/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #1b201d;
  --ink-soft: #5a635c;
  --hair: #dfe3dd;
  --accent: #2f6b52;
  --accent-ink: #ffffff;
  --danger: #a5423a;
  --danger-soft: #f7e6e4;
  --radius: 14px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Manrope", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2023;
    --ink: #e9ebe6;
    --ink-soft: #a3aca3;
    --hair: #2c3134;
    --accent: #5fb98c;
    --accent-ink: #0e1210;
    --danger: #e0847e;
    --danger-soft: #33201f;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
  z-index: 999; border-radius: 8px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* =============================================================
   3. Header / footer
   ============================================================= */
.site-header { padding: 22px 0 6px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 19px; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }

.site-footer { padding: 40px 0 60px; }
.site-footer p { font-size: 13px; color: var(--ink-soft); text-align: center; }
.site-footer a { color: var(--ink-soft); text-decoration: underline; }
.footer-links { margin-bottom: 10px; font-size: 13px !important; }
.footer-note { font-size: 12px !important; max-width: 54ch; margin: 8px auto 0; opacity: .75; }

/* =============================================================
   4. Intro
   ============================================================= */
.intro { padding: 28px 0 22px; text-align: center; }
.intro h1 { font-size: clamp(28px, 5vw, 38px); margin: 0 0 12px; }
.lede { color: var(--ink-soft); font-size: 16px; max-width: 52ch; margin: 0 auto; }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px -14px rgba(0,0,0,.15);
}

.panel { display: none; padding: 28px 20px; }
.tool-card[data-state="idle"] .panel-idle { display: block; }
.tool-card[data-state="loading-engine"] .panel-progress,
.tool-card[data-state="working"] .panel-progress { display: flex; }
.tool-card[data-state="done"] .panel-done { display: block; }
.tool-card[data-state="error"] .panel-error { display: block; }

/* idle / dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; padding: 46px 20px;
  border: 2px dashed var(--hair); border-radius: 10px;
  cursor: pointer; color: var(--ink-soft);
  transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.dz-icon { color: var(--accent); margin-bottom: 4px; }
.dz-title { font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--ink); }
.dz-sub { font-size: 14px; }
.dz-privacy { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 14px; opacity: .8; }

/* progress */
.panel-progress { flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--hair); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-msg { font-size: 14.5px; color: var(--ink-soft); max-width: 46ch; }
.progress-track { width: 100%; max-width: 320px; height: 6px; border-radius: 4px; background: var(--hair); overflow: hidden; }
.progress-fill { height: 100%; width: 8%; background: var(--accent); border-radius: 4px; transition: width .3s var(--ease-out); }

/* =============================================================
   6. Before/after slider
   ============================================================= */
.slider-frame {
  position: relative; aspect-ratio: 4/3; max-height: 420px;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--hair);
  background: var(--bg); touch-action: pan-y;
}
.slider-frame.checker {
  background-image:
    linear-gradient(45deg, var(--hair) 25%, transparent 25%),
    linear-gradient(-45deg, var(--hair) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--hair) 75%),
    linear-gradient(-45deg, transparent 75%, var(--hair) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}
.slider-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.slider-before { z-index: 1; }
.slider-clip {
  position: absolute; inset: 0; z-index: 2; overflow: hidden;
  width: 50%; /* JS drives this */
}
.slider-clip .slider-after { position: absolute; inset: 0; width: var(--frame-w, 100%); height: 100%; object-fit: contain; }
.slider-handle {
  position: absolute; top: 0; bottom: 0; left: 50%; z-index: 3;
  width: 0; pointer-events: none;
  transform: translateX(-1px);
}
.slider-handle::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0;
  width: 2px; background: var(--surface); box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.slider-handle-grip {
  position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.slider-range {
  position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: ew-resize; appearance: none;
}

/* =============================================================
   7. Customize controls
   ============================================================= */
.customize { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.customize-group { display: flex; flex-direction: column; gap: 8px; }
.customize-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }

.bg-options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bg-swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--hair);
  background: var(--swatch, var(--surface)); position: relative; flex: none;
  display: flex; align-items: center; justify-content: center; color: var(--ink-soft);
  transition: transform .12s var(--ease-out), border-color .12s var(--ease-out);
}
.bg-swatch:hover { transform: scale(1.08); }
.bg-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.bg-swatch-transparent {
  background-image:
    linear-gradient(45deg, var(--hair) 25%, transparent 25%),
    linear-gradient(-45deg, var(--hair) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--hair) 75%),
    linear-gradient(-45deg, transparent 75%, var(--hair) 75%);
  background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}
.bg-swatch-custom { padding: 0; overflow: hidden; cursor: pointer; }
.bg-swatch-custom input[type="color"] {
  width: 44px; height: 44px; margin: -7px; border: 0; cursor: pointer; background: none;
}
.bg-swatch-blur { background: var(--bg); }

