/* ═══════════════════════════════════════════════════════════════════════
   EZ Essay — design system v2
   AKA IND design language: Eames warmth (ivory ground, pills, primary
   dots) + brutalist structure (2px ink rules, exposed grid, mono spec
   labels) + one deliberate break per layout (the off-grid specimen sheet).
   No gradient washes, no emoji, no glow. Light + dark via tokens.
   ═══════════════════════════════════════════════════════════════════════ */

@view-transition { navigation: auto; }

:root {
  color-scheme: light dark;

  --ground: #F3EEE4;
  --card: #FBF8F2;
  --paper: #FFFDF9;
  --rule: #CFC6B6;
  --rule-soft: #E4DCCD;
  --ink: #1C1A17;
  --muted: #5B5348;
  --faint: #857B6C;
  --void: #121212;

  --walnut: #6B4428;
  --ochre: #E3A72F;
  --blue: #2D5B8A;
  --red: #C8432B;
  --olive: #5E6B3A;

  --on-ink: #F3EEE4;
  --tint-blue: #DCE5EE;
  --tint-ochre: #F5E3B8;
  --tint-red: #F3D8D1;
  --tint-olive: #E1E4D3;

  --f-display: 'IBM Plex Sans', sans-serif;
  --f-body: 'IBM Plex Sans', sans-serif;
  --f-mono: 'IBM Plex Mono', monospace;
  --f-serif: 'IBM Plex Serif', serif;

  --bw: 2px;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --pill: 999px;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121212;
    --card: #1A1917;
    --paper: #201E1B;
    --rule: #3D3933;
    --rule-soft: #2B2825;
    --ink: #F3EEE4;
    --muted: #BDB3A3;
    --faint: #91887A;
    --on-ink: #121212;
    --blue: #8FB3DA;
    --red: #E7826D;
    --olive: #A9B87F;
    --tint-blue: #1E2A36;
    --tint-ochre: #3A2F17;
    --tint-red: #3A211B;
    --tint-olive: #262A1C;
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--ground);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.08; letter-spacing: -0.015em; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--ochre); }
::selection { background: var(--ochre); color: #1C1A17; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 300;
  background: var(--ink); color: var(--on-ink);
  padding: 10px 16px; border-radius: var(--pill); text-decoration: none;
}
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }

/* Mono spec label — the system's voice for structure */
.spec {
  font-family: var(--f-mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.dot { display: inline-block; width: .62em; height: .62em; border-radius: 50%; background: var(--ochre); vertical-align: .05em; }
.dot--blue { background: var(--blue); }
.dot--red { background: var(--red); }
.dot--olive { background: var(--olive); }

/* ── Masthead ─────────────────────────────────────────────────────────── */
.masthead {
  position: sticky; top: 0; z-index: 100;
  background: var(--ground);
  border-bottom: var(--bw) solid var(--ink);
  view-transition-name: masthead;
}
.masthead__inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: var(--ink); color: var(--on-ink);
  border-radius: 9px;
  font-size: .82rem; font-weight: 700; letter-spacing: .02em;
}
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--pill);
  font-weight: 500;
  font-size: .92rem;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--ink); background: var(--rule-soft); }
