/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --surface: #f7f7f9;
  --border: #e6e6eb;
  --fg: #14141a;
  --muted: #64646f;
  --accent: #5b5bf0;
  --accent-fg: #ffffff;
  --accent-soft: #eeeeff;
  --success: #17a673;
  --danger: #d33a3a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 26, .05), 0 1px 3px rgba(20, 20, 26, .06);
  --shadow-md: 0 4px 24px -8px rgba(20, 20, 26, .12), 0 2px 8px -2px rgba(20, 20, 26, .08);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0f;
    --surface: #131318;
    --border: #26262f;
    --fg: #f2f2f6;
    --muted: #9a9aa8;
    --accent: #8686ff;
    --accent-fg: #0b0b0f;
    --accent-soft: #1c1c2c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 30px -10px rgba(0, 0, 0, .5);
  }
}
html[data-theme="dark"] {
  --bg: #0b0b0f; --surface: #131318; --border: #26262f; --fg: #f2f2f6;
  --muted: #9a9aa8; --accent: #8686ff; --accent-fg: #0b0b0f; --accent-soft: #1c1c2c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 8px 30px -10px rgba(0,0,0,.5);
}
html[data-theme="light"] {
  --bg: #ffffff; --surface: #f7f7f9; --border: #e6e6eb; --fg: #14141a;
  --muted: #64646f; --accent: #5b5bf0; --accent-fg: #ffffff; --accent-soft: #eeeeff;
  --shadow-sm: 0 1px 2px rgba(20,20,26,.05), 0 1px 3px rgba(20,20,26,.06);
  --shadow-md: 0 4px 24px -8px rgba(20,20,26,.12), 0 2px 8px -2px rgba(20,20,26,.08);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
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.1; letter-spacing: -0.02em; font-weight: 600; }
ul { list-style: none; padding: 0; }
::selection { background: var(--accent); color: var(--accent-fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.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;
}
.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--fg); color: var(--bg); z-index: 9999; border-radius: 8px; font-weight: 500;
  transition: top .15s var(--ease-out);
}
.skip-link:focus { top: 1rem; }
.muted { color: var(--muted); }
.text-center { text-align: center; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(2rem, 1.5rem + 2vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 1.3rem + 1vw, 2.25rem); }
h3 { font-size: 1.15rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: .04em;
}

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: .95rem;
  transition: transform .15s var(--ease-out), background-color .15s var(--ease-out), opacity .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { opacity: .92; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
.btn-ghost:hover { border-color: var(--fg); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 26px; font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  border: 1px solid var(--border); padding: 6px 14px; font-size: .85rem;
  transition: all .15s var(--ease-out); background: var(--bg);
}
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.pill:hover:not([aria-pressed="true"]) { border-color: var(--fg); }

/* =============================================================
   6. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  color: var(--accent-fg); display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
}
.main-nav { display: none; align-items: center; gap: 28px; font-size: .9rem; color: var(--muted); }
.main-nav a:hover { color: var(--fg); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg); }
.nav-toggle { display: flex; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border); align-items: center; justify-content: center; }

@media (min-width: 720px) {
  .main-nav { display: flex; }
  .nav-toggle { display: none; }
}

.mobile-nav {
  display: none; flex-direction: column; padding: 8px 20px 16px; border-top: 1px solid var(--border);
}
.mobile-nav.is-open { display: flex; }
.mobile-nav a { padding: 10px 0; color: var(--muted); }
.mobile-nav a:hover { color: var(--fg); }

/* =============================================================
   7. Hero + Tool card
   ============================================================= */
.hero { padding: 56px 0 8px; text-align: center; }
.hero p.lead { margin: 14px auto 0; max-width: 560px; color: var(--muted); font-size: 1.05rem; }

.tool-section { padding: 32px 0 8px; }
.tool-card {
  max-width: 640px; margin: 0 auto; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { margin: 0 auto 12px; color: var(--muted); }
.dropzone .dz-title { font-weight: 600; }
.dropzone .dz-sub { margin-top: 4px; font-size: .85rem; color: var(--muted); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }

.file-info {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.file-info .file-icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-info .file-meta { min-width: 0; flex: 1; }
.file-info .file-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info .file-size { font-size: .8rem; color: var(--muted); }
.file-info .file-change { font-size: .8rem; color: var(--muted); text-decoration: underline; flex-shrink: 0; }
.file-info .file-change:hover { color: var(--fg); }

.field-group { margin-top: 20px; }
.field-label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 8px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

.progress-track {
  height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 6px;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0%; transition: width .25s var(--ease-out); }
.progress-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 6px; }

.step-list { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; margin-bottom: 16px; }
.step-list li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.step-list li.is-active { color: var(--fg); font-weight: 600; }
.step-list li.is-done { color: var(--success); }
.step-list .dot { width: 8px; height: 8px; border-radius: 999px; background: currentColor; flex-shrink: 0; }

.result-box { text-align: center; }
.result-box .result-icon { color: var(--success); font-size: 1.5rem; margin-bottom: 8px; }
.result-box .result-meta { font-size: .85rem; color: var(--muted); margin: 6px 0 18px; }

.error-box {
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: .9rem;
}
.error-box strong { display: block; color: var(--danger); margin-bottom: 2px; }

.privacy-badge {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 18px;
  font-size: .82rem; color: var(--muted); line-height: 1.5;
}
.privacy-badge svg { flex-shrink: 0; margin-top: 2px; color: var(--success); }

[data-tool-state] .tool-panel { display: none; }
[data-tool-state="idle"] .tool-panel--idle { display: block; }
[data-tool-state="loading-engine"] .tool-panel--loading-engine { display: block; }
[data-tool-state="working"] .tool-panel--working { display: block; }
[data-tool-state="done"] .tool-panel--done { display: block; }
[data-tool-state="error"] .tool-panel--error { display: block; }

/* =============================================================
   8. Ad slots
   ============================================================= */
.ad-slot {
  max-width: var(--container); margin: 32px auto; min-height: 100px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
}

/* =============================================================
   9. Content sections
   ============================================================= */
.section { padding: 56px 0; }
.section-head { max-width: 640px; margin: 0 auto 32px; text-align: center; }
.section-head p { margin-top: 10px; color: var(--muted); }

.steps-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.step-card { padding: 22px; }
.step-card .step-num {
  width: 32px; height: 32px; border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; margin-bottom: 14px;
}
.step-card h3 { margin-bottom: 6px; }
.step-card p { color: var(--muted); font-size: .92rem; }

.format-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.format-card { padding: 18px; }
.format-card .format-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.format-card .format-tag {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}
.format-card p { color: var(--muted); font-size: .87rem; }

.seo-copy { max-width: 720px; margin: 0 auto; color: var(--muted); }
.seo-copy p + p { margin-top: 14px; }

.faq-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.faq-item summary {
  cursor: pointer; padding: 16px 18px; font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; color: var(--muted); transition: transform .15s var(--ease-out); }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-answer { padding: 0 18px 16px; color: var(--muted); font-size: .9rem; }

.related-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.related-card { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; }
.related-card:hover { border-color: var(--fg); }

.credits { font-size: .78rem; color: var(--muted); margin-top: 10px; }
.credits a { text-decoration: underline; }

/* =============================================================
   10. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); padding: 44px 0 26px; margin-top: 40px; }
.footer-grid { display: grid; gap: 28px; grid-template-columns: 1fr 1fr; }
.footer-col h4 { font-size: .85rem; margin-bottom: 12px; }
.footer-col ul { display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--muted); font-size: .88rem; }
.footer-col a:hover { color: var(--fg); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }

/* =============================================================
   11. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .format-grid { grid-template-columns: repeat(3, 1fr); }
  .related-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 720px) {
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 960px) {
  .format-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   12. Reduced motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; }
}

/* =============================================================
   13. No-JS fallback
   ============================================================= */
.no-js-note { display: none; }
html:not(.js) .no-js-note { display: block; margin-top: 14px; }
html:not(.js) [data-tool-state] .tool-panel { display: none; }
html:not(.js) [data-tool-state] .tool-panel--idle { display: block; }
html:not(.js) .dropzone { opacity: .6; pointer-events: none; }
