/* ===========================================================
   Atlas of Symptoms
   Calm, restrained, type-led. Warm paper, deep ink, one bronze.
   =========================================================== */

:root {
  --font-display: "Fraunces", "Iowan Old Style", "Palatino", serif;
  --font-body: "Inter Tight", -apple-system, "Helvetica Neue", sans-serif;

  /* Warm paper neutrals */
  --paper:        oklch(0.985 0.008 78);
  --paper-2:      oklch(0.965 0.013 76);
  --paper-3:      oklch(0.93 0.018 72);
  --paper-edge:   oklch(0.88 0.022 68);

  /* Ink scale, slightly cool to keep ink-on-paper feel */
  --ink:          oklch(0.18 0.022 282);
  --ink-2:        oklch(0.30 0.020 280);
  --ink-3:        oklch(0.44 0.018 280);
  --ink-4:        oklch(0.55 0.018 280);
  --ink-5:        oklch(0.70 0.015 280);

  --rule:         oklch(0.85 0.014 280);
  --rule-soft:    oklch(0.91 0.010 280);

  /* THE accent: a single warm bronze.
     Used only on the primary CTA, the active mode tab, the strength
     bars, the focus ring, and a couple of micro-touches. Nowhere else. */
  --accent:       oklch(0.55 0.115 55);
  --accent-deep:  oklch(0.43 0.115 50);
  --accent-soft:  oklch(0.78 0.080 60);
  --accent-glaze: oklch(0.96 0.020 60);

  /* Diagnostic signal colors — desaturated to fit warm paper */
  --positive:     oklch(0.46 0.105 152);
  --positive-soft:oklch(0.96 0.025 152);
  --negative:     oklch(0.50 0.135 30);
  --negative-soft:oklch(0.96 0.030 30);

  --shadow-1: 0 1px 0 rgba(40, 25, 10, 0.04), 0 14px 32px -22px rgba(40, 25, 10, 0.18);
  --shadow-2: 0 1px 0 rgba(40, 25, 10, 0.06), 0 24px 60px -28px rgba(40, 25, 10, 0.28);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "ss01", "cv11";
  position: relative;
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { border: 0; background: none; cursor: pointer; }

::selection {
  background: color-mix(in oklab, var(--accent) 28%, transparent);
  color: var(--ink);
}

/* ----------------------------------------------------------
   SKIP LINK
   ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  transition: top 200ms var(--ease);
}
.skip-link:focus {
  top: 1rem;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   PAGE SHELL
   ---------------------------------------------------------- */

.masthead {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.masthead-row {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem clamp(1.4rem, 2.5vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-family: var(--font-body);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.masthead-nav {
  display: flex;
  gap: 1.6rem;
  font-size: 0.86rem;
}

.masthead-nav a {
  color: var(--ink-3);
  text-decoration: none;
  transition: color 200ms var(--ease);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}

.masthead-nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(2rem, 3vw + 1rem, 4rem) clamp(1.4rem, 2.5vw, 3rem) 4rem;
}

/* ----------------------------------------------------------
   HERO — compressed, no editorial scenery
   ---------------------------------------------------------- */

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  gap: clamp(1rem, 1.5vw, 1.6rem);
  padding: clamp(1.8rem, 2.8vw, 2.6rem) clamp(1.4rem, 2.5vw, 3rem) clamp(2rem, 3vw, 3rem);
  margin-inline: calc(-1 * clamp(1.4rem, 2.5vw, 3rem));
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper) 88%, var(--paper-2));
}

/* Layered ambient color — three overlapping warm washes anchored to
   different corners. Creates real color variation across the hero
   without ever reading as a flat tinted card. */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    /* upper-left: warm bronze glaze, the dominant wash */
    radial-gradient(900px 480px at 6% -8%,
      color-mix(in oklab, var(--accent-glaze) 100%, transparent) 0%,
      transparent 60%),
    /* lower-right: a deeper paper tone, anchors the corner */
    radial-gradient(720px 420px at 102% 108%,
      color-mix(in oklab, var(--paper-3) 72%, transparent) 0%,
      transparent 62%),
    /* mid-right: a softer secondary warm tint that bridges them */
    radial-gradient(520px 280px at 78% 48%,
      color-mix(in oklab, var(--accent-glaze) 55%, transparent) 0%,
      transparent 70%),
    /* upper-right: a cool quiet area for breathing room */
    radial-gradient(600px 320px at 95% 0%,
      color-mix(in oklab, var(--paper-2) 60%, transparent) 0%,
      transparent 65%);
  pointer-events: none;
}