.nav a[aria-current="page"] { color: var(--on-ink); background: var(--ink); }
.masthead__spec { display: none; }
@media (min-width: 900px) { .masthead__spec { display: block; } }
@media (max-width: 520px) {
  .brand__name { display: none; }
  .nav a { padding: 8px 11px; font-size: .88rem; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px;
  padding: 0 22px;
  border: var(--bw) solid var(--btn-bd);
  border-radius: var(--pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s, transform .15s var(--ease), border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--ink { --btn-bg: var(--ink); --btn-fg: var(--on-ink); }
.btn--ink:hover { --btn-bg: var(--blue); --btn-bd: var(--blue); --btn-fg: #fff; }
.btn--ghost:hover { --btn-bg: var(--ink); --btn-fg: var(--on-ink); }
.btn--quiet { --btn-bd: var(--rule); }
.btn--quiet:hover { --btn-bd: var(--ink); }
.btn--danger { --btn-fg: var(--red); --btn-bd: color-mix(in srgb, var(--red) 55%, transparent); }
.btn--danger:hover { --btn-bg: var(--red); --btn-fg: #fff; --btn-bd: var(--red); }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.btn--lg { min-height: 54px; padding: 0 28px; font-size: 1rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn .kbd { font-family: var(--f-mono); font-size: .7rem; opacity: .65; font-weight: 500; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ── Form controls ───────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .86rem; }
.field > label.spec { font-size: .72rem; font-weight: 500; }
.field__hint { font-size: .8rem; color: var(--faint); }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--paper);
  border: var(--bw) solid var(--rule);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ochre) 55%, transparent); }
.textarea { resize: vertical; line-height: 1.55; field-sizing: content; min-height: 110px; }
.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23857B6C' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
.input--hero { font-size: 1.1rem; min-height: 56px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.req { color: var(--red); }

/* Segmented choice — radio pills */
.seg { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  padding: 8px 16px; border-radius: var(--pill);
  border: var(--bw) solid var(--rule); cursor: pointer;
  font-weight: 500; font-size: .9rem; background: var(--paper);
  transition: border-color .15s, background .15s, color .15s;
}
.seg label:hover { border-color: var(--ink); }
.seg input:checked + label { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.seg input:focus-visible + label { outline: 3px solid var(--ochre); outline-offset: 2px; }

/* ── Panels ───────────────────────────────────────────────────────────── */
.panel {
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg);
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px;
  border-bottom: var(--bw) solid var(--ink);
}

/* ── Page heads ───────────────────────────────────────────────────────── */
.pagehead { padding: clamp(32px, 6vw, 56px) 0 clamp(20px, 3vw, 28px); display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: end; justify-content: space-between; }
.pagehead h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-top: 10px; }
.pagehead p { color: var(--muted); max-width: 56ch; margin-top: 10px; }

/* ═══════════════════════════════════════════════════════════════════════
   HOME
   ═══════════════════════════════════════════════════════════════════════ */
.hero { position: relative; border-bottom: var(--bw) solid var(--ink); overflow: clip; }
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
  padding: clamp(40px, 8vw, 96px) 0 clamp(48px, 8vw, 104px);
}
@media (min-width: 960px) {
  .hero__grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: center; }
}
.hero h1 {
  font-size: clamp(2.7rem, 7.4vw, 5.6rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: .95;
  margin: 18px 0 24px;
}
.hero h1 em { font-style: italic; font-weight: 400; letter-spacing: -0.02em; }
.hero__lede { font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--muted); max-width: 40ch; }
.hero__ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero__facts {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin-top: 36px; padding-top: 18px;
  border-top: 1px dashed var(--rule);
  list-style: none; padding-left: 0;
}
.hero__facts li { display: flex; align-items: center; gap: 8px; }

