/* Subclass. Forms on the desk.
   Organising idea: the Department pages are on screen as blank forms before the first
   question, and every answer types one of them in. The desk is darker than the paper. */

:root {
  color-scheme: light;
  --ground: #DCDFD9;
  --ground2: #D2D6CF;
  --paper: #F7F8F4;
  --paperGhost: rgba(247, 248, 244, .38);
  --ink: #17201A;
  --ink2: rgba(23, 32, 26, .8);
  --ink3: rgba(23, 32, 26, .66);
  --ghost: rgba(23, 32, 26, .3);
  --hair: rgba(23, 32, 26, .12);
  --hair2: rgba(23, 32, 26, .2);
  --accent: #B93A2C;
  --accentInk: #2C0B07;
  --accentDim: rgba(185, 58, 44, .12);
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
  --paperTop: inset 0 1px 0 rgba(255, 255, 255, .6);
  --lift: 0 18px 44px -22px rgba(23, 32, 26, .35);
  --liftHover: 0 22px 48px -22px rgba(23, 32, 26, .42);
  --rLg: 1.25rem;
  --rMd: .85rem;
  --rSm: .5rem;
  --rPill: 999px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.4, .44, 1);
  --rail: 22rem;
  --gutter: 4.5rem;
  --column: 46rem;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Author', system-ui, sans-serif;
  --tnum: "tnum" 1, "lnum" 1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #1C1C19;
    --ground2: #161613;
    --paper: #262622;
    --paperGhost: rgba(236, 238, 232, .05);
    --ink: #ECEEE8;
    --ink2: rgba(236, 238, 232, .8);
    --ink3: rgba(236, 238, 232, .66);
    --ghost: rgba(236, 238, 232, .3);
    --hair: rgba(236, 238, 232, .12);
    --hair2: rgba(236, 238, 232, .2);
    --accent: #D9634B;
    --accentInk: #2C0B07;
    --accentDim: rgba(217, 99, 75, .18);
    --paperTop: inset 0 1px 0 rgba(255, 255, 255, .07);
    --lift: 0 18px 44px -22px rgba(0, 0, 0, .7);
    --liftHover: 0 22px 48px -22px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #1C1C19;
  --ground2: #161613;
  --paper: #262622;
  --paperGhost: rgba(236, 238, 232, .05);
  --ink: #ECEEE8;
  --ink2: rgba(236, 238, 232, .8);
  --ink3: rgba(236, 238, 232, .66);
  --ghost: rgba(236, 238, 232, .3);
  --hair: rgba(236, 238, 232, .12);
  --hair2: rgba(236, 238, 232, .2);
  --accent: #D9634B;
  --accentInk: #2C0B07;
  --accentDim: rgba(217, 99, 75, .18);
  --paperTop: inset 0 1px 0 rgba(255, 255, 255, .07);
  --lift: 0 18px 44px -22px rgba(0, 0, 0, .7);
  --liftHover: 0 22px 48px -22px rgba(0, 0, 0, .8);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100dvh;
}
::selection { background: var(--accent); color: var(--accentInk); }
a { color: inherit; text-decoration-color: var(--hair2); text-underline-offset: .14em; }
a:hover { text-decoration-color: var(--ink); }
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--rSm);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p, dl, dd, dt, blockquote, figure { margin: 0; }
[hidden] { display: none !important; }
svg.i { width: 1.1rem; height: 1.1rem; fill: currentColor; flex: none; }

/* Type roles */
.label {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink3);
}
.num { font-family: var(--display); font-variant-numeric: tabular-nums lining-nums; font-feature-settings: var(--tnum); }
.sub { color: var(--ink2); font-size: .95rem; }
.small { font-size: .78rem; color: var(--ink3); }
.textbtn { color: var(--ink2); text-decoration: underline; text-decoration-color: var(--hair2); text-underline-offset: .14em; font-size: .85rem; }
.textbtn:hover { color: var(--ink); text-decoration-color: var(--ink); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: .5rem .8rem; border-radius: var(--rSm); z-index: 60; }
.skip:focus { left: 8px; }

