/* ═══════════════════════════════════════════════════════════════
   Emberquill · Paper & Ink
   Display: Instrument Serif (headings only) · UI: Instrument Sans
   Literary-magazine restraint: cream paper, warm ink, hairline rules.
   No blue/cyan/purple. No gradients. No glow.
   Class names are unchanged so JS and markup keep working.
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  /* palette: DARK (default). Warm ink-on-night, never blue-black. */
  --bg:        #151311;
  --ink:       #F1EBDF;   /* headings, primary buttons */
  --body:      #BAB2A3;
  --muted:     #8A8376;
  --hairline:  #2C2823;
  --card:      #1E1B18;
  --rule:      #4A443B;
  --pill-bg:   #25221E;
  --pill-br:   #36312B;

  /* status colors: used ONLY for status */
  --ok:        #93B882;
  --warn:      #D8A55A;
  --err:       #E0796C;
  --ok-soft:   rgba(147, 184, 130, .12);
  --warn-soft: rgba(216, 165, 90, .13);
  --err-soft:  rgba(224, 121, 108, .12);

  /* theme helpers */
  --field:        #171513;
  --tint:         rgba(241, 235, 223, .06);
  --sel:          rgba(241, 235, 223, .18);
  --btn-hover:    #FBF7EE;
  --border-hover: #4A443B;
  --pill-text:    #BAB2A3;
  --nav-bg:       rgba(21, 19, 17, .72);
  --overlay-bg:   rgba(21, 19, 17, .96);
  --warm:         rgba(180, 140, 90, .07);
  --grain-blend:  screen;
  --grain-opacity: .03;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .34), 0 16px 40px rgba(0, 0, 0, .36);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .34), 0 16px 40px rgba(0, 0, 0, .40);
  --ring:      0 0 0 3px rgba(241, 235, 223, .12);

  /* aliases: older class rules and inline styles still reference these */
  --bg-2:         var(--pill-bg);
  --surface:      var(--card);
  --surface-2:    var(--bg);
  --surface-3:    var(--pill-bg);
  --ink-soft:     var(--body);
  --ink-faint:    var(--muted);
  --ember:        var(--ink);
  --ember-2:      var(--ink);
  --ember-soft:   var(--tint);
  --ember-line:   var(--rule);
  --good:         var(--ok);
  --good-soft:    var(--ok-soft);
  --bad:          var(--err);
  --bad-soft:     var(--err-soft);
  --moss:         var(--ok);
  --moss-wash:    var(--ok-soft);
  --amber:        var(--warn);
  --amber-wash:   var(--warn-soft);
  --paper:        var(--bg);
  --paper-deep:   var(--pill-bg);
  --line:         var(--hairline);
  --line-strong:  var(--pill-br);

  --font-display: "Instrument Serif", Georgia, serif;
  --font-body:    "Instrument Sans", "Segoe UI", system-ui, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 18px;

  --ease: ease;
}

/* LIGHT: warm cream paper */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #F7F3EC;
  --ink:       #1A1815;
  --body:      #4A453D;
  --muted:     #8A8275;
  --hairline:  #E8E1D5;
  --card:      #FFFFFF;
  --rule:      #C9C0AE;
  --pill-bg:   #EFE9DD;
  --pill-br:   #E0D8C7;

  --ok:        #4A6B3E;
  --warn:      #A8762A;
  --err:       #A03A2E;
  --ok-soft:   color-mix(in srgb, var(--ok) 10%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 12%, transparent);
  --err-soft:  color-mix(in srgb, var(--err) 9%, transparent);

  --field:        #FFFFFF;
  --tint:         rgba(26, 24, 21, .05);
  --sel:          rgba(26, 24, 21, .12);
  --btn-hover:    #26221C;
  --border-hover: #D6CDBA;
  --pill-text:    #57514A;
  --nav-bg:       rgba(247, 243, 236, .72);
  --overlay-bg:   rgba(247, 243, 236, .96);
  --warm:         rgba(180, 140, 90, .08);
  --grain-blend:  multiply;
  --grain-opacity: .035;
  --shadow-sm: 0 1px 2px rgba(30, 25, 15, .04), 0 8px 24px rgba(30, 25, 15, .05);
  --shadow-md: 0 2px 4px rgba(30, 25, 15, .06), 0 16px 40px rgba(30, 25, 15, .08);
  --shadow-lg: 0 2px 4px rgba(30, 25, 15, .06), 0 16px 40px rgba(30, 25, 15, .10);
  --ring:      0 0 0 3px rgba(26, 24, 21, .08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule) transparent; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
}

