/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #10201c;
  --text-dim: #4b5f5a;
  --border: #dbe4e1;
  --accent: #0d8f7f;
  --accent-strong: #086b5f;
  --accent-contrast: #ffffff;
  --danger: #c0442f;
  --warn-bg: #fff4e5;
  --warn-text: #7a4a08;
  --shadow: 0 1px 2px rgba(16, 32, 28, 0.06), 0 8px 24px rgba(16, 32, 28, 0.06);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Fraunces", var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1613;
    --surface: #131f1b;
    --surface-2: #182823;
    --text: #eaf3f0;
    --text-dim: #a9beb8;
    --border: #24352f;
    --accent: #2bd6bd;
    --accent-strong: #57e3cf;
    --accent-contrast: #06231e;
    --warn-bg: #2a2110;
    --warn-text: #f0c481;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1613;
  --surface: #131f1b;
  --surface-2: #182823;
  --text: #eaf3f0;
  --text-dim: #a9beb8;
  --border: #24352f;
  --accent: #2bd6bd;
  --accent-strong: #57e3cf;
  --accent-contrast: #06231e;
  --warn-bg: #2a2110;
  --warn-text: #f0c481;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
}

/* =============================================================
   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);
  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%; }
img { height: auto; }
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.01em; font-family: var(--display); }
ul, ol { padding-left: 1.2em; }
::selection { background: var(--accent); color: var(--accent-contrast); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--surface); color: var(--text);
  z-index: 9999; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.section { padding-block: clamp(2.5rem, 6vw, 5rem); }
.section-head { max-width: 68ch; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: .6rem; }
.section-head p { color: var(--text-dim); font-size: 1.05rem; }
.eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-strong); margin-bottom: .5rem;
}

/* =============================================================
   4. Buttons
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.4rem; border-radius: 999px; font-weight: 600; font-size: .98rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow); }
.btn--primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn--primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--ghost { background: var(--surface-2); color: var(--text); }
.btn--ghost:hover { background: var(--border); }
.btn--small { padding: .5rem .9rem; font-size: .85rem; }
.btn--link { padding: 0; color: var(--accent-strong); font-weight: 600; }
.btn--link:hover { text-decoration: underline; }

/* =============================================================
   5. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; padding-block: .9rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-contrast); font-size: .95rem; flex-shrink: 0; }
.header-nav { display: flex; align-items: center; gap: 1.4rem; }
.header-nav a { font-size: .92rem; font-weight: 600; color: var(--text-dim); }
.header-nav a:hover { color: var(--text); }

/* =============================================================
   6. Hero + tool
   ============================================================= */
.hero { padding-block: clamp(2rem, 5vw, 3.2rem) 1rem; }
.hero .container { max-width: 900px; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 3.1rem); margin-bottom: .8rem; max-width: 22ch; margin-inline: auto; }
.hero p.sub { color: var(--text-dim); font-size: clamp(1rem, 1.6vw, 1.2rem); max-width: 56ch; margin-inline: auto; }
.hero-badges { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1.1rem; }
.pill {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); padding: .35rem .75rem; border-radius: 999px; color: var(--text-dim);
}
.pill svg { width: 14px; height: 14px; color: var(--accent-strong); flex-shrink: 0; }

.tool-section { padding-block: 1.5rem clamp(2rem, 5vw, 3rem); }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: clamp(1.1rem, 3vw, 2rem); max-width: 980px; margin-inline: auto;
}

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: clamp(1.6rem, 5vw, 2.6rem);
  text-align: center; cursor: pointer; transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dropzone-icon { width: 46px; height: 46px; margin: 0 auto .8rem; color: var(--accent-strong); }