/* Head */
.head {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  gap: 1rem;
}
.wordmark { font-family: var(--display); font-weight: 500; font-size: 1rem; letter-spacing: -.01em; text-decoration: none; }
.headlinks { display: flex; gap: 1.25rem; align-items: center; }
.headlinks a, .headlinks button { font-size: .85rem; color: var(--ink2); text-decoration: underline; text-decoration-color: var(--hair2); text-underline-offset: .14em; }

/* Frame */
.frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  column-gap: 3rem;
  padding: 0 2rem 4rem;
  align-items: start;
}

/* Column */
.column { min-width: 0; }
.gate {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 40px;
  display: block;
  font-size: .78rem;
  line-height: 1.4;
  font-weight: 500;
  color: var(--ink2);
  background: var(--ground);
  border-bottom: 1px solid var(--hair);
  padding: .65rem 0 .55rem;
}
.gate a { color: var(--ink); }
.colhead { padding: 1.5rem 0 1rem; display: grid; gap: .35rem; }
.colsub { color: var(--ink2); font-size: .95rem; max-width: 46rem; }

.case {
  max-width: var(--column);
  padding-left: var(--gutter);
  display: grid;
  gap: 12px;
  position: relative;
}

/* Sheet */
.sheet {
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  margin-left: calc(-1 * var(--gutter));
  transition: opacity .6s var(--ease), transform .5s var(--ease);
  will-change: transform;
}
.sheet .gut {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 22px;
  gap: .1rem;
}
.sheet .gutnum {
  font-family: var(--display);
  font-weight: 500;
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums lining-nums;
  transition: color .3s var(--ease);
}
.sheet .gutrule { display: block; width: 1.6rem; height: 1px; background: var(--ghost); margin-top: 1.4rem; }
.sheet .gutlabel { font-family: var(--display); font-size: .6rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--ink3); }
.sheet .paper {
  background: var(--paper);
  border-radius: var(--rMd);
  box-shadow: var(--paperTop), var(--lift);
  padding: 20px 24px;
  min-height: 168px;
  display: grid;
  gap: 16px;
  transition: opacity .6s var(--ease), transform .6s var(--ease), box-shadow .5s var(--ease);
}
.sheet.ghost .paper { background: var(--paperGhost); box-shadow: none; }
.sheet.ghost .gutnum { color: var(--ghost); }
.sheet.top .paper { margin-left: calc(-1 * var(--gutter) + .9rem); padding-left: calc(24px + var(--gutter) - .9rem); box-shadow: var(--paperTop), var(--liftHover); }
.sheet.top .gut { position: relative; z-index: 1; }
.sheet.top .gutnum { color: var(--ink); }
.sheet.lifting .paper { animation: lift .6s var(--ease); }
@keyframes lift { from { opacity: .38; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.sheethead { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.visa {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  letter-spacing: -.01em;
  line-height: 1.08;
  max-width: 24ch;
  clip-path: inset(0 0 0 0);
  transition: clip-path .42s var(--ease) .18s;
}
.visa.filling { clip-path: inset(0 100% 0 0); }
.subclass { font-family: var(--display); font-size: .8rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink2); white-space: nowrap; }

.band { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; }
.fld { display: grid; gap: .3rem; align-content: start; }
.fld .val { font-weight: 500; font-size: 1rem; color: var(--ink); overflow-wrap: anywhere; }
.fld .val.num { font-size: 1.05rem; }
.fld .val.long { font-size: .9rem; font-weight: 400; color: var(--ink2); }
.fld .val.flag { font-family: var(--display); font-size: .62rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); padding: .2rem .45rem; border: 1px solid var(--hair2); border-radius: var(--rSm); justify-self: start; }

.rule { display: block; height: 1px; background: var(--ghost); width: var(--w, 60%); }
.rule.tall { height: 1.4rem; background: none; border-bottom: 1px solid var(--ghost); }
.rules { display: grid; gap: 10px; }

.block { display: grid; gap: .5rem; }
.block .label { margin-bottom: .1rem; }
.quote { font-size: .95rem; color: var(--ink); padding-left: 14px; border-left: 2px solid var(--hair2); }
.quote cite { display: block; font-style: normal; font-size: .78rem; color: var(--ink3); margin-top: .2rem; }
.pairs { display: grid; gap: .55rem; }
.pair { display: grid; grid-template-columns: 5.4rem minmax(0, 1fr); gap: .15rem .8rem; align-items: baseline; }
.pair dt { font-family: var(--display); font-size: .62rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink3); padding-top: .2rem; }
.pair dd { font-size: .95rem; color: var(--ink); }
.pair dd.you { font-weight: 500; }
.pair.diff dd.page { color: var(--ink2); }
.warnrow { display: flex; gap: .6rem; align-items: flex-start; font-size: .95rem; color: var(--ink); }
.warnrow svg.i { margin-top: .15rem; color: var(--ink2); }
.plainlist { display: grid; gap: .35rem; font-size: .95rem; color: var(--ink2); padding-left: 20px; }
.plainlist li { list-style: none; text-indent: -20px; }
.plainlist li::before { content: ""; display: inline-block; width: 8px; height: 1px; background: var(--ink3); vertical-align: middle; margin: 0 10px 0 2px; }
.source { font-size: .78rem; color: var(--ink3); display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.source a { color: var(--ink2); display: inline-flex; align-items: center; gap: .25rem; }
.source svg.i { width: .85rem; height: .85rem; }
.more { color: var(--ink2); font-size: .85rem; text-decoration: underline; text-decoration-color: var(--hair2); }

/* Empty result sheet */
.sheet.none .visa { font-size: 1.6rem; }

/* Answer sheet */
.answer {
  max-width: var(--column);
  margin-top: 28px;
  background: var(--paper);
  border-radius: var(--rLg);
  box-shadow: var(--paperTop), var(--lift);
  padding: 32px;
  display: grid;
  gap: 20px;
}
.answer .gateline { font-size: .78rem; color: var(--ink2); padding-bottom: 12px; border-bottom: 1px solid var(--hair); }
.answerhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem 1rem; align-items: start; }
.answerhead h2 { font-family: var(--display); font-weight: 500; font-size: 1.6rem; letter-spacing: -.01em; grid-column: 1; }
.answerhead .sub { grid-column: 1; }
.answerhead .pill { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
.rows { display: grid; gap: 0; }
.row {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr) 2.2rem;
  gap: .2rem 1rem;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
  position: relative;
}
.row:last-child { border-bottom: 0; }
.row .k { padding-top: .15rem; font-size: .85rem; font-weight: 500; color: var(--ink2); line-height: 1.35; }
.rows .fade { position: relative; max-height: 7.5rem; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent); mask-image: linear-gradient(to bottom, black 20%, transparent); }
.rows .rest { padding: 10px 0 0; font-size: .95rem; color: var(--ink2); }
.row .v { font-size: 1rem; color: var(--ink); overflow-wrap: anywhere; }
.row .v.num { font-size: 1rem; }
.row .v.missing { color: var(--ink3); font-style: italic; }
.row .note { grid-column: 2; font-size: .78rem; color: var(--ink3); }
.row .tag { display: inline-block; font-family: var(--display); font-size: .6rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); border: 1px solid var(--hair2); border-radius: var(--rSm); padding: .1rem .4rem; margin-left: .5rem; vertical-align: middle; }
.row .copy { grid-column: 3; grid-row: 1; justify-self: end; opacity: 0; color: var(--ink2); width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--rPill); transition: opacity .16s var(--ease), background-color .16s var(--ease); }
.row:hover .copy, .row:focus-within .copy, .row .copy:focus-visible { opacity: 1; }
.row .copy:hover { background: var(--ground2); }
.row .copy.done { opacity: 1; color: var(--ink); }
@media (hover: none) { .row .copy { opacity: 1; } }
.section { padding-top: 14px; }
.paidstep { display: grid; gap: .8rem; padding-top: 20px; border-top: 1px solid var(--hair); }
.paidstep .pill .price { font-family: var(--display); font-variant-numeric: tabular-nums lining-nums; font-weight: 500; padding-left: .6rem; margin-left: .6rem; border-left: 1px solid rgba(44, 11, 7, .25); }
.freestep { display: grid; gap: .5rem; padding-top: 20px; border-top: 1px solid var(--hair); }
.steps { display: grid; gap: .5rem; padding-left: 0; counter-reset: s; }
.steps li { list-style: none; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: .6rem; font-size: .95rem; color: var(--ink); }
.steps li::before { counter-increment: s; content: counter(s); font-family: var(--display); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink3); }