.preset-options, .shape-options, .format-choice {
  display: inline-flex; gap: 4px; padding: 4px; background: var(--bg);
  border: 1px solid var(--hair); border-radius: 999px; width: fit-content;
}
.preset-btn, .shape-btn, .format-btn {
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft); transition: background-color .12s var(--ease-out), color .12s var(--ease-out);
  white-space: nowrap;
}
.preset-btn.is-active, .shape-btn.is-active, .format-btn.is-active {
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.preset-hint { font-size: 12.5px; color: var(--ink-soft); min-height: 1.4em; }
.customize-group-shape[hidden] { display: none; }

/* =============================================================
   8. Done actions / buttons
   ============================================================= */
.done-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 15px;
  text-decoration: none; transition: transform .1s var(--ease-out), opacity .15s var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: .92; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--hair); }
.btn-ghost:hover { border-color: var(--ink-soft); }

/* error */
.panel-error { text-align: center; }
.error-msg { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 14px 16px; font-size: 14.5px; margin-bottom: 16px; }

/* =============================================================
   9. Ad slots
   ============================================================= */
.ad-slot {
  margin: 28px auto; max-width: 720px; min-height: 90px;
  border: 1px dashed var(--hair); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); background: color-mix(in srgb, var(--ink) 3%, var(--surface));
}
.ad-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .5; }
.ad-leaderboard { max-width: 728px; }
.ad-incontent { max-width: 336px; min-height: 280px; }
.ad-popup { min-height: 200px; margin: 16px auto; }

/* =============================================================
   10. How it works / SEO text / use cases / FAQ
   ============================================================= */
.how-it-works, .seo-text, .use-cases, .faq { padding: 36px 0; }
.how-it-works h2, .seo-text h2, .use-cases h2, .faq h2 { font-size: clamp(22px, 3.4vw, 28px); margin-bottom: 20px; text-align: center; }

.steps { list-style: none; padding: 0; display: grid; gap: 20px; }
.step { text-align: center; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-family: var(--display); font-weight: 800; font-size: 14px; margin-bottom: 10px;
}
.step h3 { font-size: 17px; margin-bottom: 6px; }
.step p { color: var(--ink-soft); font-size: 14.5px; max-width: 40ch; margin: 0 auto; }

.seo-text p { color: var(--ink-soft); margin-bottom: 14px; font-size: 15px; }
.seo-text p:last-child { margin-bottom: 0; }

.cases-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.case-card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 18px;
}
.case-card h3 { font-size: 15.5px; margin-bottom: 6px; }
.case-card p { font-size: 13.5px; color: var(--ink-soft); }

.faq details {
  border-bottom: 1px solid var(--hair); padding: 14px 0;
}
.faq summary {
  cursor: pointer; font-weight: 700; font-size: 15px; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; color: var(--ink-soft); flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq p { margin-top: 10px; color: var(--ink-soft); font-size: 14.5px; }

/* =============================================================
   11. Corner toast
   ============================================================= */
.corner-toast {
  position: fixed; bottom: 16px; right: 16px; z-index: 500;
  max-width: 260px; background: var(--surface); border: 1px solid var(--hair);
  border-radius: 12px; padding: 12px 34px 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  font-size: 12.5px; color: var(--ink-soft);
  animation: toast-in .3s var(--ease-out);
}
.corner-toast[hidden] { display: none; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.corner-toast-close {
  position: absolute; top: 6px; right: 8px; font-size: 16px; color: var(--ink-soft); line-height: 1;
}

/* =============================================================
   12. Download dialog (popup)
   ============================================================= */
.download-dialog {
  border: 0; border-radius: 16px; padding: 22px; max-width: 380px; width: calc(100% - 40px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25); position: relative;
}
.download-dialog::backdrop { background: rgba(0,0,0,.4); }
.download-dialog-title { font-family: var(--display); font-weight: 800; font-size: 17px; text-align: center; margin-bottom: 4px; }
.download-dialog-close {
  position: absolute; top: 10px; right: 12px; font-size: 20px; color: var(--ink-soft); line-height: 1;
}
.download-dialog-btn { width: 100%; margin-top: 6px; }

/* =============================================================
   13. Legal pages
   ============================================================= */
.legal-page { padding: 32px 0 60px; }
.legal-page h1 { font-size: 26px; margin-bottom: 18px; }
.legal-page h2 { font-size: 18px; margin: 24px 0 8px; }
.legal-page p { color: var(--ink-soft); font-size: 14.5px; margin-bottom: 6px; }

/* =============================================================
   14. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .cases-grid { grid-template-columns: 1fr 1fr; }
  .done-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
@media (min-width: 720px) {
  .steps { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 960px) {
  .cases-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   15. Reduced motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .corner-toast { animation: none; }
  html { scroll-behavior: auto; }
}