/* Specimen sheet — the deliberate break: tilted, overhanging the hero rule */
.specimen { position: relative; justify-self: center; width: min(100%, 420px); }
@media (min-width: 960px) { .specimen { margin-bottom: -150px; } }
@media (max-width: 959px) { .specimen { display: none; } }
.sheet {
  position: relative;
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: 6px;
  padding: 40px 38px 46px;
  font-family: var(--f-serif);
  color: var(--ink);
}
.sheet__title { font-family: var(--f-serif); font-weight: 600; font-size: 1.2rem; line-height: 1.25; text-align: center; letter-spacing: 0; }
.sheet__meta { text-align: center; font-size: .78rem; color: var(--faint); margin: 8px 0 22px; font-family: var(--f-mono); letter-spacing: .06em; }
.sheet__h { font-family: var(--f-mono); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.sheet p { font-size: .82rem; line-height: 1.7; color: var(--muted); }
.sheet mark { background: var(--tint-ochre); color: var(--ink); padding: 0 2px; border-radius: 2px; }
.sheet sup { color: var(--blue); font-family: var(--f-mono); font-weight: 600; }
.sheet__refs { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: .72rem; color: var(--muted); line-height: 1.6; }
.sheet__refs span { display: block; padding-left: 1.6em; text-indent: -1.6em; }
.annot {
  position: absolute; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.annot::after { content: ""; width: 28px; height: 0; border-top: 1px solid var(--ink); }
.annot--1 { top: 64px; right: calc(100% + 6px); }
.annot--2 { top: 46%; right: calc(100% + 6px); }
.annot--3 { bottom: 34px; right: calc(100% + 6px); }
@media (max-width: 1240px) { .annot { display: none; } }

/* Process rail (timeline) */
.rail { border-bottom: var(--bw) solid var(--ink); background: var(--card); }
.rail__track {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.timeline-step {
  position: relative;
  padding: 18px 16px 18px 0;
  display: flex; align-items: center; gap: 12px;
  color: var(--faint);
}
.timeline-step + .timeline-step { padding-left: 16px; border-left: 1px solid var(--rule); }
.tl-circle {
  flex: none;
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: var(--bw) solid currentColor;
  font-family: var(--f-mono); font-size: .78rem; font-weight: 600;
  transition: background .25s var(--ease), color .25s, border-color .25s;
}
.tl-label { font-family: var(--f-mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 500; }
.timeline-step.active { color: var(--ink); }
.timeline-step.active .tl-circle { background: var(--ochre); border-color: var(--ink); color: #1C1A17; }
.timeline-step.completed { color: var(--olive); }
.timeline-step.completed .tl-circle { background: var(--olive); border-color: var(--olive); color: var(--ground); }
@media (max-width: 640px) {
  .tl-label { font-size: .62rem; letter-spacing: .06em; }
  .timeline-step { flex-direction: column; align-items: flex-start; gap: 6px; padding-block: 14px; }
  .tl-circle { width: 26px; height: 26px; font-size: .7rem; }
}

/* Exposed-grid feature sheet */
.section { padding: clamp(56px, 9vw, 112px) 0; }
.section__head { display: grid; gap: 14px; margin-bottom: 36px; max-width: 760px; }
.section__head h2 { font-size: clamp(1.9rem, 4.2vw, 3rem); }
.section__head p { color: var(--muted); font-size: 1.05rem; max-width: 56ch; }

.grid-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--card);
}
.cell {
  padding: 28px 26px 30px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 0 -1px -1px 0;
  display: grid; gap: 10px; align-content: start;
}
.cell h3 { font-size: 1.3rem; }
.cell p { color: var(--muted); font-size: .95rem; }
.cell__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  font-family: var(--f-mono); font-size: .7rem; letter-spacing: .05em;
  padding: 3px 9px; border-radius: var(--pill);
  border: 1px solid var(--rule); color: var(--muted);
  background: var(--paper);
}

/* ── Generator ───────────────────────────────────────────────────────── */
.gen {
  display: grid; gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  position: relative;
}
@media (min-width: 1040px) { .gen { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; } }
.gen__form { padding: 24px; display: grid; gap: 22px; }
@media (min-width: 1040px) { .gen__form { position: sticky; top: 88px; } }
.gen__group { display: grid; gap: 14px; border: 0; padding: 0; min-width: 0; }
.gen__group legend { padding: 0; margin-bottom: 4px; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .row-2, .row-3 { grid-template-columns: minmax(0, 1fr); } }

.disclose { border-top: 1px dashed var(--rule); padding-top: 16px; }
.disclose summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .92rem;
}
.disclose summary::-webkit-details-marker { display: none; }
.disclose summary::after { content: "+"; font-family: var(--f-mono); font-size: 1.1rem; color: var(--muted); }
.disclose[open] summary::after { content: "–"; }
.disclose__body { display: grid; gap: 14px; margin-top: 16px; }

.gen__submit { display: grid; gap: 8px; }
.gen__submit .spec { text-align: center; }

/* Output: the document */
.doc { min-height: 560px; display: flex; flex-direction: column; overflow: hidden; }
.doc__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.doc__body { flex: 1; background: var(--paper); position: relative; }
.essay-pre {
  font-family: var(--f-serif);
  font-size: 1.04rem;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: clamp(24px, 5vw, 56px) clamp(20px, 6vw, 72px) 64px;
  max-width: 76ch;
  margin-inline: auto;
}
.doc__empty {
  display: grid; place-items: center; text-align: center; gap: 14px;
  padding: 64px 24px; height: 100%; min-height: 480px;
  color: var(--faint);
  background-image:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}
.doc__empty h3 { color: var(--ink); font-size: 1.4rem; }
.doc__empty p { max-width: 36ch; }

.drafting { padding: 40px clamp(20px, 6vw, 72px); display: grid; gap: 14px; }
.drafting__status { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar { height: 12px; border-radius: 4px; background: var(--rule-soft); position: relative; overflow: hidden; }
.bar::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ochre) 35%, transparent), transparent);
  transform: translateX(-100%);
  animation: sweep 1.4s var(--ease) infinite;
}
.bar:nth-child(3n) { width: 82%; }
.bar:nth-child(4n) { width: 64%; }
@keyframes sweep { to { transform: translateX(100%); } }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ochre); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.5); opacity: .5; } }

