/* ===== CSS Variables ===== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e8ecf1;
  --text: #1a1d26;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #5b6af0;
  --primary-hover: #4a56d4;
  --primary-light: #eef0ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --border: #374151;
  --text: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --primary-light: #1e2848;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.drag-over {
  background: rgba(91,106,240,0.08);
}

[data-theme="dark"] .file-queue-item,
[data-theme="dark"] .summary-item,
[data-theme="dark"] .resize-controls,
[data-theme="dark"] .comparison-image-wrapper,
[data-theme="dark"] .comparison-slider-track {
  background: #161b25;
}

[data-theme="dark"] .result-thumb,
[data-theme="dark"] .file-queue-thumb { background: #374151; }

[data-theme="dark"] .btn-secondary { background: #263040; border-color: #374151; }
[data-theme="dark"] .btn-secondary:hover { background: #2d3a4f; }
[data-theme="dark"] .btn-ghost:hover { background: #263040; }

[data-theme="dark"] .slider { background: #374151; }
[data-theme="dark"] .progress-bar-track { background: #374151; }

[data-theme="dark"] .preset-btn { background: #263040; }
[data-theme="dark"] .preset-btn:hover { background: #374151; }

[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.7); }

[data-theme="dark"] .input { background: #263040; color: var(--text); }
[data-theme="dark"] .input::placeholder { color: #6b7280; }

/* Ensure [hidden] always wins over any display property set in CSS */
[hidden] { display: none !important; }

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* ===== Animated dot-grid background ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.3;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  animation: bgDrift 60s linear infinite;
}

[data-theme="dark"] body::before {
  opacity: 0.15;
}

@keyframes bgDrift {
  0% { background-position: 0 0; }
  100% { background-position: 28px 28px; }
}

/* ===== App Container ===== */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  padding: 0 4px;
}

.header > div:nth-child(2) {
  flex: 1;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.theme-toggle svg {
  transition: transform 0.35s ease;
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

.theme-toggle:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

[data-theme="dark"] .theme-toggle:hover { background: #263040; }

.header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius);
  flex-shrink: 0;
  animation: softPulse 3s ease-in-out infinite;
}

@keyframes softPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,106,240,0.15); }
  50% { box-shadow: 0 0 0 10px rgba(91,106,240,0); }
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.header-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  z-index: 1;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.upload-card:hover {
  transform: none;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 20px;
}

/* ===== Upload Card ===== */
.upload-card {
  padding: 0;
  overflow: hidden;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 28px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}

.drop-zone:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,240,0.12);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
  transition: color var(--transition);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.drop-zone.drag-over .drop-zone-icon {
  color: var(--primary);
  animation: bounce 0.4s ease forwards;
}

@keyframes bounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-14px) scale(1.08); }
  60% { transform: translateY(-6px) scale(1.02); }
  80% { transform: translateY(-2px); }
  100% { transform: translateY(0) scale(1); }
}

.drop-zone-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-zone-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
  line-height: 1.5;
}

.drop-zone-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
  animation: fadeInUp 0.25s ease both;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 550;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.convert-btn-ready {
  animation: pulseGlow 2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(91,106,240,0.4);
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,106,240,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(91,106,240,0); }
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: #f3f4f6;
  color: var(--text);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ===== File Queue ===== */
.file-queue-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.file-queue-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-count-badge {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.queue-total-size {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.btn-queue-clear {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--danger);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-queue-clear:hover {
  background: var(--danger-light);
}

.file-queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  animation: fadeInUp 0.25s ease both;
}

.file-queue-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: #e5e7eb;
  flex-shrink: 0;
}

.file-queue-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.file-queue-size {
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.file-queue-estimate {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.file-queue-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.file-queue-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ===== Settings Card ===== */
.settings-card {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity var(--transition);
}

.settings-card.active {
  opacity: 1;
  pointer-events: auto;
}

.setting-group {
  margin-bottom: 22px;
}

.setting-group:last-of-type {
  margin-bottom: 24px;
}

.setting-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.setting-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 20px;
}

/* ===== Slider ===== */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.slider-presets {
  display: flex;
  gap: 8px;
}

.preset-btn {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 14px;
  background: #f3f4f6;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.preset-btn:hover {
  background: #e5e7eb;
}

.preset-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ===== Toggle ===== */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.toggle-label {
  font-weight: 500;
}

/* ===== Resize Controls ===== */
.resize-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
  padding: 16px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.resize-controls.hidden {
  display: none;
}

.resize-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resize-input-group label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.resize-separator {
  font-size: 1.1rem;
  color: var(--text-muted);
  padding-bottom: 10px;
}

.input {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,240,0.12);
}

