/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f2ede4;
  --text: #18140f;
  --text-muted: #635c4e;
  --border: #e6ded0;
  --accent: #ff5a36;
  --accent-hover: #e8481f;
  --accent-contrast: #fff9f6;
  --success: #1f9d55;
  --success-bg: #e9f8ef;
  --danger: #d64545;
  --danger-bg: #fdecec;
  --focus: #ff5a36;

  --sans: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", Georgia, serif;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow-card: 0 1px 2px rgba(24,20,15,.04), 0 12px 28px -14px rgba(24,20,15,.16);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f;
    --surface: #1d1a15;
    --surface-2: #262219;
    --text: #f3efe4;
    --text-muted: #a89f8c;
    --border: #38332a;
    --accent: #ff7a52;
    --accent-hover: #ff8f6b;
    --accent-contrast: #1a1108;
    --success: #4ec97e;
    --success-bg: #16281d;
    --danger: #ff8080;
    --danger-bg: #2c1717;
    --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 12px 28px -14px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --bg: #14120f;
  --surface: #1d1a15;
  --surface-2: #262219;
  --text: #f3efe4;
  --text-muted: #a89f8c;
  --border: #38332a;
  --accent: #ff7a52;
  --accent-hover: #ff8f6b;
  --accent-contrast: #1a1108;
  --success: #4ec97e;
  --success-bg: #16281d;
  --danger: #ff8080;
  --danger-bg: #2c1717;
  --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 12px 28px -14px rgba(0,0,0,.55);
}

/* =============================================================
   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; }
@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;
  transition: background-color .3s var(--ease-out), color .3s var(--ease-out);
}
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.08; letter-spacing: -0.02em; font-family: var(--display); font-weight: 600; }
ul, ol { list-style: none; padding: 0; }
::selection { background: var(--accent); color: var(--accent-contrast); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 760px; margin-inline: auto; padding-inline: 1.25rem; }
.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-card);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.9rem, 4.6vw, 2.7rem); max-width: 20ch; margin-inline: auto; text-align: center; }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); margin-bottom: 1.1rem; }
h3 { font-size: 1.05rem; font-family: var(--sans); font-weight: 700; margin-block: .5rem .3rem; }

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

/* header */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-block: .9rem; max-width: 900px; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; color: var(--text); }
.logo svg { color: var(--accent); flex-shrink: 0; }
.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted);
  transition: color .2s var(--ease-out), border-color .2s var(--ease-out), background-color .2s var(--ease-out);
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle .icon-moon { display: none; }
@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; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: var(--radius-s); font-weight: 700; font-size: .95rem;
  transition: transform .15s var(--ease-out), background-color .15s var(--ease-out), box-shadow .15s var(--ease-out), border-color .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-big { width: 100%; padding: 1rem; font-size: 1rem; }

/* tool card */
.tool-section { padding-block: 2.4rem 1rem; text-align: center; }
.tool-subtitle { color: var(--text-muted); max-width: 46ch; margin: .7rem auto 1.8rem; font-size: 1.02rem; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--shadow-card); padding: 1.5rem; text-align: left;
}
.noscript-msg { text-align: center; color: var(--text-muted); padding: 1rem; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  border: 2px dashed var(--border); border-radius: var(--radius-m);
  padding: 3rem 1.5rem; text-align: center; cursor: pointer; color: var(--text-muted);
  transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.dropzone svg { color: var(--accent); }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
.dropzone-title { font-weight: 700; font-size: 1.1rem; color: var(--text); font-family: var(--display); }
.dropzone-sub { font-size: .88rem; }

.format-bar { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-end; margin-bottom: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .82rem; font-weight: 700; color: var(--text-muted); }
.field-quality { flex: 1 1 200px; }
#target-format {
  padding: .6rem .8rem; border-radius: var(--radius-s); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: .95rem;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.webp-warning { flex-basis: 100%; font-size: .85rem; color: var(--danger); background: var(--danger-bg); padding: .55rem .8rem; border-radius: var(--radius-s); }

.file-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.2rem; max-height: 420px; overflow-y: auto; }
.file-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: .8rem;
  padding: .6rem; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
}
.file-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.file-info { min-width: 0; }
.file-name { font-size: .88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .78rem; color: var(--text-muted); }
.file-status { font-size: .78rem; font-weight: 700; text-align: right; white-space: nowrap; }
.file-status.is-ok { color: var(--success); }
.file-status.is-error { color: var(--danger); }
.file-row .progress-track { width: 100%; height: 5px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.file-row .progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width .2s var(--ease-out); }
.file-download {
  font-size: .8rem; font-weight: 700; color: var(--accent); border: 1px solid var(--border);
  padding: .35rem .6rem; border-radius: 6px; white-space: nowrap;
}
.file-download:hover { background: var(--surface-2); }
.file-remove { color: var(--text-muted); font-size: 1.1rem; line-height: 1; padding: .2rem .4rem; }
.file-remove:hover { color: var(--danger); }