/* A second pseudo-element holds a faint repeating texture so the
   color variation has some tooth instead of being pure gradient. */
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    repeating-radial-gradient(circle at 50% 50%,
      rgba(80, 50, 20, 0.012) 0 1px,
      transparent 1px 3px);
  mix-blend-mode: multiply;
  pointer-events: none;
  opacity: 0.7;
}

/* Tiny geometric mark above the title — square + rule, in bronze. */
.hero-mark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
}

.mark-square {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: var(--accent);
}

.mark-rule {
  display: inline-block;
  width: clamp(48px, 6vw, 76px);
  height: 2px;
  background: var(--accent);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 1.4rem + 3.4vw, 4.6rem);
  line-height: 1.0;
  letter-spacing: -0.022em;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
  max-width: 18ch;
}

.hero-title em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  position: relative;
  display: inline-block;
}

/* A soft hand-marked highlight behind the em accent. */
.hero-title em::before {
  content: "";
  position: absolute;
  left: -0.05em;
  right: -0.05em;
  bottom: 0.06em;
  height: 0.22em;
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  z-index: -1;
  border-radius: 1px;
}

.hero-lede {
  margin: 0;
  max-width: 56ch;
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.12rem);
  line-height: 1.6;
  color: var(--ink-2);
}

.hero-safety {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
  font-size: 0.84rem;
  color: var(--ink-3);
  max-width: 78ch;
  line-height: 1.55;
}

/* ----------------------------------------------------------
   MODE STRIP
   ---------------------------------------------------------- */

.mode-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
  align-items: baseline;
  padding: clamp(1.6rem, 2.5vw, 2.6rem) 0 clamp(1.4rem, 2vw, 2rem);
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 880px) {
  .mode-strip { grid-template-columns: auto auto 1fr; gap: 1.2rem 1.8rem; }
}

.strip-prompt {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.mode-tabs {
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
}

.mode-tab {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.4rem);
  line-height: 1;
  color: var(--ink-4);
  letter-spacing: -0.018em;
  padding: 0.05em 0.05em;
  border-radius: 0;
  position: relative;
  transition: color 220ms var(--ease);
}

.mode-tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -0.18em;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms var(--ease);
}

.mode-tab:hover { color: var(--ink-2); }

.mode-tab.is-active { color: var(--ink); }

.mode-tab.is-active::after { transform: scaleX(1); }

.strip-caption {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-3);
  max-width: 50ch;
  line-height: 1.55;
}

@media (min-width: 880px) {
  .strip-caption { justify-self: end; text-align: right; }
}

/* ----------------------------------------------------------
   INTAKE
   ---------------------------------------------------------- */

.intake { padding-top: clamp(2rem, 3vw, 3rem); }

.intake-head {
  margin-bottom: clamp(2rem, 3vw, 3rem);
  display: grid;
  gap: 0.5rem;
  max-width: 70ch;
}

.kicker {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.intake-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.85rem, 1.4rem + 1.6vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--ink);
  text-wrap: balance;
}

.intake-lede {
  margin: 0.4rem 0 0;
  max-width: 56ch;
  font-size: 1rem;
  color: var(--ink-2);
  line-height: 1.6;
}

.intake-form {
  display: none;
  flex-direction: column;
  gap: clamp(2.4rem, 3vw, 3.6rem);
}

.intake-form.is-active { display: flex; }

/* Block: marginalia (left rail) | body (right column) */
.block {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.2rem;
  padding-top: clamp(1.6rem, 2.4vw, 2.4rem);
  border-top: 1px solid var(--rule);
  position: relative;
}