/* Rail */
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 1rem;
  padding: 1rem 0 1.25rem;
  min-width: 0;
}
.railtop { min-height: 0; display: grid; align-content: start; gap: .8rem; }
.railtop h1 { font-size: 1.3rem; font-weight: 500; line-height: 1.25; max-width: 26ch; letter-spacing: -.005em; }
.railtop .sub { max-width: 30ch; }
.ledgerwrap { min-height: 0; overflow: auto; max-height: 40dvh; -webkit-mask-image: linear-gradient(to bottom, transparent, black 16px, black calc(100% - 16px), transparent); mask-image: linear-gradient(to bottom, transparent, black 16px, black calc(100% - 16px), transparent); padding: 12px 0; }
.ledger { display: grid; gap: 0; }
.lrow {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: baseline;
  min-height: 32px;
  padding: 4px 0 4px 10px;
  margin-left: -10px;
  border-left: 2px solid transparent;
}
.lrow.asking { border-left-color: var(--accent); }
.lrow .lk { font-family: var(--display); font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); padding-top: .15rem; }
.lrow .lv {
  font-size: .95rem;
  color: var(--ink);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.lrow .lv.open { -webkit-line-clamp: unset; line-clamp: unset; }
.lrow .lv.empty { color: var(--ghost); }
.lrow .lv.flash { animation: flash .6s var(--ease); }
@keyframes flash { from { background: var(--accentDim); } to { background: transparent; } }
.lrow .change { opacity: 0; font-size: .78rem; color: var(--ink2); text-decoration: underline; text-decoration-color: var(--hair2); }
.lrow:hover .change, .lrow:focus-within .change { opacity: 1; }
@media (hover: none) { .lrow .change { opacity: 1; } }

.railbottom { display: grid; gap: .8rem; }
.question {
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.25;
  max-width: 26ch;
  min-height: 3.2rem;
  letter-spacing: -.005em;
  transition: opacity .16s var(--ease), filter .16s var(--ease);
}
.question.long { font-size: 1.15rem; }
.question.swap { opacity: 0; filter: blur(2px); }
.question .cursor { display: inline-block; width: .5ch; height: 1em; background: var(--accent); vertical-align: -.1em; margin-left: .1ch; animation: pulse 1.2s var(--ease) infinite; }
.qrule { width: 20ch; height: 1px; background: var(--ghost); }
.field { display: grid; gap: .4rem; }
.field textarea {
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: var(--rMd);
  padding: 14px 16px;
  min-height: calc(1.45rem * 4 + 28px);
  max-height: calc(1.45rem * 8 + 28px);
  resize: none;
  box-shadow: var(--paperTop);
  width: 100%;
  transition: color .16s var(--ease), box-shadow .16s var(--ease);
  caret-color: var(--accent);
}
.field textarea.small { min-height: calc(1.45rem * 2 + 28px); }
.field textarea:focus-visible { box-shadow: var(--paperTop), 0 0 0 2px rgba(185, 58, 44, .45); }
.field textarea.waiting { color: var(--ink3); }
.field textarea.err { box-shadow: var(--paperTop), inset 0 -2px 0 var(--ink); }
.helper { font-size: .78rem; color: var(--ink3); min-height: 1.2em; }
.helper.error { color: var(--ink); font-weight: 500; font-size: .85rem; }
.pills { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  height: 44px;
  padding: 0 1.25rem;
  border-radius: var(--rPill);
  font-size: .95rem;
  font-weight: 500;
  white-space: nowrap;
  transition: transform .12s var(--ease), background-color .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
  border: 1px solid transparent;
}
.pill:active { transform: scale(.97); }
.pill:focus-visible { box-shadow: var(--focus); border-radius: var(--rPill); }
.pill.primary { background: var(--accent); color: var(--accentInk); padding: 0 .55rem 0 1.25rem; box-shadow: 0 6px 22px -10px rgba(185, 58, 44, .5); }
.pill.primary .pip { width: 2rem; height: 2rem; border-radius: var(--rPill); background: rgba(44, 11, 7, .12); display: inline-flex; align-items: center; justify-content: center; transition: transform .16s var(--spring); }
.pill.primary .pip svg.i { width: 1rem; height: 1rem; }
@media (hover: hover) and (pointer: fine) {
  .pill.primary:hover { filter: brightness(.94); }
  .pill.primary:hover .pip { transform: translate(3px, -1px) scale(1.06); }
  .pill.ghost:hover { border-color: var(--hair2); background: var(--paper); }
}
.pill.ghost { border-color: var(--hair); color: var(--ink); background: transparent; }
.pill.ghost.listening { background: var(--accentDim); border-color: transparent; color: var(--ink); animation: pulse 2s var(--ease) infinite; }
.pill:disabled, .pill[aria-disabled="true"] { background: var(--ground2); color: var(--ink3); box-shadow: none; cursor: default; border-color: transparent; filter: none; }
.pill:disabled .pip, .pill[aria-disabled="true"] .pip { background: transparent; transform: none; }
.pill.loading { animation: pulse 1.6s var(--ease) infinite; pointer-events: none; }
.pill.done { background: var(--ground2); color: var(--ink2); box-shadow: none; pointer-events: none; }
.pill .swap { display: inline-block; transition: filter .16s var(--ease), opacity .16s var(--ease); }
.pill.loading .swap { filter: blur(2px); opacity: .7; }

/* Choice pills, keyboard driven so no motion */
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { height: 40px; padding: 0 1rem; border-radius: var(--rPill); border: 1px solid var(--hair); background: var(--paper); font-size: .95rem; color: var(--ink); }
.choice[aria-pressed="true"] { background: var(--accent); color: var(--accentInk); border-color: transparent; }

.railfoot { display: grid; gap: .35rem; font-size: .78rem; color: var(--ink3); }
.railfoot a { color: var(--ink2); }

/* Column level error strip */
.strip { max-width: var(--column); background: var(--paper); border-radius: var(--rMd); padding: 12px 16px; font-weight: 500; display: flex; gap: 1rem; align-items: center; justify-content: space-between; box-shadow: var(--paperTop); border-bottom: 2px solid var(--ink); }
.strip.hidden { display: none; }

/* Live state pulses. Never a spinner. */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.pulsing { animation: pulse 1.6s var(--ease) infinite; }

/* Modal, the fake door */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; background: rgba(23, 32, 26, .35); }
.modalcard {
  width: min(26rem, 100%);
  background: var(--paper);
  border-radius: var(--rLg);
  box-shadow: var(--paperTop), var(--lift);
  padding: 28px;
  display: grid;
  gap: 14px;
  position: relative;
  transform-origin: center;
  animation: pop .26s var(--spring);
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modalcard h2 { font-family: var(--display); font-weight: 500; font-size: 1.4rem; letter-spacing: -.01em; padding-right: 2.5rem; }
.modalcard .close { position: absolute; top: 18px; right: 18px; width: 2rem; height: 2rem; border-radius: var(--rPill); display: inline-flex; align-items: center; justify-content: center; color: var(--ink2); }
.modalcard .close:hover { background: var(--ground2); }
.modalcard form { display: grid; gap: .6rem; }
.modalcard input[type="email"] {
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--ground2); border: 0; border-radius: var(--rMd); padding: 12px 14px; width: 100%;
  caret-color: var(--accent);
}
.modalcard input[type="email"]:focus-visible { box-shadow: 0 0 0 2px rgba(185, 58, 44, .45); }
.modalcard input.err { box-shadow: inset 0 -2px 0 var(--ink); }
.modalcard .content { display: grid; gap: 14px; transition: filter .2s var(--ease), opacity .2s var(--ease); }
.modalcard .content.swap { filter: blur(2px); opacity: .7; }
.donerow { display: flex; gap: .6rem; align-items: flex-start; }
.donerow svg.i { margin-top: .15rem; }