/* page texture 1: fine film grain over everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 120;
  pointer-events: none; opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* page texture 2: warm shadow in the top-right corner */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle at top right, var(--warm), transparent 55%);
}

::selection { background: var(--sel); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border: 2px solid var(--bg); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Type ──────────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display); font-weight: 400; line-height: 1.1;
  letter-spacing: -.015em; color: var(--ink); text-wrap: balance;
}
h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
h3 { font-size: 1.35rem; }

p { text-wrap: pretty; }

a { color: var(--ink); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 640px) { .wrap { padding: 0 18px; } .narrow { padding: 0 16px; } }

/* eyebrow labels */
.kicker {
  display: inline-flex; align-items: center;
  font-family: var(--font-body); font-size: 11px; font-weight: 500; line-height: 1.4;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.kicker::before { content: ""; display: inline-block; width: 20px; height: 1px; background: var(--rule); vertical-align: middle; margin-right: 10px; }
.kicker[style*="justify-content:center"]::before { display: none; }

.muted { color: var(--body); }
.faint { color: var(--muted); }
.serif-i { font-family: var(--font-display); font-style: italic; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 14px; font-weight: 500; line-height: 1; letter-spacing: .01em;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease,
    border-color .15s ease, color .15s ease;
  text-decoration: none; user-select: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  color: var(--bg); background: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 1px 2px rgba(26, 24, 21, .16);
}
.btn-primary:hover:not(:disabled) {
  color: var(--bg); background: var(--btn-hover); transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 4px 12px rgba(26, 24, 21, .18);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost { background: transparent; color: var(--body); border-color: var(--hairline); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--border-hover); }

.btn-quiet { background: transparent; color: var(--body); }
.btn-quiet:hover:not(:disabled) { background: var(--tint); color: var(--ink); }

.btn-danger { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 28%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--err) 14%, transparent); }

.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: 8px; }

/* ── Cards & surfaces ──────────────────────────────────────────── */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
/* big working surfaces stay put on hover */
.panel:hover, .auth-card:hover, .demo-card:hover, .mock:hover, .history-panel:hover { transform: none; }

/* ── Nav ───────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--hairline);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; max-width: 1120px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-body); font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-family: var(--font-display); font-size: 15px; line-height: 1;
}
.nav-links { display: flex; align-items: center; gap: 8px; }

/* ── Forms ─────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--body); margin-bottom: 7px; }
.input, .textarea, select.input {
  width: 100%; font-family: var(--font-body); font-size: 15px; color: var(--ink);
  background: var(--field); border: 1px solid var(--pill-br); border-radius: 8px;
  padding: 12px 14px; transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .textarea:hover { border-color: var(--border-hover); }
.input:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 230px; line-height: 1.7; }

select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%231A1815' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center;
}
select.input option { background: var(--card); color: var(--ink); }

.form-error {
  display: none; margin-top: 14px; padding: 11px 15px; font-size: .875rem;
  background: var(--err-soft); color: var(--err);
  border: 1px solid color-mix(in srgb, var(--err) 28%, transparent); border-radius: 8px;
}
.form-error.show { display: block; animation: toast-in .25s ease; }

/* ── Badges & pills ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  padding: 4px 10px; border-radius: 999px;
  background: var(--pill-bg); color: var(--pill-text); border: 1px solid var(--pill-br);
}
.badge.ember { background: var(--pill-bg); color: var(--ink); border-color: var(--pill-br); }
.badge.moss, .badge.good { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.bad { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 28%, transparent); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Landing hero ──────────────────────────────────────────────── */
.hero { padding: 92px 24px 72px; display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
@media (max-width: 980px) { .hero { grid-template-columns: 1fr; padding: 64px 18px 48px; gap: 40px; } }
.hero h1 { margin: 20px 0 22px; }
.hero h1 em { font-style: italic; color: var(--ink); }
.hero p.lede { font-size: 1.125rem; color: var(--body); max-width: 540px; margin-bottom: 34px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.hero-note { font-size: 13px; color: var(--muted); }

/* demo card on the hero */
.demo-card { padding: 0; overflow: hidden; }
.demo-head { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--hairline); }
.demo-head .dots { display: flex; gap: 6px; }
.demo-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--pill-br); }
.demo-head .dots i:first-child { background: var(--ink); }
.demo-head .lbl { margin-left: auto; font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.demo-body { padding: 22px 24px 8px; min-height: 168px; }
.demo-line { font-size: 15px; line-height: 1.75; color: var(--body); }
.demo-line .hl { background: var(--pill-bg); border-bottom: 1px solid var(--rule); color: var(--ink); padding: 0 2px; border-radius: 3px; }
.demo-foot { display: flex; align-items: center; gap: 18px; padding: 16px 24px 22px; border-top: 1px solid var(--hairline); }
.demo-score b { font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.demo-score span { display: block; font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.demo-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--pill-bg); overflow: hidden; }
.demo-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--ok); transition: width 1.4s ease; }

