:root {
  --bg: #f0ebd8;
  --surface: #f7f4e6;
  --surface-2: #e6e0c8;
  --fg: #0d1321;
  --muted: #3e5c76;
  --border: #d4ccb0;
  --accent: #1d2d44;
  --accent-hover: #2a3d57;
  --accent-tint: rgba(29, 45, 68, 0.08);
  --thumb-pulse: #ddd5b8;
  --danger: #b00020;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  max-width: 880px;
  margin: 0 auto;
  padding: 5rem 1.5rem 4rem;
}

/* ── Hero ─────────────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 3rem;
}

h1 {
  font-size: clamp(2.5rem, 5.5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.subhead {
  font-size: 1.375rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--muted);
  margin: 0 auto;
  max-width: 32ch;
}

h2 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

main section {
  margin-bottom: 5rem;
}

main section#dropzone-section,
main section#format-section,
main section#settings,
main section#results {
  margin-bottom: 1.25rem;
}

main section#results { margin-bottom: 5rem; }

/* ── Dropzone ─────────────────────────────────────────── */
#dropzone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3.5rem 1.5rem;
  min-height: 260px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease,
              box-shadow 0.18s ease, transform 0.18s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--fg);
}

#dropzone:hover,
#dropzone:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px var(--accent-tint);
  outline: none;
}

#dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
  transform: scale(1.005);
}

.dropzone-icon {
  color: var(--muted);
  margin-bottom: 0.5rem;
  transition: color 0.18s ease, transform 0.18s ease;
}

#dropzone:hover .dropzone-icon,
#dropzone.dragover .dropzone-icon {
  color: var(--accent);
  transform: translateY(-2px);
}

.dropzone-title {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.dropzone-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0.75rem 0 0;
}

.link {
  color: var(--accent);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ── Format toggle ────────────────────────────────────── */
#format-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.format-label {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--fg);
  white-space: nowrap;
}

.format-toggle {
  display: flex;
  gap: 0.375rem;
}

.fmt-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.35rem 1rem;
  border-radius: 980px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}

.fmt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.fmt-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.fmt-btn.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

/* ── Quality slider ───────────────────────────────────── */
#settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

#settings label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: var(--fg);
  font-size: 0.9375rem;
}

#quality-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

#settings input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  outline: none;
}
#settings input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 0.5px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 3px 8px rgba(0,0,0,0.08);
  cursor: pointer;
}
#settings input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 0.5px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 3px 8px rgba(0,0,0,0.08);
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────── */
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 980px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
}
button:hover { background: var(--accent-hover); }
button:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

/* "Download all" is secondary — individual Download links are primary */
#download-all {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
#download-all:hover:not(:disabled) {
  background: var(--surface-2);
}
#download-all:disabled {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}

/* ── Results ──────────────────────────────────────────── */
#results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
#results-header h2 { margin: 0; }

#file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

#file-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
#file-list li:last-child { border-bottom: none; }

#file-list .thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface-2);
}

#file-list .thumb.loading {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { background: var(--surface-2); }
  50%      { background: var(--thumb-pulse); }
}

#file-list .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
}

#file-list .status {
  color: var(--muted);
  font-size: 0.8125rem;
}

#file-list .error { color: var(--danger); }

#file-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
}
#file-list a:hover { text-decoration: underline; }

/* ── How it works (numbered circles via counters) ──────── */
.how-it-works,
.faq {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.how-it-works h2,
.faq h2 {
  text-align: center;
  margin-bottom: 2rem;
}

.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 0.25rem 0 0.25rem 3rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 500;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.steps li strong {
  color: var(--fg);
  font-weight: 500;
}

/* ── FAQ (custom +/- marker) ──────────────────────────── */
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0.25rem;
  background: transparent;
}
.faq details:first-of-type { border-top: 1px solid var(--border); }

.faq summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 1.0625rem;
  letter-spacing: -0.005em;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--fg);
  transition: color 0.15s ease;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::marker { content: ""; }

.faq summary::after {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor);
  background-size: 14px 1.5px, 1.5px 14px;
  background-position: center, center;
  background-repeat: no-repeat;
  color: var(--muted);
  transition: transform 0.2s ease, color 0.15s ease;
}

.faq details[open] summary::after {
  background-size: 14px 1.5px, 0 0;
  color: var(--accent);
}

.faq summary:hover { color: var(--accent); }
.faq summary:hover::after { color: var(--accent); }

.faq details[open] summary {
  margin-bottom: 0.75rem;
}

.faq p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
  max-width: 60ch;
}

/* ── About page code snippets ─────────────────────────── */
code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.875em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* ── Footer ───────────────────────────────────────────── */
footer {
  text-align: center;
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
}
footer a { color: var(--muted); }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 600px) {
  body { padding: 2.5rem 1rem 3rem; }
  header { margin-bottom: 2rem; }
  h1 { font-size: 2.25rem; }
  .subhead { font-size: 1.125rem; }
  main section { margin-bottom: 3.5rem; }
  #dropzone { padding: 2.5rem 1rem; min-height: 220px; }
  .dropzone-title { font-size: 1.125rem; }
  #format-section { flex-wrap: wrap; gap: 0.75rem; }
  #results-header { flex-direction: column; align-items: stretch; }
  #results-header button { width: 100%; }
  footer { margin-top: 4rem; }
}