.dropzone h3 { font-size: 1.15rem; margin-bottom: .3rem; }
.dropzone p { color: var(--text-dim); font-size: .92rem; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.controls-row {
  display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; align-items: center; justify-content: space-between;
}
.preset-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.preset-btn {
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: .87rem; font-weight: 600; color: var(--text-dim); transition: all .16s var(--ease-out);
}
.preset-btn:hover { border-color: var(--accent); color: var(--text); }
.preset-btn.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.output-panel { margin-top: 1rem; padding: 1rem; background: var(--surface-2); border-radius: var(--radius); }
.output-panel[hidden] { display: none; }
.output-modes { display: flex; flex-wrap: wrap; gap: .9rem; }
.output-mode {
  display: flex; align-items: center; gap: .45rem; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.color-inputs { display: flex; gap: 1rem; margin-top: .8rem; flex-wrap: wrap; }
.color-inputs label { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600; color: var(--text-dim); }
.color-inputs input[type="color"] { width: 40px; height: 32px; border-radius: 8px; border: 1px solid var(--border); padding: 0; }

.limit-notice {
  margin-top: .9rem; padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-text);
  font-size: .87rem; font-weight: 600;
}
.limit-notice[hidden] { display: none; }

.engine-progress { margin-top: 1rem; display: none; }
[data-tool-card][data-state="loading-engine"] .engine-progress,
[data-tool-card][data-state="working"] .engine-progress { display: block; }
.engine-progress-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.engine-progress-bar { height: 100%; width: 4%; background: var(--accent); transition: width .3s var(--ease-out); }
.engine-progress p { margin-top: .5rem; font-size: .85rem; color: var(--text-dim); }

.results { margin-top: 1.4rem; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: .9rem; }
.results-head h3 { font-size: 1.05rem; }
.results-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.items-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem;
}
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2);
}
.result-card__preview {
  position: relative; aspect-ratio: 1; background-image:
    linear-gradient(45deg, #d9dfdd 25%, transparent 25%), linear-gradient(-45deg, #d9dfdd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9dfdd 75%), linear-gradient(-45deg, transparent 75%, #d9dfdd 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.result-card__preview img { width: 100%; height: 100%; object-fit: contain; }
.result-card__overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  background: rgba(10, 20, 18, .55); color: #fff; font-size: .78rem; font-weight: 600; text-align: center; padding: .5rem;
  opacity: 1; transition: opacity .25s var(--ease-out);
}
.result-card[data-state="done"] .result-card__overlay { opacity: 0; pointer-events: none; }
.result-card[data-state="error"] .result-card__overlay { background: rgba(120, 30, 20, .72); cursor: pointer; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.result-card[data-state="done"] .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-card__meta { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .55rem .6rem; }
.result-card__name { font-size: .76rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; }

.privacy-badge {
  display: flex; align-items: flex-start; gap: .7rem; margin-top: 1.3rem; padding: .9rem 1rem;
  background: var(--surface-2); border-radius: var(--radius); font-size: .87rem; color: var(--text-dim);
}
.privacy-badge svg { width: 20px; height: 20px; color: var(--accent-strong); flex-shrink: 0; margin-top: 2px; }
.privacy-badge strong { color: var(--text); }
.limits-note { margin-top: .6rem; font-size: .8rem; color: var(--text-dim); }

.tool-reset { margin-top: .9rem; text-align: center; }

.needs-js-note { display: none; text-align: center; padding: 2rem; color: var(--text-dim); }
html.no-js .needs-js-note { display: block; }
html.no-js .tool-card > *:not(.needs-js-note) { display: none; }

/* =============================================================
   7. Ad slots
   ============================================================= */
.ad-slot {
  margin-inline: auto; max-width: 980px; min-height: 100px; border: 1px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: .78rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; background: var(--surface-2); margin-block: 1.5rem;
}

/* =============================================================
   8. Content sections
   ============================================================= */
.info-grid { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .info-grid { grid-template-columns: repeat(3, 1fr); } }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.info-card h3 { font-size: 1.02rem; margin-bottom: .5rem; }
.info-card p { color: var(--text-dim); font-size: .92rem; }

.steps { display: grid; gap: 1rem; grid-template-columns: 1fr; counter-reset: step; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(4, 1fr); } }
.step { position: relative; padding-top: 2.6rem; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 0; left: 0; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast); font-weight: 700; display: grid; place-items: center; font-family: var(--display);
}
.step h3 { font-size: .98rem; margin-bottom: .35rem; }
.step p { color: var(--text-dim); font-size: .88rem; }

.prose { max-width: 72ch; }
.prose p { margin-bottom: 1rem; color: var(--text-dim); }
.prose h3 { margin-top: 1.6rem; margin-bottom: .5rem; font-size: 1.15rem; color: var(--text); }
.prose ul { color: var(--text-dim); margin-bottom: 1rem; }
.prose li { margin-bottom: .35rem; }

.compare-table-wrap { overflow-x: auto; margin-block: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
table.compare { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
table.compare th, table.compare td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
table.compare th { background: var(--surface-2); font-family: var(--display); font-weight: 600; }
table.compare td.brand-col, table.compare th.brand-col { font-weight: 700; }
table.compare tr:last-child td { border-bottom: none; }

.faq-list { max-width: 76ch; }
details.faq-item {
  border-bottom: 1px solid var(--border); padding-block: 1rem;
}
details.faq-item summary {
  cursor: pointer; font-weight: 700; font-size: 1rem; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
details.faq-item summary::-webkit-details-marker { display: none; }
details.faq-item summary::after {
  content: "+"; font-size: 1.3rem; color: var(--accent-strong); flex-shrink: 0; transition: transform .2s var(--ease-out);
}
details.faq-item[open] summary::after { transform: rotate(45deg); }
details.faq-item p { margin-top: .7rem; color: var(--text-dim); font-size: .95rem; }

/* =============================================================
   9. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); padding-block: 2.4rem; margin-top: 2rem; }
.footer-grid { display: flex; flex-wrap: wrap; gap: 1.6rem; justify-content: space-between; align-items: flex-start; }
.footer-brand p { color: var(--text-dim); font-size: .88rem; max-width: 34ch; margin-top: .5rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem 1.6rem; }
.footer-links a { font-size: .88rem; color: var(--text-dim); font-weight: 600; }
.footer-links a:hover { color: var(--text); }
.footer-bottom { margin-top: 1.8rem; padding-top: 1.4rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; justify-content: space-between; }

/* Legal pages */
.legal-page main { padding-block: clamp(2rem, 5vw, 3.5rem); }
.legal-page .prose h2 { margin-top: 2rem; margin-bottom: .6rem; font-size: 1.3rem; }
.legal-page .prose h2:first-child { margin-top: 0; }
.legal-updated { color: var(--text-dim); font-size: .85rem; margin-bottom: 2rem; }

/* =============================================================
   10. Responsive
   ============================================================= */
@media (max-width: 539px) {
  .header-nav { gap: .8rem; }
  .header-nav a { font-size: .82rem; }
  .controls-row { flex-direction: column; align-items: stretch; }
  .results-head { flex-direction: column; align-items: flex-start; }
}
