/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f2f4f8;
  --bg-grid: rgba(20, 30, 55, 0.05);
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --text: #11131a;
  --text-dim: #5b6472;
  --text-faint: #8790a0;
  --border: #dde2ea;
  --border-strong: #c4cbd8;
  --accent: #2952e3;
  --accent-ink: #ffffff;
  --accent-soft: #e7ecff;
  --good: #0f9d78;
  --good-soft: #e2f6ef;
  --bad: #d1483f;
  --bad-soft: #fbe9e7;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -16px rgba(15, 23, 42, 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c11;
    --bg-grid: rgba(255, 255, 255, 0.045);
    --surface: #12151d;
    --surface-2: #181c26;
    --text: #edf0f6;
    --text-dim: #9aa3b5;
    --text-faint: #6b7284;
    --border: #262b38;
    --border-strong: #343b4c;
    --accent: #6a8bff;
    --accent-ink: #0a0c11;
    --accent-soft: #1c2440;
    --good: #34d3a3;
    --good-soft: #133329;
    --bad: #ef6c62;
    --bad-soft: #3a1d1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-grid: rgba(255, 255, 255, 0.045);
  --surface: #12151d;
  --surface-2: #181c26;
  --text: #edf0f6;
  --text-dim: #9aa3b5;
  --text-faint: #6b7284;
  --border: #262b38;
  --border-strong: #343b4c;
  --accent: #6a8bff;
  --accent-ink: #0a0c11;
  --accent-soft: #1c2440;
  --good: #34d3a3;
  --good-soft: #133329;
  --bad: #ef6c62;
  --bad-soft: #3a1d1c;
  color-scheme: dark;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.015em; font-weight: 700; }
input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 920px; margin-inline: auto; padding-inline: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--text); color: var(--bg);
  border-radius: var(--radius-s); font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }
.mono { font-family: var(--mono); }
.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* =============================================================
   4. Typography
   ============================================================= */
.hero-title { font-size: clamp(1.9rem, 4.4vw, 2.9rem); max-width: 20ch; margin-inline: auto; text-align: center; }
.hero-sub {
  color: var(--text-dim);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  max-width: 46ch;
  margin: .85rem auto 0;
  text-align: center;
}
.section-title { font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin-bottom: .5rem; }
.section-lede { color: var(--text-dim); max-width: 62ch; }
.prose { color: var(--text-dim); max-width: 68ch; }
.prose p + p { margin-top: 1rem; }
.prose strong { color: var(--text); }

/* =============================================================
   5. Components
   ============================================================= */

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.15rem;
  border-radius: var(--radius-s);
  font-weight: 700;
  font-size: .95rem;
  transition: transform .15s var(--ease-out), background .15s var(--ease-out), border-color .15s var(--ease-out);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); padding: .5rem .7rem; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: .5rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* --- Segmented control (format picker) --- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 3px;
  background: var(--surface-2);
  gap: 2px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  cursor: pointer;
  padding: .5rem .85rem;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.segmented input:checked + label { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented label[data-disabled="true"] { opacity: .35; cursor: not-allowed; }

/* --- Field --- */
.field { display: flex; flex-direction: column; gap: .45rem; }
.field-label {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
}
.field-label .value { color: var(--accent); font-weight: 700; }
.field-hint { font-size: .8rem; color: var(--text-faint); }

/* --- Range slider --- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 80%), var(--surface-2) var(--fill, 80%), var(--surface-2) 100%);
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(15,23,42,.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(15,23,42,.25);
  cursor: pointer; border: 3px solid var(--accent);
}
input[type="range"]::-moz-range-track { background: transparent; }
input[type="range"]:disabled { opacity: .4; }

/* --- Number input --- */
.number-input {
  display: flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface); padding: .55rem .7rem;
}
.number-input input {
  border: 0; background: transparent; width: 100%; font-family: var(--mono); font-size: .92rem;
}
.number-input input:focus { outline: none; }
.number-input .unit { color: var(--text-faint); font-family: var(--mono); font-size: .8rem; }

/* --- Tool card --- */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}
@media (min-width: 720px) { .tool-card { padding: 2rem; } }

.tool-grid { display: grid; gap: 1.5rem; }

/* --- Dropzone --- */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .65rem;
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
}
.dropzone::before, .dropzone::after,
.dropzone .corner-a, .dropzone .corner-b { content: ""; }
.dropzone-corner {
  position: absolute; width: 16px; height: 16px;
  border-color: var(--accent); opacity: 0; transition: opacity .18s var(--ease-out);
}
.dropzone-corner.tl { top: 8px; left: 8px; border-top: 2px solid; border-left: 2px solid; }
.dropzone-corner.tr { top: 8px; right: 8px; border-top: 2px solid; border-right: 2px solid; }
.dropzone-corner.bl { bottom: 8px; left: 8px; border-bottom: 2px solid; border-left: 2px solid; }
.dropzone-corner.br { bottom: 8px; right: 8px; border-bottom: 2px solid; border-right: 2px solid; }
.dropzone:hover, .dropzone:focus-within, .dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone:hover .dropzone-corner, .dropzone:focus-within .dropzone-corner, .dropzone.is-dragover .dropzone-corner { opacity: 1; }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon { color: var(--accent); }
.dropzone-title { font-weight: 700; font-size: 1.05rem; }
.dropzone-sub { color: var(--text-faint); font-size: .85rem; }