/* Situation stage: heading and field sit together, the foot stays at the bottom */
body[data-stage="situation"] .rail .ledgerwrap { display: none; }
body[data-stage="situation"] .rail { grid-template-rows: auto auto minmax(0, 1fr); }
body[data-stage="situation"] .railfoot { align-self: end; }
body[data-stage="situation"] .railtop { padding-top: 1.5rem; }

/* Mobile: the column is the page, the rail is a paper bottom sheet */
@media (max-width: 1023px) {
  .head { height: 48px; padding: 0 1rem; }
  .frame { grid-template-columns: minmax(0, 1fr); padding: 0 1rem 52dvh; column-gap: 0; }
  .gate { font-size: .72rem; min-height: 36px; }
  :root { --gutter: 2.5rem; }
  .sheet .gutnum { font-size: 2rem; }
  .sheet .gutlabel { display: none; }
  .sheet .gut { padding-top: 18px; }
  .sheet .paper { padding: 16px 16px; min-height: 140px; }
  .sheet.top .paper { margin-left: calc(-1 * var(--gutter) + .6rem); padding-left: calc(16px + var(--gutter) - .6rem); }
  .band { grid-template-columns: 1fr; }
  .answer { padding: 20px; }
  .answerhead { grid-template-columns: 1fr; }
  .answerhead .pill { grid-column: 1; grid-row: auto; justify-self: start; }
  .row { grid-template-columns: minmax(0, 1fr) 2.2rem; }
  .row .k { grid-column: 1; }
  .row .v { grid-column: 1; }
  .row .note { grid-column: 1; }
  .row .copy { grid-column: 2; grid-row: 1; }
  .rail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    height: auto;
    max-height: 45dvh;
    background: var(--paper);
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -18px 44px -22px rgba(23, 32, 26, .45);
    padding: 12px 1rem calc(12px + env(safe-area-inset-bottom));
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: .5rem;
    z-index: 30;
    overflow: auto;
    transition: max-height .3s var(--ease);
  }
  .rail.open { max-height: 80dvh; }
  .rail .grab { width: 2.5rem; height: 4px; border-radius: 4px; background: var(--hair2); margin: 0 auto; }
  .railtop h1 { font-size: 1.15rem; }
  .ledgerwrap { max-height: none; }
  .railtop .ledgerwrap { display: none; }
  .rail.open .railtop .ledgerwrap { display: block; }
  .ledgertoggle { display: inline-flex; gap: .5rem; align-items: center; font-size: .85rem; color: var(--ink2); text-decoration: underline; text-decoration-color: var(--hair2); }
  #ledgerLabel { display: none; }
  .question { font-size: 1.15rem; min-height: 2.6rem; }
  .field textarea { min-height: calc(1.45rem * 3 + 28px); background: var(--ground); }
  .field textarea.small { min-height: calc(1.45rem * 2 + 28px); }
  .railfoot { display: none; }
  .rail.open .railfoot { display: grid; }
  .modalcard { align-self: end; width: 100%; border-radius: 1.25rem 1.25rem 0 0; }
  .modal { align-items: end; padding: 0; }
}
@media (min-width: 1024px) {
  .rail .grab, .ledgertoggle { display: none; }
}

/* Reduced motion: keep opacity and colour, drop travel */
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet .paper, .visa, .pill, .pill .pip, .question, .modalcard, .rail { transition-property: opacity, background-color, color; transition-duration: .2s; }
  .sheet.lifting .paper { animation: none; }
  .visa.filling { clip-path: none; opacity: 0; }
  .modalcard { animation: none; }
  .pill.primary:hover .pip { transform: none; }
  .pulsing, .pill.loading, .pill.ghost.listening, .question .cursor { animation-duration: 2.4s; }
  .lrow .lv.flash { animation: none; }
}

/* Print: the answer sheet reads black on white with the gate first */
@media print {
  .head, .rail, .gate, .colhead, .case, .modal { display: none !important; }
  .frame { display: block; padding: 0; }
  .answer { box-shadow: none; border: 1px solid #000; }
  body { background: #fff; color: #000; }
}