.tool-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; }
.tool-actions .btn-primary { flex: 1 1 auto; min-width: 180px; }

.post-convert { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.done-summary { text-align: center; padding: 0 0 1.2rem; }
.done-summary strong { font-family: var(--display); font-size: 1.3rem; display: block; margin-bottom: .3rem; }
.post-convert .tool-actions { justify-content: center; flex-direction: column; }
.link-reset { text-align: center; color: var(--text-muted); text-decoration: underline; font-size: .9rem; }
.link-reset:hover { color: var(--text); }

.tool-error { text-align: center; padding: 1rem 0; }
.error-msg { color: var(--danger); margin-bottom: 1rem; font-weight: 600; }

.privacy-badge { text-align: center; margin-top: 1.2rem; color: var(--text-muted); font-size: .88rem; }
.limits-note { text-align: center; margin-top: .35rem; color: var(--text-muted); font-size: .8rem; }

/* ad slots */
.ad-slot {
  margin-block: 2.2rem; min-height: 90px; border: 1px dashed var(--border); border-radius: var(--radius-s);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .78rem;
}
.ad-label { text-transform: uppercase; letter-spacing: .08em; }

/* content sections */
.content-section { padding-block: 1.5rem 2rem; }
.steps { display: grid; gap: 1.4rem; margin-bottom: 2.2rem; }
.steps li { padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface); }
.steps svg { color: var(--accent); margin-bottom: .5rem; }
.steps p { color: var(--text-muted); font-size: .92rem; }
.seo-text p { margin-bottom: 1rem; color: var(--text-muted); }
.seo-text strong { color: var(--text); }

.faq-section { padding-block: 1rem 3rem; }
[data-faq-list] details {
  border: 1px solid var(--border); border-radius: var(--radius-s); padding: .9rem 1.1rem; margin-bottom: .7rem; background: var(--surface);
}
[data-faq-list] summary { font-weight: 700; cursor: pointer; list-style: none; }
[data-faq-list] summary::-webkit-details-marker { display: none; }
[data-faq-list] summary::after { content: "+"; float: right; color: var(--accent); font-weight: 800; }
[data-faq-list] details[open] summary::after { content: "–"; }
[data-faq-list] p { color: var(--text-muted); margin-top: .6rem; font-size: .93rem; }

/* legal pages */
.legal-page { padding-block: 2.5rem 4rem; }
.legal-page h1 { text-align: left; margin-bottom: .3rem; }
.legal-page .updated { color: var(--text-muted); font-size: .85rem; margin-bottom: 1.6rem; }
.legal-page h2 { font-size: 1.15rem; margin-top: 1.8rem; }
.legal-page p, .legal-page li { color: var(--text-muted); margin-bottom: .7rem; }
.legal-page li { list-style: disc; margin-left: 1.3rem; }
.legal-page a { color: var(--accent); text-decoration: underline; }

/* footer */
.site-footer { border-top: 1px solid var(--border); padding-block: 1.6rem; margin-top: 1rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: .85rem; }
.footer-nav { display: flex; gap: 1.1rem; }
.footer-nav a:hover { color: var(--text); text-decoration: underline; }

/* =============================================================
   6. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 720px) {
  .container { padding-inline: 2rem; }
}