/* ── Sections ──────────────────────────────────────────────────── */
.section { padding: 84px 24px; }
@media (max-width: 640px) { .section { padding: 64px 18px; } }
.section-head { max-width: 620px; margin-bottom: 52px; }
.section-head h2 { margin: 16px 0 14px; }
.section-head p { color: var(--body); font-size: 1.125rem; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.section-head.center .kicker::before { display: none; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }
@media (min-width: 901px) {
  .steps .step:nth-child(2) { margin-top: 16px; }
  .steps .step:nth-child(3) { margin-top: 32px; }
}
.step { padding: 28px; }
.step-num {
  font-family: var(--font-display); font-style: italic; font-size: 1.5rem; line-height: 1;
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: var(--pill-bg); color: var(--ink); margin-bottom: 18px;
  border: 1px solid var(--pill-br);
}
.step h3 { margin-bottom: 8px; }
.step p { font-size: 15px; color: var(--body); }

/* feature split with mock UI */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; gap: 36px; } }
.split .copy h2 { margin: 16px 0 16px; }
.split .copy p { color: var(--body); margin-bottom: 14px; }
.feat-list { list-style: none; margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.feat-list li { display: flex; gap: 14px; align-items: flex-start; font-size: 15px; color: var(--body); }
.feat-list li svg { flex: none; margin-top: 2px; }
.feat-list li b { color: var(--ink); font-weight: 500; display: block; }

.mock { padding: 28px; }
.mock-toolbar { display: flex; gap: 6px; margin-bottom: 16px; }
.mock-toolbar i { height: 26px; border-radius: 7px; background: var(--pill-bg); flex: 1; }
.mock-toolbar i.on { background: var(--pill-br); border: 1px solid var(--rule); }
.mock-lines { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
.mock-lines i { height: 10px; border-radius: 5px; background: var(--pill-bg); }
.mock-lines i:nth-child(1) { width: 92%; } .mock-lines i:nth-child(2) { width: 100%; }
.mock-lines i:nth-child(3) { width: 78%; } .mock-lines i:nth-child(4) { width: 96%; }
.mock-lines i:nth-child(5) { width: 64%; background: var(--pill-br); }
.mock-meter { display: flex; align-items: center; gap: 12px; }
.mock-meter .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--pill-bg); overflow: hidden; }
.mock-meter .bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