.intake-form > .block:first-of-type { padding-top: 0; border-top: 0; }

@media (min-width: 760px) {
  .block {
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    gap: clamp(2rem, 3vw, 3.6rem);
  }
}

.margin {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
}

@media (min-width: 760px) {
  .margin { position: sticky; top: 1.5rem; align-self: start; }
}

.block-num {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.block-title {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.3rem, 1.1rem + 0.6vw, 1.65rem);
  line-height: 1.1;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.block-note {
  margin: 0.2rem 0 0;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink-3);
  max-width: 28ch;
  line-height: 1.5;
}

.block-body {
  display: grid;
  gap: clamp(1.5rem, 1.6vw, 2.2rem);
  min-width: 0;
}

.row { display: grid; gap: 1.2rem; }

.row-basics {
  grid-template-columns: minmax(0, 0.55fr) minmax(0, 1.45fr);
  align-items: start;
  gap: 1.4rem 2rem;
}

.row-twin {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem 1.8rem;
}

.row-extras {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.3rem 1.6rem;
}

@media (max-width: 720px) {
  .row-basics, .row-twin, .row-extras { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------
   FIELDS
   ---------------------------------------------------------- */

.text-field, .pill-field, .intensity-field {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.text-label, legend.text-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.02rem;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.005em;
  padding: 0;
}

.text-help {
  margin: -0.15rem 0 0.25rem;
  font-family: var(--font-body);
  font-size: 0.83rem;
  color: var(--ink-3);
  line-height: 1.5;
}

input[type="number"],
input[type="text"],
.text-field-select select,
textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--rule);
  border-radius: 0;
  padding: 0.7rem 0 0.75rem;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

input[type="number"]::placeholder,
input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--ink-5);
}

input[type="number"]:hover,
input[type="text"]:hover,
.text-field-select select:hover,
textarea:hover {
  border-bottom-color: var(--ink-3);
}

input[type="number"]:focus,
input[type="text"]:focus,
.text-field-select select:focus,
textarea:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.text-field-select { position: relative; }

.text-field-select select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 2rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 1.15rem, calc(100% - 8px) 1.15rem;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.text-field-select select option {
  background: var(--paper);
  color: var(--ink);
}

/* ----------------------------------------------------------
   PILL DECKS
   ---------------------------------------------------------- */

.pill-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.pill-deck-dual {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.pill-deck-tight { gap: 0.4rem; }

.pill-option {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0.18rem;
  min-height: 44px;
  padding: 0.7rem 1.05rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: color-mix(in oklab, var(--paper) 88%, white);
  color: var(--ink-2);
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 220ms var(--ease), background 220ms var(--ease), color 220ms var(--ease), transform 220ms var(--ease);
  isolation: isolate;
}

.pill-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.pill-label {
  font-size: 0.96rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings: "opsz" 18;
}

.pill-hint {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-3);
  line-height: 1.3;
}

.pill-option:hover {
  border-color: var(--ink-3);
  background: color-mix(in oklab, var(--paper) 70%, white);
}

.pill-option.is-selected,
.pill-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glaze);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.pill-option.is-selected .pill-label,
.pill-option:has(input:checked) .pill-label {
  color: var(--accent-deep);
}

.pill-option.is-selected .pill-hint,
.pill-option:has(input:checked) .pill-hint {
  color: var(--accent);
}

.pill-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  position: relative;
  z-index: 2;
}

.pill-option:active { transform: scale(0.97); }

.pill-deck-tight .pill-option { padding: 0.55rem 0.95rem; }

[data-style="compact"] .pill-option {
  padding: 0.55rem 1rem;
  flex-direction: row;
  align-items: center;
}

/* ----------------------------------------------------------
   INTENSITY SCALE — 11 buttons, visually weighted
   ---------------------------------------------------------- */

.intensity-field { gap: 0.7rem; }

.intensity-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.intensity-readout {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--accent-deep);
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.005em;
}

.intensity-readout em {
  font-style: italic;
}

.intensity-scale {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}