.badge {
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .06em;
  padding: 4px 10px; border-radius: var(--pill);
  background: var(--tint-olive); color: var(--olive);
  border: 1px solid color-mix(in srgb, var(--olive) 40%, transparent);
}
.badge:empty { display: none; }

.alert {
  margin: 24px; padding: 16px 18px;
  border: var(--bw) solid var(--red); border-radius: var(--r);
  background: var(--tint-red); color: var(--ink);
}
.alert strong { color: var(--red); }

/* Gate */
.generator-gate {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: start center;
  padding: clamp(40px, 10vw, 120px) 16px;
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  border-radius: var(--r-lg);
}
.gate { width: min(100%, 480px); padding: 32px; text-align: left; }
.gate h3 { font-size: 1.7rem; margin: 10px 0 10px; }
.gate p { color: var(--muted); }
.gate__form { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.gate__form .input { flex: 1 1 200px; }
.gate__fine { font-size: .8rem; color: var(--faint); margin-top: 12px; }
.generator-content-locked { pointer-events: none; user-select: none; filter: grayscale(.4); opacity: .55; }
.offer {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tint-ochre); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--ochre) 70%, transparent);
  padding: 6px 12px; border-radius: var(--pill);
  font-weight: 600; font-size: .86rem; margin-top: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════
   DIALOGS + TOASTS
   ═══════════════════════════════════════════════════════════════════════ */
dialog.dlg {
  width: min(100% - 32px, 560px);
  max-height: min(90dvh, 820px);
  padding: 0;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--card);
  color: var(--ink);
  overflow: auto;
}
dialog.dlg--wide { width: min(100% - 32px, 760px); }
dialog.dlg::backdrop { background: rgb(18 18 18 / .6); }
@media (prefers-reduced-motion: no-preference) {
  dialog.dlg[open] { animation: dlg-in .22s var(--ease); }
  @keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
}
.dlg__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: var(--bw) solid var(--ink); }
.dlg__head h2 { font-size: 1.3rem; }
.dlg__body { padding: 22px; display: grid; gap: 16px; }
.dlg__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 0 22px 22px; }
.x {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; border: var(--bw) solid var(--rule); background: transparent; cursor: pointer;
}
.x:hover { border-color: var(--ink); }
.x svg { width: 14px; height: 14px; }