/* --- Controls row --- */
.controls-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .controls-grid { grid-template-columns: auto 1fr auto; align-items: end; gap: 1.75rem; }
}
.webp-note { font-size: .76rem; color: var(--text-faint); margin-top: .3rem; }

/* --- File queue / results --- */
.queue { display: flex; flex-direction: column; gap: .6rem; }
.queue-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .5rem 1rem;
  padding: .85rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.queue-row[data-status="error"] { border-color: var(--bad); background: var(--bad-soft); }
.qr-name {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: .5rem;
  font-size: .9rem; font-weight: 600;
  overflow: hidden;
}
.qr-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-remove { flex: 0 0 auto; margin-left: auto; color: var(--text-faint); }
.qr-remove:hover { color: var(--bad); }
.qr-meta {
  grid-column: 1 / -1;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem;
  font-family: var(--mono); font-size: .8rem; color: var(--text-dim);
}
.qr-arrow { color: var(--text-faint); }
.qr-badge {
  font-family: var(--mono); font-size: .74rem; font-weight: 700;
  padding: .15rem .5rem; border-radius: 999px;
}
.qr-badge.is-good { background: var(--good-soft); color: var(--good); }
.qr-badge.is-bad { background: var(--bad-soft); color: var(--bad); }
.qr-progress {
  grid-column: 1 / -1;
  height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden;
}
.qr-progress > span {
  display: block; height: 100%; width: 0%; background: var(--accent);
  transition: width .2s var(--ease-out);
}
.qr-error-msg { grid-column: 1 / -1; font-size: .82rem; color: var(--bad); }
.qr-download { grid-column: 1 / -1; justify-self: start; }

/* --- Actions bar --- */
.actions-bar {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
}
.actions-bar .stat { font-family: var(--mono); font-size: .82rem; color: var(--text-dim); margin-left: auto; }

/* --- Privacy / limits badges --- */
.badge-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.info-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .8rem; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .4rem .7rem; border-radius: 999px;
}
.info-pill svg { flex: 0 0 auto; color: var(--good); }

/* --- Ad slots --- */
.ad-slot {
  min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-m);
  color: var(--text-faint);
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px);
}
.ad-slot.leaderboard { max-width: 728px; margin-inline: auto; min-height: 90px; }

/* --- Steps --- */
.steps-grid { display: grid; gap: 1.25rem; margin-top: 1.75rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1.25rem;
  background: var(--surface);
  position: relative;
}
.step-num {
  font-family: var(--mono); font-weight: 700; font-size: .82rem;
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--accent);
  margin-bottom: .85rem;
}
.step-title { font-size: 1.02rem; margin-bottom: .4rem; }
.step-text { color: var(--text-dim); font-size: .92rem; }

/* --- FAQ --- */
.faq-list { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.5rem; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.15rem;
  font-weight: 700;
  font-size: .98rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .plus {
  flex: 0 0 auto; color: var(--accent); font-family: var(--mono);
  transition: transform .2s var(--ease-out);
}
.faq-item[open] summary .plus { transform: rotate(45deg); }
.faq-item .faq-body { padding: 0 1.15rem 1.1rem; color: var(--text-dim); font-size: .92rem; }

/* --- Section wrapper --- */
.section { padding-block: 3rem; }
.section-head { text-align: left; margin-bottom: .25rem; }

/* --- Header / Footer --- */
.site-header {
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 800; font-size: .95rem;
}
.header-note { font-size: .8rem; color: var(--text-faint); font-family: var(--mono); white-space: nowrap; }
.header-note strong { color: var(--good); }
@media (max-width: 539px) { .header-note { display: none; } }

.theme-toggle {
  width: 38px; height: 38px; border-radius: var(--radius-s);
  border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2rem;
  margin-top: 2rem;
}
.footer-grid { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .85rem; color: var(--text-dim); }
.footer-links a:hover { color: var(--accent); }
.footer-credit { font-size: .78rem; color: var(--text-faint); }

/* --- No-JS notice --- */
.nojs-only { display: none; }
noscript .nojs-only,
.no-js-notice { display: block; }

/* =============================================================
   6. Hero
   ============================================================= */
.hero { padding-block: 2.75rem 1rem; }
@media (min-width: 720px) { .hero { padding-block: 3.75rem 1.5rem; } }

/* =============================================================
   7. Effects
   ============================================================= */
[data-state="idle"] .queue-wrap,
[data-state="idle"] .actions-bar { display: none; }
[data-state="empty"] .queue-wrap,
[data-state="empty"] .actions-bar { display: none; }
.fade-in { animation: fadeIn .35s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
}

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 539px) {
  .actions-bar .stat { margin-left: 0; width: 100%; }
  .qr-download { width: 100%; }
}