.intensity-step {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 0.4rem;
  background: color-mix(in oklab, var(--paper) 88%, white);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 220ms var(--ease), border-color 220ms var(--ease), color 220ms var(--ease), transform 220ms var(--ease);
}

/* Visual weight scales with the value — bigger and bolder as you climb. */
.intensity-step[data-value="0"] { font-size: 0.84rem; color: var(--ink-4); }
.intensity-step[data-value="1"] { font-size: 0.90rem; }
.intensity-step[data-value="2"] { font-size: 0.95rem; }
.intensity-step[data-value="3"] { font-size: 1.00rem; }
.intensity-step[data-value="4"] { font-size: 1.05rem; }
.intensity-step[data-value="5"] { font-size: 1.10rem; }
.intensity-step[data-value="6"] { font-size: 1.15rem; }
.intensity-step[data-value="7"] { font-size: 1.22rem; }
.intensity-step[data-value="8"] { font-size: 1.30rem; }
.intensity-step[data-value="9"] { font-size: 1.40rem; font-weight: 600; }
.intensity-step[data-value="10"] { font-size: 1.55rem; font-weight: 600; }

.intensity-step:hover {
  background: var(--accent-glaze);
  border-color: var(--ink-3);
  color: var(--ink);
}

.intensity-step.is-selected {
  background: var(--accent-glaze);
  border-color: var(--accent);
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 1px var(--accent);
  transform: translateY(-1px);
}

.intensity-step:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  z-index: 2;
}

.intensity-step:active { transform: scale(0.96); }

.intensity-anchors {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-body);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-top: 0.2rem;
}

@media (max-width: 720px) {
  .intensity-scale {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .intensity-step { min-height: 48px; }
}

/* ----------------------------------------------------------
   EXTRAS
   ---------------------------------------------------------- */

.extras {
  padding-top: clamp(1.6rem, 2vw, 2.2rem);
  border-top: 1px solid var(--rule);
}

.extras > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--ink);
  padding: 0.4rem 0;
  min-height: 44px;
}

.extras > summary::-webkit-details-marker { display: none; }

.extras-marker {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  position: relative;
  flex-shrink: 0;
  transition: transform 280ms var(--ease), background 280ms var(--ease);
  margin-left: auto;
}

.extras-marker::before,
.extras-marker::after {
  content: "";
  position: absolute;
  background: var(--accent);
  border-radius: 1px;
}

.extras-marker::before { width: 10px; height: 1.5px; }
.extras-marker::after  { width: 1.5px; height: 10px; transition: transform 280ms var(--ease); }

/* Works for any <details> using the extras-marker pattern */
[open] > summary .extras-marker {
  background: var(--accent-glaze);
  transform: rotate(180deg);
}

[open] > summary .extras-marker::after { transform: scaleY(0); }

.extras-lede {
  margin: 0.8rem 0 1.4rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink-3);
  line-height: 1.55;
  max-width: 50ch;
}

/* ----------------------------------------------------------
   FORM ACTIONS
   ---------------------------------------------------------- */

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.6rem;
  align-items: center;
  padding-top: clamp(1.4rem, 2vw, 2rem);
  border-top: 1px solid var(--rule);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: 4px;
  min-height: 44px;
  transition: transform 220ms var(--ease), background 220ms var(--ease), color 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms var(--ease);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-1);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-arrow {
  font-size: 1.15em;
  transition: transform 260ms var(--ease);
}

.btn-primary:hover .btn-arrow { transform: translateX(3px); }

.btn-ghost {
  background: transparent;
  color: var(--ink-3);
  padding: 0.85rem 0.6rem;
  border-radius: 0;
  border-bottom: 1px solid transparent;
  min-height: 44px;
}

.btn-ghost:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.btn.is-loading {
  pointer-events: none;
  position: relative;
}

.btn.is-loading::after {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  border: 2px solid color-mix(in oklab, var(--paper) 50%, transparent);
  border-top-color: var(--paper);
  animation: spin 700ms linear infinite;
}

/* ----------------------------------------------------------
   RECEIPT
   ---------------------------------------------------------- */