.helper-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.shortcut-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.settings-card.active .shortcut-hint {
  opacity: 1;
}

.shortcut-hint kbd {
  font-family: var(--font);
  font-size: 0.7rem;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
  font-weight: 600;
}

[data-theme="dark"] .shortcut-hint kbd {
  background: #263040;
  border-color: #374151;
}

/* ===== Progress ===== */
.progress-card {
  transition: opacity var(--transition);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.progress-header .section-title {
  margin-bottom: 0;
}

.progress-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.btn-cancel {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-cancel:hover {
  background: var(--danger-light);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  background-size: 200% 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.progress-speed {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ===== Summary ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card .btn + .btn {
  margin-top: 10px;
}

.summary-card {
  animation: fadeInUp 0.4s ease both;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
}

.summary-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.summary-value.saved {
  color: var(--success);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* ===== Results ===== */
.results-section {
  margin-top: 4px;
}

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeInUp 0.3s ease both;
  cursor: pointer;
}

.result-item:nth-child(1) { animation-delay: 0s; }
.result-item:nth-child(2) { animation-delay: 0.04s; }
.result-item:nth-child(3) { animation-delay: 0.08s; }
.result-item:nth-child(4) { animation-delay: 0.12s; }
.result-item:nth-child(5) { animation-delay: 0.16s; }
.result-item:nth-child(6) { animation-delay: 0.2s; }
.result-item:nth-child(7) { animation-delay: 0.24s; }
.result-item:nth-child(8) { animation-delay: 0.28s; }

.result-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.result-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.result-dims {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.result-sizes {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.result-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.result-saved {
  font-weight: 600;
}

.result-saved.positive {
  color: var(--success);
}

.result-saved.warning {
  color: var(--warning);
}

.result-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.result-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--primary);
  flex-shrink: 0;
}

.result-status.done {
  color: var(--success);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-status.error {
  color: var(--danger);
}

.status-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Comparison Slider ===== */
.comparison-slider {
  margin-bottom: 12px;
}

.comparison-slider-track {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #f9fafb;
  user-select: none;
}

.comparison-img-base {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: contain;
}

.comparison-img-overlay {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  clip-path: inset(0 50% 0 0);
  pointer-events: none;
}

.comparison-slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--primary);
  cursor: col-resize;
  transform: translateX(-1px);
  z-index: 2;
}

.comparison-slider-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.comparison-slider-grip::before,
.comparison-slider-grip::after {
  content: '';
  width: 2px;
  height: 12px;
  background: var(--primary);
  position: absolute;
  border-radius: 1px;
}

.comparison-slider-grip::before { left: 8px; }
.comparison-slider-grip::after { right: 8px; }

.comparison-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.comparison-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ===== Preview Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-overlay.visible {
  display: flex !important;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 650;
}

.modal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-nav-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.modal-nav-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.modal-close:hover {
  background: #f3f4f6;
}

.modal-body {
  padding: 24px;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  animation: toastIn 0.3s ease, toastOut 0.25s ease 3.5s forwards;
  pointer-events: auto;
  cursor: pointer;
  transition: background var(--transition);
}

.toast:hover {
  background: #f3f4f6;
}

[data-theme="dark"] .toast:hover {
  background: #263040;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.toast-icon.success { background: var(--success); }
.toast-icon.warning { background: var(--warning); color: var(--text); }
.toast-icon.error { background: var(--danger); }

.toast-msg {
  flex: 1;
  min-width: 0;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px 4px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Body scroll lock ===== */
body {
  padding-right: 0;
  transition: padding-right 0.1s ease;
}

body.modal-open {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .app {
    padding: 20px 12px 48px;
  }

  .header {
    margin-bottom: 24px;
  }

  .header h1 {
    font-size: 1.15rem;
  }

  .card {
    padding: 20px;
    border-radius: var(--radius);
  }

  .drop-zone {
    padding: 36px 18px;
  }

  .drop-zone-title {
    font-size: 1rem;
  }

  .summary-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .file-queue-item {
    padding: 8px 12px;
    gap: 8px;
  }

  .file-queue-size {
    display: none;
  }

  .btn-queue-clear { font-size: 0.75rem; }

  .result-item {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }

  .result-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .resize-controls {
    flex-direction: column;
    gap: 10px;
  }

  .resize-separator {
    display: none;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .modal {
    border-radius: var(--radius);
  }

  .comparison-slider-track {
    min-height: 200px;
  }
}