.toasts {
  position: fixed; z-index: 400; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; pointer-events: none;
  width: min(100% - 32px, 440px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--on-ink);
  padding: 12px 18px; border-radius: var(--pill);
  font-weight: 500; font-size: .92rem;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ochre); flex: none; }
.toast--ok::before { background: #8DB36A; }
.toast--err::before { background: #E7826D; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .25s var(--ease); }
  @keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
}

/* Cover chooser */
.cover-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .cover-grid { grid-template-columns: minmax(0, 1fr); } }
.cover-card {
  display: grid; gap: 10px; text-align: left; padding: 12px;
  border: var(--bw) solid var(--rule); border-radius: var(--r);
  background: var(--paper); cursor: pointer;
  transition: border-color .15s, transform .15s var(--ease);
}
.cover-card:hover { border-color: var(--ink); }
.cover-card.selected, .cover-card[aria-pressed="true"] { border-color: var(--ink); background: var(--tint-ochre); }
.cover-preview { aspect-ratio: 3 / 4; border-radius: 6px; border: 1px solid var(--rule); background: #fff; display: grid; place-content: center; gap: 6px; padding: 14px; overflow: hidden; }
.cover-preview i { display: block; height: 5px; border-radius: 2px; background: #1C1A17; margin-inline: auto; }
.cover-preview--academic { outline: 3px solid #2D5B8A; outline-offset: -9px; }
.cover-preview--academic i { background: #2D5B8A; }
.cover-preview--pro { place-content: start stretch; padding: 0; }
.cover-preview--pro b { display: block; height: 32%; background: #1C1A17; margin-bottom: 18px; }
.cover-preview--pro i { margin-inline: 14px 0; }
.cover-label { font-weight: 600; font-size: .92rem; }
.cover-desc { font-size: .78rem; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════════════
   STUDIO
   ═══════════════════════════════════════════════════════════════════════ */
.studio-layout {
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: 64px;
}
@media (min-width: 1100px) { .studio-layout { grid-template-columns: 220px minmax(0, 1fr) 260px; align-items: start; } }

.tools { padding: 8px; display: grid; gap: 2px; }
@media (min-width: 1100px) { .tools { position: sticky; top: 88px; } }
.tools__group { padding: 12px 10px 6px; }
.tool-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; text-align: left; cursor: pointer;
  font-weight: 500; font-size: .92rem;
  transition: background .12s;
}
.tool-btn:hover { background: var(--rule-soft); }
.tool-btn .spec { font-size: .64rem; min-width: 2.2em; color: var(--faint); }
@media (max-width: 1099px) {
  .tools { display: flex; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 10px; border-radius: var(--r); }
  .tools__group { display: none; }
  .tool-btn { flex: none; width: auto; border: 1px solid var(--rule); border-radius: var(--pill); background: var(--paper); white-space: nowrap; }
  .tool-btn .spec { display: none; }
}

.editor-card { overflow: hidden; display: flex; flex-direction: column; min-height: 70dvh; }
.editor-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px; border-bottom: var(--bw) solid var(--ink);
  background: var(--card);
}
.editor-toolbar .select { min-height: 36px; width: auto; padding: 4px 34px 4px 12px; font-size: .86rem; background-position: right 12px center; }
.fmt-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; cursor: pointer;
}
.fmt-btn:hover { background: var(--rule-soft); border-color: var(--rule); }
.fmt-btn svg { width: 17px; height: 17px; }
.toolbar-divider { width: 1px; height: 22px; background: var(--rule); margin: 0 4px; }
.toolbar-spacer { flex: 1; }
.save-state { font-family: var(--f-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 0 6px; }

.studio-editor-content {
  flex: 1;
  background: var(--paper);
  padding: clamp(24px, 5vw, 64px) clamp(20px, 6vw, 80px);
  font-family: var(--f-serif);
  font-size: 16px;
  line-height: 2;
  outline: none;
  max-width: none;
  overflow-wrap: anywhere;
}
.studio-editor-content:focus-visible { outline: none; box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ochre) 50%, transparent); }
.studio-editor-content:empty::before { content: attr(data-placeholder); color: var(--faint); white-space: pre-line; pointer-events: none; }

.processing-bar {
  display: none; align-items: center; gap: 12px;
  padding: 12px 18px; border-top: var(--bw) solid var(--ink);
  background: var(--tint-ochre); font-weight: 500; font-size: .92rem;
}
.processing-bar.on { display: flex; }

.inspector { display: grid; gap: 0; overflow: hidden; }
@media (min-width: 1100px) { .inspector { position: sticky; top: 88px; } }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-item { padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.stat-item:nth-child(odd) { border-right: 1px solid var(--rule); }
.stat-label { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.stat-value { font-family: var(--f-display); font-size: 1.7rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.insp { padding: 16px 18px; border-bottom: 1px solid var(--rule); display: grid; gap: 10px; }
.insp:last-child { border-bottom: 0; }
.tone-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tone-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 500;
  padding: 4px 10px; border-radius: var(--pill);
  background: var(--tint-blue); color: var(--ink);
}
.tone-tag--empty { background: var(--rule-soft); color: var(--faint); }
.tone-meter { display: grid; gap: 8px; }
.tone-meter__row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .82rem; }
.tone-meter__row b { font-family: var(--f-mono); font-weight: 500; font-size: .74rem; color: var(--muted); }
.tone-meter__bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--rule-soft); overflow: hidden; }
.tone-meter__bar span { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
.issue-item { font-size: .86rem; padding: 10px 12px; border-radius: var(--r-sm); background: var(--paper); border: 1px solid var(--rule); }
.issue-item + .issue-item { margin-top: 6px; }
.issue-fix { display: inline-block; margin-top: 4px; font-family: var(--f-mono); font-size: .78rem; color: var(--olive); }
.ok-note { color: var(--olive); font-weight: 500; font-size: .9rem; }

.tone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tone-card {
  text-align: left; padding: 12px 14px; cursor: pointer;
  border: var(--bw) solid var(--rule); border-radius: var(--r);
  background: var(--paper);
  transition: border-color .12s;
}
.tone-card:hover { border-color: var(--ink); }
.tone-card.selected { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.tone-card .name { font-weight: 600; font-size: .92rem; }
.tone-card .desc { font-size: .78rem; opacity: .75; }

.summary-out { font-family: var(--f-serif); line-height: 1.75; white-space: pre-wrap; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px 20px; max-height: 50dvh; overflow: auto; }

/* ═══════════════════════════════════════════════════════════════════════
   PORTAL
   ═══════════════════════════════════════════════════════════════════════ */
.auth-wrap { display: grid; place-items: center; padding: clamp(32px, 8vw, 88px) 0; }
.auth-card { width: min(100%, 440px); padding: 28px; display: grid; gap: 18px; }
.auth-card h1 { font-size: 2rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; border: var(--bw) solid var(--ink); border-radius: var(--pill); }
.auth-tab { border: 0; background: transparent; padding: 9px; border-radius: var(--pill); cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.auth-tab.active { background: var(--ink); color: var(--on-ink); }
.form-stack { display: grid; gap: 14px; }
.err { color: var(--red); font-size: .86rem; font-weight: 500; }
.note { font-size: .82rem; color: var(--faint); display: flex; gap: 8px; align-items: flex-start; }
.note .dot { margin-top: .45em; flex: none; }

.userchip { display: inline-flex; align-items: center; gap: 10px; }
.userchip__avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ochre); color: #1C1A17; font-weight: 700; font-family: var(--f-display); }

.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; padding-bottom: 72px; }
.project-card {
  display: grid; gap: 18px; text-align: left; padding: 22px; cursor: pointer;
  background: var(--card); border: var(--bw) solid var(--ink); border-radius: var(--r-lg);
  transition: background .15s;
}
.project-card:hover { background: var(--paper); }
.project-card:hover .project-title { text-decoration: underline; text-decoration-color: var(--ochre); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.project-card__top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.project-title { font-size: 1.3rem; }
.project-topic { color: var(--muted); font-size: .92rem; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-stage-badge { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: var(--pill); background: var(--ink); color: var(--on-ink); white-space: nowrap; }
.stage-progress-bar { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.stage-pip { height: 6px; border-radius: 3px; background: var(--rule-soft); }
.stage-pip.filled { background: var(--olive); }
.project-card__foot { display: flex; justify-content: space-between; }

.empty {
  display: grid; justify-items: center; text-align: center; gap: 14px;
  padding: 72px 24px; margin-bottom: 72px;
  border: var(--bw) dashed var(--rule); border-radius: var(--r-lg);
}
.empty h2 { font-size: 1.6rem; }
.empty p { color: var(--muted); max-width: 44ch; }

.back { display: inline-flex; align-items: center; gap: 8px; }
.stage-tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin;
  padding: 4px 2px 14px; margin-bottom: 8px;
  scroll-snap-type: x proximity;
}
.stage-tab {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--pill);
  border: var(--bw) solid var(--rule); background: var(--paper);
  cursor: pointer; font-weight: 500; font-size: .86rem; color: var(--faint);
}
.stage-tab .spec { font-size: .62rem; color: inherit; }
.stage-tab.reached { color: var(--ink); border-color: var(--faint); }
.stage-tab.active { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.stage-panel { display: grid; gap: 0; overflow: hidden; margin-bottom: 72px; }
.stage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 22px; border-bottom: var(--bw) solid var(--ink); }
.stage-header h2 { font-size: 1.5rem; }
.stage-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .stage-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } .stage-col + .stage-col { border-left: var(--bw) solid var(--ink); } }
.stage-col { display: grid; align-content: start; }
.stage-section { padding: 20px 22px; display: grid; gap: 10px; border-bottom: 1px solid var(--rule); }
.stage-section:last-child { border-bottom: 0; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-editor { font-family: var(--f-serif); min-height: 260px; }
.stage-changes { min-height: 120px; font-family: var(--f-body); }
.state { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: var(--pill); }
.state--now { background: var(--ochre); color: #1C1A17; }
.state--done { background: var(--tint-olive); color: var(--olive); }
.state--next { background: var(--rule-soft); color: var(--faint); }

.ai-chat-window { display: grid; gap: 10px; align-content: start; min-height: 260px; max-height: 420px; overflow-y: auto; padding: 14px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); }
.chat-msg { display: flex; }
.chat-msg.user-msg { justify-content: flex-end; }
.chat-bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.user-msg .chat-bubble { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 4px; }
.ai-msg .chat-bubble { background: var(--card); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.chat-empty { color: var(--faint); font-size: .9rem; text-align: center; padding: 32px 8px; }
.ai-chat-input { display: flex; gap: 8px; }
.ai-chat-input .input { flex: 1; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: pulse 1s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.foot { border-top: var(--bw) solid var(--ink); background: var(--card); margin-top: auto; }
.foot__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 32px; padding: 26px 0; }
.foot__maker { display: flex; align-items: center; gap: 14px; }
.foot__maker svg { height: 20px; width: auto; }
.foot__maker svg path { fill: var(--ink); }
.foot__links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .9rem; }
.foot__links a { color: var(--muted); text-decoration: none; }
.foot__links a:hover { color: var(--ink); text-decoration: underline; }

/* ── Motion & print ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@media print {
  .masthead, .foot, .hero, .rail, #features, .gen__form, .doc__head, .toasts, .skip, .section__head { display: none !important; }
  body, .doc__body { background: #fff; color: #000; }
  .section { padding: 0; }
  .panel { border: 0; }
  .gen { display: block; }
  .essay-pre { padding: 0; max-width: none; font-size: 12pt; }
}