.receipt {
  margin-top: clamp(3rem, 4vw, 4.5rem);
  padding: clamp(1.6rem, 2.4vw, 2.4rem) clamp(1.4rem, 2vw, 2.2rem);
  background: color-mix(in oklab, var(--paper) 95%, white);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow-1);
}

.receipt-head {
  display: grid;
  gap: 0.6rem 1.5rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  margin-bottom: 1rem;
}

@media (min-width: 720px) {
  .receipt-head { grid-template-columns: minmax(0, 1fr) auto; }
}

.receipt-head h2 {
  margin: 0.3rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.2rem + 0.6vw, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.014em;
  color: var(--ink);
}

.receipt-meta {
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
  flex-wrap: wrap;
}

.progress {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.32rem;
  font-family: var(--font-body);
  color: var(--ink-2);
}

.progress-num {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.85rem;
  line-height: 1;
  color: var(--accent);
}

.progress-of, .progress-total {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink-3);
}

.progress-total { color: var(--ink-2); }

.progress-label {
  margin-left: 0.35rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.draft-tag {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-4);
}

.progress-bar {
  height: 2px;
  background: var(--rule-soft);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 0.9rem;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 480ms var(--ease);
}

.receipt-status {
  margin: 0 0 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink-3);
  line-height: 1.5;
  padding-bottom: 1.1rem;
  border-bottom: 1px dashed var(--rule);
}

.receipt-grid {
  display: grid;
  gap: 1.4rem 2rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 820px) {
  .receipt-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
}

.receipt-card { display: grid; gap: 0.6rem; min-width: 0; }

.receipt-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

.receipt-card-label {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--ink-3);
}

.btn-mini {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 0.3rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 200ms var(--ease), color 200ms var(--ease);
}

.btn-mini:hover:not(:disabled) { border-bottom-color: var(--accent); }

.btn-mini:disabled { color: var(--ink-5); cursor: not-allowed; }

.receipt-summary {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink);
  font-variation-settings: "opsz" 18;
  overflow-wrap: break-word;
}

.receipt-doctor {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--accent-glaze);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.85rem 0.95rem;
}

.receipt-doctor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent);
}

.receipt[data-state="empty"] .receipt-summary,
.receipt[data-state="empty"] .receipt-doctor {
  color: var(--ink-4);
}

/* ----------------------------------------------------------
   MATCHES
   ---------------------------------------------------------- */

.matches {
  margin-top: clamp(3.5rem, 5vw, 6rem);
  padding-top: clamp(2rem, 3vw, 3rem);
  border-top: 1px solid var(--rule);
}

.matches-head {
  display: grid;
  gap: 0.8rem 1.5rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  margin-bottom: 1.6rem;
}

@media (min-width: 880px) {
  .matches-head { grid-template-columns: minmax(0, 1fr) auto; }
}

.matches-head h2 {
  margin: 0.4rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  max-width: 30ch;
  text-wrap: balance;
}

.not-diagnosis {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--negative);
  padding: 0.4rem 0.85rem;
  border: 1px solid color-mix(in oklab, var(--negative) 35%, var(--rule));
  border-radius: 999px;
  background: var(--negative-soft);
}

.matches-status {
  margin: 0 0 1.6rem;
  font-family: var(--font-body);
  font-size: 0.96rem;
  color: var(--ink-3);
  max-width: 62ch;
  line-height: 1.55;
}

.matches-status.is-warning { color: var(--accent-deep); }
.matches-status.is-error { color: var(--negative); }

.matches-empty {
  display: grid;
  gap: 0.4rem;
  padding: 3rem 0;
  text-align: center;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
}

.empty-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink-2);
}

.empty-copy {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink-3);
  max-width: 50ch;
  margin-inline: auto;
}

.matches-list {
  display: grid;
  gap: clamp(2.4rem, 3vw, 3.6rem);
  margin-top: 1.6rem;
}

.match {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.2rem;
  padding: clamp(1.8rem, 2.5vw, 2.6rem) 0;
  border-top: 1px solid var(--rule);
  animation: rise-in 480ms var(--ease-out) both;
}

.match:first-child { padding-top: 0; border-top: 0; }