/* ── FAQ ───────────────────────────────────────────────────────── */
.faq { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.faq details { border: 1px solid var(--hairline); border-radius: 14px; background: var(--card); overflow: hidden; transition: border-color .15s ease; }
.faq details[open] { border-color: var(--pill-br); }
.faq summary {
  list-style: none; cursor: pointer; padding: 18px 24px; font-weight: 500; font-size: 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary .ic { flex: none; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--pill-bg); color: var(--body); transition: transform .15s ease, background .15s ease; font-weight: 400; }
.faq details[open] summary .ic { transform: rotate(45deg); background: var(--ink); color: var(--bg); }
.faq .faq-body { padding: 0 24px 20px; color: var(--body); font-size: 15px; }

/* ── Auth pages ────────────────────────────────────────────────── */
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100vh - 64px); min-height: calc(100dvh - 64px); }
@media (max-width: 920px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }
.auth-side {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--pill-bg);
  border-right: 1px solid var(--hairline);
}
.auth-side h2 { font-size: clamp(1.9rem, 3vw, 2.7rem); max-width: 420px; }
.auth-side h2 em { font-style: italic; color: var(--ink); }
.auth-quote { border-left: 1px solid var(--rule); padding-left: 18px; max-width: 380px; }
.auth-quote p { font-family: var(--font-display); font-style: italic; font-size: 1.25rem; color: var(--body); }
.auth-quote span { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.auth-main { display: grid; place-items: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 430px; padding: 36px; }
.auth-card h1 { font-size: 2rem; margin-bottom: 8px; }
.auth-sub { color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.auth-switch { text-align: center; margin-top: 24px; font-size: 14px; color: var(--muted); }

.or-divider { display: flex; align-items: center; gap: 14px; margin: 24px 0; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

.btn-google { background: var(--card); color: var(--ink); border-color: var(--pill-br); }
.btn-google:hover:not(:disabled) { background: var(--bg); border-color: var(--border-hover); }
.btn-google svg { flex: none; filter: grayscale(1); }

/* ── Dashboard layout ──────────────────────────────────────────── */
.dash { padding: 34px 24px 90px; }
@media (max-width: 640px) { .dash { padding: 28px 18px 80px; } }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.dash-head h1 { font-size: 2rem; }
.dash-head p { color: var(--muted); font-size: 15px; margin-top: 5px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  display: flex; flex-direction: column; gap: 3px; min-width: 108px;
  padding: 12px 18px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--hairline);
}
.stat b { font-family: var(--font-display); font-size: 24px; font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 940px) { .dash-grid { grid-template-columns: 1fr; } }

.panel { padding: 28px; }
@media (max-width: 640px) { .panel, .step, .auth-card, .card { padding: 20px; } .demo-card { padding: 0; } }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-title h3 { font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.panel-title .tools { display: flex; gap: 8px; align-items: center; }
.word-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.word-count.over { color: var(--err); }

/* ── Controls: levels, models, sliders ─────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 16px; margin: 18px 0 6px; }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--pill-bg); border: 1px solid var(--pill-br); border-radius: 12px; }
.levels button {
  font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--body);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 4px; cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.levels button:hover:not(.active) { color: var(--ink); background: var(--tint); }
.levels button.active { background: var(--ink); color: var(--bg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.level-hint { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 1.2em; }

.ctl-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ctl-row .grow { flex: 1; min-width: 180px; }
.ctl-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--body); margin-bottom: 8px; letter-spacing: .02em; }
.ctl-label output { color: var(--ink); font-variant-numeric: tabular-nums; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--pill-bg); outline: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(30, 25, 15, .18); transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.02); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--card); border: 2px solid var(--ink); }
input[type="range"]:focus-visible { outline: none; box-shadow: var(--ring); }

.editor-drop { position: relative; }
.editor-drop.drag::after {
  content: "Drop your file to load it";
  position: absolute; inset: 6px; z-index: 5; display: grid; place-items: center;
  border: 1px solid var(--ink); border-radius: 12px;
  background: var(--overlay-bg); color: var(--ink);
  font-size: 14px; font-weight: 500; pointer-events: none;
}

.editor-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.editor-tools .spacer { flex: 1; }

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 18px; }
.tab {
  font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--muted);
  background: none; border: none; cursor: pointer; padding: 10px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--body); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .cnt { font-size: 11px; background: var(--pill-bg); border-radius: 99px; padding: 1px 7px; color: var(--muted); }

/* ── Output ────────────────────────────────────────────────────── */
.output-empty {
  display: grid; place-items: center; min-height: 280px; text-align: center;
  color: var(--muted); font-size: 15px; line-height: 1.8;
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 24px;
}
.output-empty svg { margin-bottom: 12px; opacity: .7; }
.output-text { line-height: 1.85; font-size: 1rem; color: var(--ink); }

.seg { cursor: pointer; border-radius: 5px; padding: 1px 3px; margin: 0 -3px; transition: background .15s ease, box-shadow .15s ease; }
.seg:hover { background: var(--tint); box-shadow: 0 0 0 1px var(--rule); }
.seg.swapped { background: var(--ok-soft); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 32%, transparent); }
.seg.swapped:hover { background: color-mix(in srgb, var(--ok) 16%, transparent); }

.seg-pop {
  position: absolute; z-index: 80; width: min(440px, calc(100vw - 40px));
  background: var(--card); border: 1px solid var(--pill-br); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 10px; display: none;
}
.seg-pop.open { display: block; animation: pop-in .15s ease; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.seg-pop h4 { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 6px 8px 10px; font-family: var(--font-body); }
.seg-opt {
  display: block; width: 100%; text-align: left; font-family: var(--font-body); font-size: 14.5px;
  line-height: 1.55; padding: 10px 12px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--body);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.seg-opt:hover { background: var(--bg); color: var(--ink); }
.seg-opt.active { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); color: var(--ink); }
.seg-opt small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.seg-opt.active small { color: var(--ok); }

/* ── Rewrite progress stages ───────────────────────────────────── */
.prog { display: flex; flex-direction: column; gap: 13px; padding: 26px 8px; }
.prog li { list-style: none; display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--muted); transition: color .3s ease; }
.prog li .pd { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--pill-br); display: grid; place-items: center; flex: none; transition: all .3s ease; font-size: 11px; color: transparent; }
.prog li.doing { color: var(--ink); }
.prog li.doing .pd { border-color: var(--ink); animation: pulse-ring 1.2s ease-in-out infinite; }
.prog li.done { color: var(--body); }
.prog li.done .pd { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
@keyframes pulse-ring { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Detection report ──────────────────────────────────────────── */
.report { display: flex; flex-direction: column; gap: 22px; }
.report-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.report-big { display: flex; align-items: baseline; gap: 12px; }
.report-big b { font-family: var(--font-display); font-weight: 400; font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.report-big.good b { color: var(--ok); } .report-big.warnb b { color: var(--warn); } .report-big.badb b { color: var(--err); }
.report-big .verdict { font-size: 15px; color: var(--body); max-width: 260px; line-height: 1.45; }

.meters { display: flex; flex-direction: column; gap: 14px; }
.meter-row { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 14px; }
.meter-row .mlabel { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--pill-bg); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--ok); transition: width 1.1s ease; }
.meter-row .mnum { font-family: var(--font-display); font-size: 24px; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.meter-row.before .meter i { background: var(--err); }
.meter-row.before .mnum { color: var(--err); }
.meter-row.after .meter i { background: var(--ok); }
.meter-row.after .mnum { color: var(--ok); }
.delta-chip { align-self: center; }

.heat-wrap { border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 16px; background: var(--bg); }
.heat-wrap .hw-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.heat-wrap .hw-head h4 { font-family: var(--font-body); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.heat-wrap .hw-head span { font-size: 12px; color: var(--muted); }
.heat { display: flex; gap: 2px; align-items: stretch; min-height: 30px; }
.heat i { flex: 1 1 0; min-width: 3px; border-radius: 2px; transition: opacity .15s ease; cursor: default; }
.heat i:hover { opacity: .7; }
.heat-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.heat-legend { display: flex; align-items: center; gap: 6px; }
.heat-legend .g { width: 54px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ok) 0 33.3%, var(--warn) 33.3% 66.6%, var(--err) 66.6% 100%); }

.trend-wrap { border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 16px 8px; background: var(--bg); }
.trend-wrap .hw-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.trend-wrap h4 { font-family: var(--font-body); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.trend-wrap .hw-head span { font-size: 12px; color: var(--muted); }
.trend-empty { font-size: 14px; color: var(--muted); padding: 18px 4px; }
.trend svg { display: block; width: 100%; height: 110px; }
.trend .area { fill: var(--pill-bg); opacity: .8; }
.trend .line { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.trend .pt { fill: var(--card); stroke: var(--ink); stroke-width: 1.75; }
.trend .pt.hi { stroke: var(--err); }

.report-note { font-size: 13px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--hairline); padding-top: 14px; }

/* ── Score gauge (legacy hook) ─────────────────────────────────── */
.score-row { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.gauge { position: relative; width: 92px; height: 92px; flex: none; }
.gauge svg { transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 6; }
.gauge .track { stroke: var(--pill-bg); }
.gauge .fill { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset .9s ease, stroke .4s ease; }
.gauge b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 400; color: var(--ink); font-size: 24px; font-variant-numeric: tabular-nums; }
.score-copy { font-size: 14px; color: var(--body); }
.score-copy strong { display: block; font-size: 16px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }

.output-stamp { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--muted); }

/* ── History ───────────────────────────────────────────────────── */
.history-panel { margin-top: 22px; }
.history-empty { font-size: 14.5px; color: var(--muted); padding: 8px 2px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; width: 100%; text-align: left; cursor: pointer;
  font-family: var(--font-body); color: var(--ink);
  padding: 14px 16px; border-radius: 12px;
  background: transparent; border: 1px solid var(--hairline);
  transition: border-color .15s ease, background .15s ease;
}
.history-item:hover { background: var(--bg); border-color: var(--pill-br); }
.history-item:focus-visible { outline: none; box-shadow: var(--ring); }
.history-item.active { border-color: var(--ink); background: var(--bg); }
.history-item .badge { padding: 3px 10px; }

.hist-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist-words, .hist-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-score { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; padding: 3px 10px; border-radius: 99px; }
.hist-score.good { color: var(--ok); background: var(--ok-soft); }
.hist-score.warn { color: var(--warn); background: var(--warn-soft); }
.hist-score.bad { color: var(--err); background: var(--err-soft); }

.hist-preview {
  grid-column: 1 / -1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 14.5px; line-height: 1.6; color: var(--body);
}

/* ── Spinner / skeletons ───────────────────────────────────────── */
.spinner { width: 17px; height: 17px; flex: none; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 24%, transparent); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.shimmer { position: relative; overflow: hidden; background: var(--pill-bg); border-radius: 6px; animation: soft-pulse 1.4s ease-in-out infinite; }
@keyframes soft-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Toasts ────────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 130; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 250px; max-width: 380px; padding: 13px 18px; font-size: 14.5px; color: var(--ink);
  background: var(--card); border: 1px solid var(--pill-br); border-left: 3px solid var(--muted);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease; display: flex; gap: 10px; align-items: flex-start;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.info { border-left-color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Footer ────────────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--hairline); padding: 46px 0 42px; margin-top: 40px; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
@media (max-width: 820px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
.foot h5 { font-family: var(--font-body); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.foot ul { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.foot ul a { color: var(--body); font-size: 15px; }
.foot ul a:hover { color: var(--ink); }
.foot-brand p { color: var(--muted); font-size: 14px; max-width: 300px; margin-top: 12px; }
.foot-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 38px; padding-top: 22px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: 13px; }

/* ── Pricing ───────────────────────────────────────────────────── */
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; align-items: stretch; }
@media (max-width: 900px) { .pricing-grid { grid-template-columns: 1fr; max-width: 430px; margin: 0 auto; } }

.plan-card { position: relative; padding: 32px 28px; display: flex; flex-direction: column; }
.plan-card h3 { font-size: 1.6rem; margin-bottom: 6px; }
.plan-card .plan-tag { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.plan-card.featured { border-color: var(--ink); }
.plan-price { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; color: var(--ink); margin-bottom: 24px; }
.plan-price small { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.plan-features { list-style: none; margin: 0 0 28px; flex: 1; display: flex; flex-direction: column; }
.plan-features li { position: relative; padding: 10px 0 10px 30px; font-size: 15px; color: var(--body); border-bottom: 1px solid var(--hairline); }
.plan-features li:last-child { border-bottom: none; }
.plan-features li::before {
  content: ""; position: absolute; left: 0; top: 13px; width: 16px; height: 16px; border-radius: 3px;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4.2 8.3l2.5 2.5 5-5.2' stroke='%23F7F3EC' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
  border: 1px solid var(--ink);
}
.plan-features li b { color: var(--ink); font-weight: 500; }

/* ── Utility ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* scroll reveal: classes are added by common.js, nothing hides without JS */
.fx-pre { opacity: 0; transform: translateY(12px); }
.fx-pre.fx-in { opacity: 1; transform: none; transition: opacity .5s ease-out, transform .5s ease-out; transition-delay: var(--fx-delay, 0ms); }

.divider { height: 1px; background: var(--hairline); border: none; margin: 22px 0; }
hr { border: none; border-top: 1px solid var(--hairline); }

/* ── Landing helpers ───────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 980px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid-4 { grid-template-columns: 1fr; } }
.level-card { padding: 28px 24px; display: flex; flex-direction: column; gap: 10px; }
.level-card .lv-tag { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.level-card p { font-size: 14.5px; color: var(--body); flex: 1; }
.level-card .lv-meta { font-size: 13px; color: var(--muted); border-top: 1px solid var(--hairline); padding-top: 12px; }
.cta-band { position: relative; overflow: hidden; text-align: center; padding: 78px 28px; }
.cta-band h2 { margin: 14px auto 16px; max-width: 560px; }
.cta-band p { color: var(--body); max-width: 460px; margin: 0 auto 30px; }

/* ── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}


/* ═══════════════════════════════════════════════════════════════
   Theme extras: icons that cannot use CSS variables directly
   ═══════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23F1EBDF' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
:root:not([data-theme="light"]) .plan-features li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4.2 8.3l2.5 2.5 5-5.2' stroke='%23151311' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* inline SVG icons in the markup carry light-theme hex colors; map them to tokens */
svg [stroke="#1A1815"] { stroke: var(--ink); }
svg [fill="#1A1815"]   { fill: var(--ink); }
svg [stroke="#4A6B3E"] { stroke: var(--ok); }
svg [fill="#4A6B3E"]   { fill: var(--ok); }
svg [stroke="#A8762A"] { stroke: var(--warn); }
svg [fill="#A8762A"]   { fill: var(--warn); }

/* ── Theme toggle (injected into the nav by common.js) ─────────── */
.nav-inner { gap: 8px; }
.nav-links { margin-left: auto; }
.theme-toggle { flex: none; color: var(--body); }
.theme-toggle svg { display: block; width: 18px; height: 18px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }

/* ═══════════════════════════════════════════════════════════════
   Dashboard: equal, fixed-height boxes
   ═══════════════════════════════════════════════════════════════ */
.dash-grid { align-items: stretch; }
.dash-grid > .panel { height: 700px; display: flex; flex-direction: column; min-height: 0; }
.dash-grid > .panel > * { flex: none; }
@media (max-width: 940px) { .dash-grid > .panel { height: 640px; } }

/* input box: the textarea absorbs the spare height and scrolls inside itself */
.dash-grid .editor-drop { flex: 1 1 auto; min-height: 0; display: flex; }
.dash-grid .editor-drop .textarea { flex: 1; width: 100%; height: 100%; min-height: 0; resize: none; overflow-y: auto; }

/* result box: panes fill the box, content scrolls inside */
#paneRewrite, #paneDetect { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#paneDetect { overflow-y: auto; padding-right: 4px; }
.rewrite-row { flex: 1 1 auto; min-height: 0; display: flex; gap: 22px; }
.rewrite-row .output-empty { flex: 1; min-height: 0; }
.rewrite-row .output-text { flex: 1; min-width: 0; overflow-y: auto; padding-right: 8px; }

/* ── AI score donut beside the rewritten text ──────────────────── */
.donut-card {
  flex: none; width: 164px; padding-left: 22px; border-left: 1px solid var(--hairline);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  overflow-y: auto;
}
.donut { position: relative; width: 132px; height: 132px; margin-top: 4px; }
.donut svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 9; }
.donut .d-track { stroke: var(--pill-bg); }
.donut .d-fill { stroke: var(--ok); stroke-linecap: round; transition: stroke-dasharray 1.1s ease, stroke .3s ease; }
.donut.warnb .d-fill { stroke: var(--warn); }
.donut.badb .d-fill { stroke: var(--err); }
.donut .d-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut .d-center b { font-family: var(--font-display); font-weight: 400; font-size: 38px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.donut .d-center span { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.d-label { font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.d-verdict { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.2; color: var(--ink); }
.d-compare { width: 100%; display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.d-compare span { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.d-compare b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .rewrite-row { flex-direction: column; gap: 14px; }
  .donut-card { order: -1; width: 100%; flex-direction: row; flex-wrap: wrap; justify-content: center; border-left: none; padding-left: 0; border-bottom: 1px solid var(--hairline); padding-bottom: 14px; max-height: 200px; }
  .donut { width: 96px; height: 96px; margin-top: 0; }
  .donut .d-center b { font-size: 28px; }
  .d-compare { width: auto; border-top: none; padding-top: 0; justify-content: center; }
}