@media (min-width: 820px) {
  .match {
    grid-template-columns: clamp(60px, 8vw, 90px) minmax(0, 1fr);
    gap: clamp(1.4rem, 3vw, 2.6rem);
  }
}

.match-rank {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  line-height: 1;
}

.match-body {
  display: grid;
  gap: 1.1rem;
  min-width: 0;
}

.match-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 1.5rem;
  align-items: start;
}

.match-id { min-width: 0; }

.match-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.55rem, 1.2rem + 0.9vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: -0.014em;
  color: var(--ink);
  overflow-wrap: break-word;
}

.match-medical-name {
  margin: 0.4rem 0 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink-3);
  overflow-wrap: break-word;
}

.match-summary {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 65ch;
  font-variation-settings: "opsz" 18;
  overflow-wrap: break-word;
}

/* ----------------------------------------------------------
   STRENGTH BAR
   ---------------------------------------------------------- */

.match-strength {
  display: grid;
  gap: 0.5rem;
  margin: 0.2rem 0 0;
}

.strength-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.strength-readout {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.86rem;
  color: var(--positive);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 11ch;
}

.strength-bar {
  flex: 1 1 auto;
  height: 6px;
  background: color-mix(in oklab, var(--rule) 60%, var(--paper));
  position: relative;
  overflow: hidden;
}

.strength-fill {
  position: absolute;
  inset: 0;
  background: var(--positive);
  transform: scaleX(var(--strength, 0));
  transform-origin: left;
  transition: transform 720ms var(--ease);
}

.strength-bar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--ink-4);
  pointer-events: none;
  z-index: 2;
}

/* ----------------------------------------------------------
   REASON LISTS
   ---------------------------------------------------------- */

.reason-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem 2rem;
  padding-top: 0.4rem;
}

@media (min-width: 720px) {
  .reason-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.reason {
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  min-width: 0;
}

.reason-positive { border-left-color: color-mix(in oklab, var(--positive) 60%, white); }
.reason-negative { border-left-color: color-mix(in oklab, var(--negative) 60%, white); }

.reason-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--ink-3);
}

.reason-positive .reason-title { color: var(--positive); }
.reason-negative .reason-title { color: var(--negative); }

.reason-list {
  margin: 0;
  padding-left: 0;
  display: grid;
  gap: 0.7rem;
  font-family: var(--font-body);
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--ink-2);
  list-style: none;
}

.reason-list li {
  position: relative;
  padding-left: 3.4rem;
  min-height: 1.4rem;
  overflow-wrap: break-word;
}

.reason-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: var(--reason-weight, 1.6rem);
  max-width: 2.6rem;
  height: 3px;
  background: currentColor;
  opacity: 0.65;
  transition: width 600ms var(--ease);
}

.reason-positive .reason-list li::before { background: var(--positive); }
.reason-negative .reason-list li::before { background: var(--negative); }

.reason-list li[data-no-weight]::before {
  width: 0.6rem;
  opacity: 0.3;
}

/* ----------------------------------------------------------
   FACTOR BREAKDOWN
   ---------------------------------------------------------- */

.factor-details {
  border-top: 1px dashed var(--rule);
  padding-top: 1rem;
}

.factor-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--ink-2);
  min-height: 44px;
}

.factor-details > summary::-webkit-details-marker { display: none; }

.factor-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.factor-chip {
  display: grid;
  gap: 0.4rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--rule-soft);
  min-width: 0;
}

.factor-chip:last-child { border-bottom: 0; padding-bottom: 0; }

.factor-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

.factor-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  overflow-wrap: break-word;
  min-width: 0;
}

.factor-direction {
  font-family: var(--font-body);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}

.factor-direction.positive { color: var(--positive); }
.factor-direction.negative { color: var(--negative); }
.factor-direction.neutral  { color: var(--ink-4); }

.factor-bar {
  position: relative;
  height: 4px;
  background: color-mix(in oklab, var(--rule) 50%, var(--paper));
  overflow: visible;
}

.factor-bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--ink-4);
  z-index: 2;
}

.factor-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0%;
  transition: width 700ms var(--ease), left 700ms var(--ease);
}

.factor-bar-fill.positive {
  left: 50%;
  background: var(--positive);
}

.factor-bar-fill.negative {
  background: var(--negative);
}

.factor-bar-fill.neutral {
  left: calc(50% - 2px);
  width: 4px;
  background: var(--ink-5);
}

.factor-note {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-3);
  overflow-wrap: break-word;
}

/* ----------------------------------------------------------
   COLOPHON
   ---------------------------------------------------------- */

.colophon {
  margin-top: clamp(3.5rem, 4vw, 5rem);
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.colophon p {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.84rem;
  color: var(--ink-3);
}

/* ----------------------------------------------------------
   INLINE RETRY
   ---------------------------------------------------------- */

.inline-retry {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.2rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--negative);
  border: 1px solid var(--negative);
  border-radius: 999px;
  cursor: pointer;
  min-height: 28px;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.inline-retry:hover {
  background: color-mix(in oklab, var(--negative) 85%, black);
  transform: translateY(-1px);
}
.inline-retry:focus-visible {
  outline: 2px solid var(--negative);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   ANIMATIONS
   ---------------------------------------------------------- */

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rise-in-tight {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* First-load stagger */
.hero-mark   { animation: fade-in 700ms var(--ease-out) both; animation-delay: 0ms; }
.hero-title  { animation: rise-in 800ms var(--ease-out) both; animation-delay: 80ms; }
.hero-lede   { animation: rise-in 800ms var(--ease-out) both; animation-delay: 220ms; }
.hero-safety { animation: fade-in 700ms var(--ease-out) both; animation-delay: 340ms; }

/* The mark-rule grows in from the square — feels intentional. */
.mark-rule {
  animation: rule-grow 720ms var(--ease-out) both;
  animation-delay: 220ms;
  transform-origin: left;
}

@keyframes rule-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.mode-strip  { animation: fade-in 700ms var(--ease-out) both; animation-delay: 400ms; }
.intake-head { animation: fade-in 700ms var(--ease-out) both; animation-delay: 480ms; }

.intake-form > .block {
  animation: rise-in-tight 700ms var(--ease-out) both;
}
.intake-form > .block:nth-of-type(1) { animation-delay: 560ms; }
.intake-form > .block:nth-of-type(2) { animation-delay: 640ms; }
.intake-form > .block:nth-of-type(3) { animation-delay: 720ms; }

.match { animation: rise-in 600ms var(--ease-out) both; }
.match:nth-child(1) { animation-delay: 0ms; }
.match:nth-child(2) { animation-delay: 90ms; }
.match:nth-child(3) { animation-delay: 180ms; }
.match:nth-child(4) { animation-delay: 270ms; }
.match:nth-child(5) { animation-delay: 360ms; }

/* CTA letter-spacing micro */
.btn-primary { letter-spacing: -0.005em; }
.btn-primary:hover:not(:disabled) { letter-spacing: 0.01em; }

/* ----------------------------------------------------------
   REDUCED MOTION
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ----------------------------------------------------------
   MOBILE
   ---------------------------------------------------------- */

@media (max-width: 880px) {
  .margin {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px dashed var(--rule);
    margin-bottom: 1rem;
  }
  .block-num { flex-shrink: 0; }
  .block-title { margin-top: 0; flex: 1 1 auto; min-width: 0; }
  .block-note { flex: 1 0 100%; max-width: none; margin-top: 0; }
}

@media (max-width: 720px) {
  .masthead-row {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  .masthead-nav { gap: 1rem; font-size: 0.82rem; }
  .pill-deck-dual { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .btn-primary { justify-content: center; }
  .btn-ghost {
    text-align: center;
    border: 1px solid var(--rule);
    border-radius: 4px;
  }
  .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
  .receipt { padding: 1.2rem; }
  .match { padding: 1.6rem 0; grid-template-columns: 1fr; }
  .strength-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .strength-readout { min-width: 0; }
  .reason-list li { padding-left: 2.4rem; }
  .reason-list li::before { max-width: 1.8rem; }
}
