/* ============================================================
   Hixogram — stylesheet
   ------------------------------------------------------------
   Visual language: a highlighter-yellow page, near-black "ink",
   warm paper cards, pill-shaped controls, a bold grotesque for
   headings and a monospace for small labels, plus a family of
   pastel "driver" colours used to tell things apart at a glance.
   ============================================================ */

/* Both faces are variable fonts (SIL Open Font License), so one file
   covers every weight. build-artifact.js inlines them as data URIs. */
@font-face{
  font-family:'Bricolage Grotesque';
  font-style:normal; font-weight:200 800; font-display:swap;
  src:url("../fonts/bricolage-grotesque-latin.woff2") format('woff2');
}
@font-face{
  font-family:'Geist Mono';
  font-style:normal; font-weight:100 900; font-display:swap;
  src:url("../fonts/geist-mono-latin.woff2") format('woff2');
}
/* The Hixogram wordmark only (Dx Lactos, Dirtyline Studio). Nothing else
   uses it. block, not swap: a brand name should not flash up in another face. */
@font-face{
  font-family:'Dx Lactos';
  font-style:normal; font-weight:400; font-display:block;
  src:url("../fonts/dxlactos-regular-free-personal-use.otf") format('opentype');
}

:root{
  color-scheme: light;

  --bg:            #fff48d;   /* the page itself — highlighter yellow */
  --surface:       #fffcf0;   /* paper */
  --surface-2:     #faf6e2;
  --surface-3:     #f2edd0;
  --border:        #e6dfbf;   /* hairlines inside cards */
  --border-strong: #c8c0a0;   /* inputs, chips */
  --line:          #0e0e0c;   /* structural outlines: cards, panels, dividers */
  --text:          #0e0e0c;
  --text-2:        #3a3a30;
  --muted:         #6c6c5e;

  --accent:        #0e0e0c;   /* ink is the accent on yellow */
  --accent-soft:   #fff48d;   /* highlighter */
  --accent-text:   #fff48d;
  --hover:         rgba(14,14,12,.07);

  /* the driver palette — one pastel per character */
  --dot:           #fff48d;   /* yellow */
  --fuzz:          #a3b1ff;   /* periwinkle */
  --echo:          #c9e9f6;   /* ice */
  --vortex:        #8ed8ff;   /* sky */
  --bit:           #a9e8ae;   /* mint */
  --puff:          #ffc0dd;   /* candy pink */
  --halo:          #ffd9a0;   /* peach */
  --spike:         #ffafa3;   /* coral */
  --spike-hot:     #ff6f5e;   /* coral turned up, for must-not-miss on ink */

  --pos:           #1c7646;
  --pos-soft:      #dcf2e3;
  --neg:           #5b5b50;
  --neg-soft:      #eeebdc;
  --flag:          #c0261c;
  --flag-soft:     #ffe4de;
  --warn:          #8a5700;
  --warn-soft:     #ffe8b0;

  /* completion colour of the full-width strip under the title bar */
  --done:          #8ed8ff;   /* Vortex sky */

  --radius:   20px;
  --radius-s: 11px;
  --pill:     100px;
  --shadow:   none;
  --bounce:   cubic-bezier(.34,1.56,.64,1);
  --ease:     cubic-bezier(.16,1,.3,1);
  --rail-w:   252px;
  --rail-r:   324px;
  --pad:      22px;       /* outer padding of the three-column shell */
  --gap:      22px;       /* space between the columns */
  --mast-h:   84px;       /* title bar + progress strip, for sticky offsets */

  --font: 'Bricolage Grotesque', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*{ box-sizing:border-box; }

/* A class that sets `display` outranks the UA rule for [hidden],
   so state it explicitly — the modal and the red-flag bar rely on it. */
[hidden]{ display:none !important; }

html,body{ margin:0; padding:0; }

/* Scroll areas scroll, but no scrollbar is ever drawn — in any layout. */
*{ scrollbar-width:none; -ms-overflow-style:none; }
*::-webkit-scrollbar{ display:none; width:0; height:0; }

/* A stray wide child must never make the whole page scroll sideways —
   on a phone that makes every field hard to reach. */
html{ overflow-x:hidden; background:var(--bg); }
body{ overflow-x:hidden; max-width:100%; }
body{
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
  font-size:14.5px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
::selection{ background:var(--text); color:var(--bg); }

h1,h2,h3,h4{ margin:0; font-weight:700; letter-spacing:-.02em; }
p{ margin:0 0 .6em; }
.muted{ color:var(--muted); }

/* small monospace label — the "( Section )" voice */
.mono-label, .nav-group-title, .cx-group-title, .rail-card-head h3,
.why-body h4, .ddx-table th, .page-eyebrow{
  font-family:var(--mono); font-weight:500;
  text-transform:uppercase; letter-spacing:.13em;
}

/* ---------------- masthead: title bar + progress strip ---------------- */
.masthead{ position:sticky; top:0; z-index:40; }
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; padding:10px 18px;
  background:var(--bg);
  border-bottom:2px solid var(--line);
}
.brand{ display:flex; align-items:center; gap:10px; min-width:0; }
/* the wordmark: "Hixogram" in Dx Lactos, ink on the page */
.brand-name{
  font-family:'Dx Lactos', var(--font);
  font-weight:400; font-size:32px; line-height:1;
  letter-spacing:0; white-space:nowrap; color:var(--text);
}
/* the brand's asterisk, kept from the original wordmark: in the app's own
   grotesque, not the wordmark face. Decorative, so screen readers skip it. */
.brand-name::after{
  content:"*"; content:"*" / "";
  font-family:var(--font); font-weight:800;
  margin-left:1px;
}
.topbar-actions{ display:flex; align-items:center; gap:6px; flex-wrap:nowrap; justify-content:flex-end; }

/* the signed-in user: avatar, first name, a caret; opens a small menu.
   Deliberately still: no hover lift, no transition. */
.profile{ position:relative; flex:none; }
.profile-btn{
  display:inline-flex; align-items:center; gap:8px;
  padding:3px 11px 3px 3px; margin-left:4px;
  border:1.5px solid var(--line); border-radius:var(--pill);
  background:var(--surface); color:var(--text);
  font:inherit; font-size:13.4px; font-weight:650; line-height:1;
  cursor:pointer; transition:none; transform:none;
}
.profile-btn:hover, .profile-btn[aria-expanded="true"]{ background:var(--surface-3); }
.profile-btn:focus-visible{ outline:2.5px solid var(--text); outline-offset:3px; }
.profile-avatar{
  flex:none; width:32px; height:32px; border-radius:50%; overflow:hidden;
  border:2px solid var(--line);
  display:grid; place-items:center;
  background:var(--accent); color:var(--accent-text);
  font-size:12px; font-weight:750; letter-spacing:.02em;
}
.profile-avatar img, .profile-avatar svg{ width:100%; height:100%; object-fit:cover; display:block; }
.profile-name{ max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.profile-caret{ width:12px; height:12px; flex:none; }
.profile-menu{
  position:absolute; right:0; top:calc(100% + 8px); z-index:60;
  width:max-content; min-width:230px; max-width:min(320px, calc(100vw - 24px));
  padding:6px; background:var(--surface);
  border:2px solid var(--line); border-radius:16px; box-shadow:5px 5px 0 var(--line);
}
.profile-who{
  display:flex; flex-direction:column; gap:3px; min-width:0;
  padding:9px 11px 11px; margin-bottom:6px; border-bottom:1.5px solid var(--border);
}
.profile-who strong{ font-size:14px; overflow-wrap:anywhere; }
.profile-who span{ font-family:var(--mono); font-size:11px; color:var(--muted); overflow-wrap:anywhere; }
.profile-menu button{
  display:block; width:100%; text-align:left;
  padding:9px 11px; border:0; border-radius:10px;
  background:transparent; color:var(--text);
  font:inherit; font-size:13.6px; font-weight:600; cursor:pointer;
}
.profile-menu button:hover, .profile-menu button:focus-visible{ background:var(--hover); outline:none; }

/* Overall completion, full width, one solid fill. */
.top-progress{
  position:relative; height:26px; overflow:hidden;
  background:var(--surface);
  border-bottom:2px solid var(--line);
}
.top-progress-fill{
  position:absolute; left:0; top:0; bottom:0; width:0;
  background:var(--done);
  transition:width .6s var(--ease);
}
.top-progress-label{
  position:relative; z-index:1;
  display:flex; align-items:center; height:100%; padding:0 18px;
  font-family:var(--mono); font-size:10.5px; font-weight:600;
  letter-spacing:.12em; text-transform:uppercase; color:var(--text);
  white-space:nowrap;
}

/* ---------------- buttons ---------------- */
.btn{
  font:inherit; font-size:13.4px; font-weight:650;
  padding:7px 15px; border-radius:var(--pill);
  border:1.5px solid var(--text);
  background:var(--surface); color:var(--text);
  cursor:pointer; white-space:nowrap;
  transition:background .15s, border-color .15s, color .15s, transform .4s var(--bounce);
}
.btn:hover{ background:var(--surface-3); transform:scale(1.04); }
.btn:active{ transform:scale(.97); }
.btn:focus-visible{ outline:2.5px solid var(--text); outline-offset:3px; }
.btn-primary{ background:var(--accent); border-color:var(--accent); color:var(--accent-text); }
.btn-primary:hover{ background:var(--accent); transform:scale(1.05) rotate(-1.5deg); }
.btn-ghost{ background:transparent; border-color:transparent; color:var(--text); }
.btn-ghost:hover{ background:var(--hover); color:var(--text); transform:none; }
.btn-mini{ font-size:11.5px; padding:3px 11px; border-width:1.5px; }
.btn[disabled]{ opacity:.5; cursor:not-allowed; transform:none; }

/* ---------------- layout ---------------- */
.shell{
  display:grid;
  grid-template-columns:var(--rail-w) minmax(0,1fr) var(--rail-r);
  gap:var(--gap);
  padding:var(--pad);
  align-items:start;
  max-width:1680px; margin:0 auto;
}
.rail{ position:sticky; top:calc(var(--mast-h) + 18px); max-height:calc(100vh - var(--mast-h) - 36px); overflow-y:auto; }
.main{ min-width:0; }
/* wraps .main + .rail-right; adds no box of its own except on tablets */
.workcol{ display:contents; }

/* ---------------- step nav ---------------- */
/* "[ HISTORY ]" etc.: full ink, brackets included (they inherit it) */
.nav-group-title{
  font-size:10.5px; color:var(--text); padding:14px 12px 6px;
}
.nav-group-title::before{ content:"[ "; }
.nav-group-title::after{ content:" ]"; }
.nav-item{
  display:flex; align-items:center; gap:10px;
  width:100%; text-align:left;
  padding:7px 12px; margin-bottom:2px;
  border:0; border-radius:var(--pill);
  background:transparent; color:var(--text);
  font:inherit; font-size:13.6px; font-weight:520; cursor:pointer;
  transition:background .15s, color .15s;
}
.nav-item:hover{ background:var(--hover); }
.nav-item.active{ background:var(--accent); color:var(--accent-text); font-weight:680; }
.nav-num{
  flex:none; width:21px; height:21px; border-radius:50%;
  display:grid; place-items:center;
  font-family:var(--mono); font-size:10.5px; font-weight:600;
  border:1.5px solid currentColor; color:var(--text-2);
}
.nav-item.active .nav-num{ background:var(--accent-text); border-color:var(--accent-text); color:var(--accent); }
.nav-item.done .nav-num{ background:var(--bit); border-color:var(--line); color:var(--text); }
.nav-label{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-count{ font-family:var(--mono); font-size:10.5px; opacity:.7; font-variant-numeric:tabular-nums; }
.nav-item.has-flag .nav-label::after{ content:" \25CF"; color:var(--flag); }
.nav-item.active.has-flag .nav-label::after{ color:var(--spike-hot); }

/* ---------------- cards ---------------- */
.card{
  background:var(--surface);
  border:2px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  margin-bottom:18px;
  overflow:hidden;
}
.card-head{
  display:flex; align-items:flex-start; gap:12px;
  padding:15px 18px 13px;
  border-bottom:1.5px solid var(--border);
  background:transparent;
}
.card-head h2{ font-size:18px; letter-spacing:-.025em; line-height:1.15; }
.card-head h3{ font-size:15px; }
.card-head-main{ flex:1; min-width:0; }
.card-sub{ font-size:12.8px; color:var(--text-2); margin:4px 0 0; }
.card-body{ padding:6px 18px 16px; }
.card-actions{ display:flex; gap:6px; align-items:center; flex:none; }

/* page heading — mono eyebrow over a big grotesque title */
.page-head{ margin:4px 0 22px; position:relative; }
.page-eyebrow{
  display:flex; align-items:center; gap:10px;
  font-size:11px; color:var(--text); margin-bottom:12px;
}
.page-eyebrow .dot{
  width:8px; height:8px; border-radius:50%; background:var(--text);
  animation:blink 1.5s step-end infinite;
}
.page-head h1{
  font-size:clamp(28px,3.2vw,42px); font-weight:760;
  line-height:1; letter-spacing:-.045em;
  margin-bottom:12px;
}
.page-head.enter > *{ animation:rise .7s var(--ease) both; }
.page-head.enter > *:nth-child(2){ animation-delay:.06s; }
.page-head.enter > *:nth-child(3){ animation-delay:.12s; }
.page-head p{ color:var(--text-2); font-size:14.6px; font-weight:500; margin-top:4px; }

@keyframes blink{ 0%,49%{ opacity:1; } 50%,100%{ opacity:0; } }
@keyframes rise{ from{ opacity:0; transform:translateY(14px); } to{ opacity:1; transform:none; } }
/* movement only — a dialog or a toast must never depend on an
   animation finishing to become visible */
@keyframes pop{ from{ transform:translateY(12px) scale(.985); } to{ transform:none; } }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* ---------------- question rows ---------------- */
.q{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px 14px;
  align-items:center;
  padding:10px 0;
  border-bottom:1.5px solid var(--border);
}
.q:last-child{ border-bottom:0; }
/* a question answered as a red flag carries a stripe in the red-flag
   panel's own coral */
.q.flagged{ box-shadow:inset 6px 0 0 var(--spike); padding-left:14px; }
.q-main{ min-width:0; }
.q-label{ font-size:14.2px; font-weight:560; display:flex; align-items:baseline; gap:7px; flex-wrap:wrap; }
.q-ask{ font-size:12.8px; color:var(--muted); font-style:italic; margin-top:2px; }
.q-ctrl{ display:flex; align-items:center; gap:6px; justify-content:flex-end; flex-wrap:wrap; }

.tag{
  font-family:var(--mono); font-size:9.6px; font-weight:600; letter-spacing:.1em; text-transform:uppercase;
  padding:2px 8px; border-radius:var(--pill); white-space:nowrap;
  border:1.2px solid currentColor;
}
.tag-flag{ background:var(--spike); color:var(--text); }
.tag-rf{ background:var(--halo); color:var(--text); }
.tag-ai{ background:var(--fuzz); color:var(--text); }
.tag-key{ background:var(--accent-soft); color:var(--text); }
.tag-draft{ background:var(--echo); color:var(--text); }
.tag-finished{ background:var(--bit); color:var(--text); }

.why-btn{
  flex:none; width:19px; height:19px; border-radius:50%;
  border:1.5px solid var(--text); background:transparent;
  color:var(--text); font-size:10.5px; font-weight:800;
  cursor:pointer; line-height:1; padding:0;
  display:inline-grid; place-items:center;
  transition:transform .35s var(--bounce), background .15s;
}
.why-btn:hover{ background:var(--accent); border-color:var(--accent); color:var(--accent-text); transform:scale(1.15) rotate(-8deg); }

/* Segmented yes / no / n-a. Each answer wears its own driver colour —
   mint for yes, periwinkle for no, ice for not applicable. A yes that
   is a red flag looks like any other yes; the row's coral stripe and
   the red-flag panel carry the warning. */
.seg{ display:inline-flex; border:1.5px solid var(--text); border-radius:var(--pill); overflow:hidden; background:var(--surface); }
.seg button{
  font:inherit; font-size:12.6px; font-weight:600;
  padding:4px 13px; border:0; border-right:1.5px solid var(--text);
  background:transparent; color:var(--text-2); cursor:pointer;
  transition:background .15s, color .15s;
}
.seg button:last-child{ border-right:0; }
.seg button:hover{ background:var(--hover); color:var(--text); }
.seg button.on-yes,
.seg button.on-flag{ background:var(--bit); color:var(--text); font-weight:750; }
.seg button.on-no{ background:var(--fuzz); color:var(--text); font-weight:750; }
.seg button.on-na{ background:var(--echo); color:var(--text); font-weight:750; }

select.inp, input.inp, textarea.inp{
  font:inherit; font-size:13.6px;
  padding:6px 11px; border-radius:var(--radius-s);
  border:1.5px solid var(--border-strong);
  background:var(--surface); color:var(--text);
  max-width:100%;
  transition:border-color .15s, box-shadow .15s;
}
select.inp{ min-width:150px; cursor:pointer; }
input.inp{ min-width:90px; }
input.inp.w-s{ width:80px; }
input.inp.w-m{ width:140px; }
input.inp.w-l{ width:230px; }
textarea.inp{ width:100%; min-height:78px; resize:none; line-height:1.55; }
.inp:hover{ border-color:var(--text-2); }
.inp:focus{ outline:none; border-color:var(--text); box-shadow:0 0 0 4px var(--accent-soft); }
.unit{ font-family:var(--mono); font-size:11.5px; color:var(--muted); }

.chips{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.chip{
  font:inherit; font-size:12.6px; font-weight:560;
  padding:4px 12px; border-radius:var(--pill);
  border:1.5px solid var(--border-strong); background:var(--surface);
  color:var(--text-2); cursor:pointer;
  transition:transform .35s var(--bounce), background .15s, border-color .15s;
}
.chip:hover{ border-color:var(--text); color:var(--text); transform:translateY(-1px); }
.chip.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-text); font-weight:650; }

.scale{ display:flex; align-items:center; gap:10px; }
.scale input[type=range]{ width:150px; accent-color:var(--text); }
.scale-val{ font-family:var(--mono); font-variant-numeric:tabular-nums; font-weight:700; min-width:26px; text-align:right; }

/* free-text block at the end of a section */
.freetext{ padding:14px 0 2px; border-top:1.5px dashed var(--border-strong); margin-top:6px; }
.freetext label{ display:block; font-size:13px; font-weight:650; color:var(--text); margin-bottom:6px; }
.freetext .hint{ font-size:12px; color:var(--muted); font-weight:450; margin-left:6px; }

/* ---------------- why panel ---------------- */
.why-body h4{ font-size:10.5px; color:var(--text-2); margin:18px 0 6px; }
.why-body h4::before{ content:"✦ "; }
.why-body h4:first-child{ margin-top:0; }
.why-body p{ font-size:14px; line-height:1.62; color:var(--text); }
.why-q{
  background:var(--accent-soft); color:var(--text);
  border:1.5px solid var(--line);
  padding:12px 15px; border-radius:var(--radius-s);
  font-style:italic; font-weight:500; margin-bottom:6px;
}
.why-ddx{ list-style:none; padding:0; margin:0; }
.why-ddx li{
  display:grid; grid-template-columns:58px 1fr; gap:10px;
  padding:7px 0; border-bottom:1.5px solid var(--border); font-size:13.6px;
}
.why-ddx li:last-child{ border-bottom:0; }
.why-dir{ font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.08em; text-transform:uppercase; padding-top:2px; }
.why-dir.up{ color:var(--pos); }
.why-dir.down{ color:var(--neg); }
.why-ref{
  margin-top:18px; padding-top:11px; border-top:1.5px dashed var(--border-strong);
  font-size:12.4px; color:var(--muted);
}

/* ---------------- red flag bar ---------------- */
/* Spike's coral panel; each recorded flag is a paper pill that jumps
   to its question. */
.redflag-bar{
  background:var(--spike); border:2px solid var(--line);
  border-radius:var(--radius); padding:14px 17px 15px; margin-bottom:18px;
  box-shadow:5px 5px 0 var(--line);
}
.redflag-bar h3{
  font-family:var(--mono); font-weight:700; font-size:11.5px; color:var(--text);
  text-transform:uppercase; letter-spacing:.12em; margin-bottom:10px;
  display:flex; align-items:center; gap:9px;
}
.redflag-bar h3::before{
  content:""; width:10px; height:10px; border-radius:50%;
  background:var(--flag); box-shadow:0 0 0 2px var(--surface);
  animation:blink 1.2s step-end infinite;
}
.redflag-bar ul{ list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:7px; }
.redflag-bar li{ margin:0; }
.redflag-bar li > .gap-item{
  display:inline-flex !important; align-items:center; gap:6px;
  padding:5px 13px !important; border-radius:var(--pill);
  background:var(--surface); border:1.5px solid var(--line);
  color:var(--text); font-weight:600; font-size:13px;
  transition:transform .35s var(--bounce), background .15s;
}
.redflag-bar li > .gap-item::before{ content:"!"; font-weight:800; color:var(--flag); }
.redflag-bar li > .gap-item:hover{ background:var(--dot); transform:translateY(-1px) rotate(-.6deg); }

/* ---------------- right rail ---------------- */
.rail-card{
  background:var(--surface); border:2px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow);
  margin-bottom:16px; overflow:hidden;
}
.rail-card-head{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:11px 15px; border-bottom:1.5px solid var(--border); background:transparent;
}
.rail-card-head h3{ font-size:10.5px; color:var(--text-2); display:flex; align-items:center; gap:8px; }
.rail-card-head h3::before{ content:""; width:7px; height:7px; border-radius:50%; background:currentColor; flex:none; }
.ddx-live, .ix-live{ padding:12px 15px 14px; }
.disclaimer{ font-size:11.2px; color:var(--muted); padding:0 15px 13px; margin:0; line-height:1.45; }

/* The working differential: every diagnosis wears a driver colour, on
   bars outlined in ink so the paler ones still read on paper.
   Must-not-miss diagnoses are always hot coral. */
.ddx-row{ --c:var(--dot); margin-bottom:12px; cursor:pointer; }
.ddx-row:hover .ddx-name{ text-decoration:underline; text-underline-offset:3px; }
.ddx-row.c0{ --c:var(--dot); }
.ddx-row.c1{ --c:var(--fuzz); }
.ddx-row.c2{ --c:var(--vortex); }
.ddx-row.c3{ --c:var(--bit); }
.ddx-row.c4{ --c:var(--halo); }
.ddx-row.c5{ --c:var(--puff); }
.ddx-row.mustnotmiss{ --c:var(--spike-hot); }
.ddx-row:last-child{ margin-bottom:0; }
.ddx-top{ display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.ddx-name{ font-size:13.6px; font-weight:620; }
.ddx-name .mnm{ color:var(--flag); font-weight:800; }
.ddx-pc{
  flex:none; font-family:var(--mono); font-size:10.5px; font-weight:700;
  font-variant-numeric:tabular-nums;
  background:var(--c); color:var(--text);
  border:1.2px solid var(--line);
  padding:0 7px; border-radius:var(--pill);
}
.ddx-bar{ height:10px; border-radius:var(--pill); background:var(--surface); border:1.5px solid var(--line); margin-top:5px; overflow:hidden; }
.ddx-bar span{ display:block; height:100%; background:var(--c); transition:width .5s var(--ease); }

.gap-item{
  display:block; width:100%; text-align:left;
  font:inherit; font-size:13px; color:var(--text-2);
  background:transparent; border:0; border-radius:var(--radius-s);
  padding:5px 8px; cursor:pointer;
}
.gap-item:hover{ background:var(--accent-soft); color:var(--text); }
.gap-item b{ color:var(--flag); }
/* a wrapped item in a bulleted list keeps its bullet on the first line */
li > .gap-item{ vertical-align:top; }

/* Further investigations: one row per working differential, name | test
   count; the row opens the tests that would confirm it */
.ix-row{
  display:flex; align-items:baseline; justify-content:space-between; gap:10px;
  width:100%; text-align:left; font:inherit; color:var(--text);
  background:transparent; border:0; border-bottom:1.5px dashed var(--border);
  padding:8px 4px; cursor:pointer;
}
.ix-row:last-child{ border-bottom:0; }
.ix-row:hover:not([disabled]) .ix-name{ text-decoration:underline; text-underline-offset:3px; }
.ix-row[disabled]{ cursor:default; opacity:.55; }
.ix-name{ font-size:13.6px; font-weight:620; min-width:0; }
.ix-name .mnm{ color:var(--flag); font-weight:800; }
.ix-count{
  flex:none; font-family:var(--mono); font-size:10.5px; font-weight:700;
  font-variant-numeric:tabular-nums; color:var(--text-2);
  border:1.2px solid var(--line); padding:0 7px; border-radius:var(--pill);
}
.why-body .flagline{ color:var(--flag); font-weight:650; }

/* Sharing: what came in and what went out, above the records */
.share-row{ display:flex; gap:12px; align-items:flex-start; justify-content:space-between; padding:10px 0; border-bottom:1.5px dashed var(--border); }
.share-row:last-child{ border-bottom:0; }
.share-row.unread .share-title{ font-weight:750; }
.share-main{ min-width:0; }
.share-title{ font-size:14px; font-weight:620; display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.share-meta{ font-size:12px; color:var(--muted); margin-top:2px; }
.share-note{ font-size:13px; color:var(--text-2); margin-top:4px; font-style:italic; }
.share-acts{ display:flex; gap:6px; flex:none; flex-wrap:wrap; justify-content:flex-end; }
.share-sent > summary{ cursor:pointer; list-style:none; }
.share-sent > summary::-webkit-details-marker{ display:none; }
.share-dialog .inp{ width:100%; }
.share-people{ max-height:260px; overflow-y:auto; margin:10px 0 12px; border:1.5px solid var(--border); border-radius:var(--radius-s); }
.share-person{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left; font:inherit; font-size:14px;
  background:transparent; border:0; border-bottom:1px solid var(--border); padding:7px 10px; cursor:pointer; color:var(--text);
}
.share-person:last-child{ border-bottom:0; }
.share-person:hover{ background:var(--hover); }
.share-person.on{ background:var(--accent-soft); font-weight:700; }
.share-avatar{ width:32px; height:32px; flex:none; display:inline-flex; }
.share-label{ display:block; font-size:12.8px; font-weight:650; margin-bottom:4px; }
@media (max-width: 600px){
  .share-row{ flex-direction:column; }
  .share-acts{ justify-content:flex-start; }
}

/* Investigation pathway: numbered boxes joined by arrows, each arrow
   carrying the finding that leads to the next step */
.ixflow{ list-style:none; padding:0; margin:6px 0 0; }
.ixflow-step{
  border:2px solid var(--line); border-radius:var(--radius-s); background:var(--surface);
  padding:9px 12px 8px; box-shadow:3px 3px 0 var(--line);
}
.ixflow-head{ display:flex; align-items:center; gap:8px; font-weight:700; font-size:13.4px; margin-bottom:4px; }
.ixflow-num{
  flex:none; width:22px; height:22px; border-radius:50%; display:grid; place-items:center;
  font-family:var(--mono); font-size:11px; background:var(--fuzz); border:1.5px solid var(--line);
}
.ixflow-tests{ margin:0; padding-left:20px; }
.ixflow-tests li{ font-size:13.4px; line-height:1.5; }
.ixflow-arrow{
  position:relative; margin:0 0 0 22px; padding:8px 0 8px 18px;
  border-left:2.5px solid var(--line); font-size:12.6px; color:var(--text-2); font-style:italic;
}
.ixflow-arrow:not(.end)::after{
  content:""; position:absolute; left:-7px; bottom:-2px;
  border:6px solid transparent; border-top:8px solid var(--line); border-bottom:0;
}
.ixflow-arrow.end{ border-left-style:dashed; font-style:normal; color:var(--text); }

/* Template community (js/community/community.js): the full template,
   suggestions with votes, the discussion */
.tag-community{ background:var(--bit); color:var(--text); }
.cm-bar{ display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px 16px; }
.cm-bar .out-tabs{ margin:0; }
.cm-pick{ display:flex; flex-direction:column; gap:4px; flex:1 1 240px; min-width:0; }
.cm-pick .inp{ width:100%; }
.cm-bar > p{ flex-basis:100%; margin:0; font-size:13px; }
.cm-h{ font-size:18px; margin:0 0 4px; }
.cm-sources{ margin-top:10px; }
.cm-sources ul{ margin:4px 0 0; padding-left:20px; font-size:13px; color:var(--text-2); }
.cm-item{ display:flex; gap:12px; align-items:flex-start; justify-content:space-between; padding:10px 0; border-bottom:1.5px dashed var(--border); }
.cm-item:last-child{ border-bottom:0; }
.cm-item.retired .cm-item-main{ opacity:.5; text-decoration:line-through; }
.cm-item-main{ min-width:0; flex:1; }
.cm-item-label{ font-size:14px; font-weight:620; display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.cm-item-meta{ font-size:12px; color:var(--muted); margin-top:3px; overflow-wrap:anywhere; }
.cm-item-acts{ display:flex; gap:6px; flex:none; flex-wrap:wrap; justify-content:flex-end; }
.cm-ddx{ padding:12px 0; border-bottom:1.5px dashed var(--border); }
.cm-ddx:last-child{ border-bottom:0; }
.cm-ddx-head{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; font-size:14.4px; }
.cm-ddx-head .btn{ margin-left:auto; }
.cm-note{ font-size:13px; margin:4px 0 0; }
.cm-sugg-body{ display:flex; gap:14px; align-items:flex-start; }
.cm-vote{ display:flex; flex-direction:column; align-items:center; gap:2px; flex:none; width:40px; }
.cm-vote-btn{
  width:34px; height:28px; border:1.5px solid var(--line); border-radius:var(--radius-s); background:var(--surface);
  color:var(--text); font-size:12px; cursor:pointer;
}
.cm-vote-btn:hover:not(:disabled){ background:var(--surface-3); }
.cm-vote-btn.on{ background:var(--accent); color:var(--accent-text); }
.cm-vote-btn:disabled{ opacity:.4; cursor:default; }
.cm-score{ font-family:var(--mono); font-size:15px; font-weight:700; }
.cm-sugg-main{ min-width:0; flex:1; }
.cm-sugg-title{ font-size:14.4px; font-weight:650; display:flex; gap:6px; align-items:center; flex-wrap:wrap; overflow-wrap:anywhere; }
.cm-open{ background:var(--echo); }
.cm-approved{ background:var(--bit); }
.cm-rejected, .cm-reverted{ background:var(--spike); }
.cm-rationale{ font-size:13px; color:var(--text-2); margin:6px 0 0; white-space:pre-wrap; }
.cm-admin-note{ font-size:13px; margin:6px 0 0; padding:6px 10px; border-left:3px solid var(--line); background:var(--surface-2); }
.cm-detail p{ white-space:pre-wrap; }
.cm-thread{ display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.cm-comment{ padding:8px 10px; border:1.5px solid var(--border); border-radius:var(--radius-s); background:var(--surface-2); }
.cm-comment p{ margin:4px 0; font-size:13.4px; }
.cm-post{ display:flex; gap:8px; align-items:flex-end; }
.cm-post .inp{ flex:1; min-width:0; }
.cm-form .ai-card-use{ display:flex; align-items:center; gap:6px; margin-bottom:14px; font-size:13.4px; }
@media (max-width: 600px){
  .cm-item{ flex-direction:column; }
  .cm-item-acts{ justify-content:flex-start; }
  .cm-ddx-head .btn{ margin-left:0; }
  .cm-post{ flex-direction:column; align-items:stretch; }
}

/* ---------------- step foot ---------------- */
.step-foot{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:16px 2px 34px;
}
.step-foot .btn{ padding:10px 22px; font-size:14px; }
.step-foot-mid{ font-family:var(--mono); font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--text-2); }

/* ---------------- complaint picker ---------------- */
.cx-search{ width:100%; font-size:15.5px; padding:12px 16px; margin-bottom:14px; border-radius:var(--pill) !important; }
.cx-group-title{ font-size:11px; color:var(--text-2); margin:18px 0 9px; }
.cx-group-title::before{ content:"( "; }
.cx-group-title::after{ content:" )"; }
.cx-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(228px,1fr)); gap:10px; }
.cx-card{
  text-align:left; font:inherit; cursor:pointer; color:var(--text);
  border:1.5px solid var(--border-strong); border-radius:14px;
  background:var(--surface); padding:12px 14px;
  transition:transform .4s var(--bounce), border-color .15s, background .15s;
}
.cx-card:hover{ border-color:var(--text); transform:translateY(-2px) rotate(-.5deg); }
.cx-card.on{ border:2px solid var(--line); background:var(--accent-soft); padding:11.5px 13.5px; }
.cx-card-name{ font-size:14.2px; font-weight:680; letter-spacing:-.01em; display:flex; justify-content:space-between; gap:8px; }
.cx-card-name .tick{
  flex:none; width:20px; height:20px; border-radius:50%; display:grid; place-items:center;
  background:var(--text); color:var(--bg); font-size:11px; font-weight:800;
}
.cx-card-sub{ font-size:12.2px; color:var(--text-2); margin-top:4px; line-height:1.4; }

/* ---------------- repeating groups (previous pregnancies) ---------------- */
.rep-item{
  border:1.5px solid var(--border-strong); border-radius:14px;
  padding:13px 15px; margin-bottom:10px; background:var(--surface-2);
}
.rep-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:9px; }
.rep-head h4{ font-size:14px; }
.rep-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:10px 12px; }
.rep-field label{ display:block; font-size:12px; color:var(--text-2); font-weight:600; margin-bottom:4px; }
.rep-field .inp{ width:100%; }

/* ---------------- output / report ---------------- */
.out-tabs{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:16px; }
.out-tab{
  font:inherit; font-size:13.4px; font-weight:620;
  padding:7px 15px; border-radius:var(--pill);
  border:1.5px solid var(--text); background:transparent;
  color:var(--text); cursor:pointer;
  transition:transform .4s var(--bounce), background .15s;
}
.out-tab:hover{ background:var(--hover); transform:translateY(-1px); }
.out-tab.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-text); }

.report{
  background:var(--surface); border:2px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow);
  padding:28px 32px;
}
.report h2{
  font-family:var(--mono); font-weight:600;
  font-size:11.5px; text-transform:uppercase; letter-spacing:.13em;
  color:var(--text); margin:26px 0 9px; padding-bottom:7px;
  border-bottom:2px solid var(--line);
}
.report h2::before{ content:"✦ "; }
.report h2:first-child{ margin-top:0; }
.report h3{ font-size:14.4px; margin:14px 0 4px; }
.report p{ font-size:14.4px; line-height:1.68; margin:0 0 9px; }
.report ul, .report ol{ margin:0 0 10px; padding-left:22px; }
.report li{ font-size:14.4px; line-height:1.6; margin-bottom:3px; }
.report .kv{ display:grid; grid-template-columns:150px 1fr; gap:3px 12px; font-size:14px; margin-bottom:10px; }
.report .kv dt{ color:var(--text-2); font-weight:650; }
.report .kv dd{ margin:0; }
.report .neg-string{ color:var(--text-2); }
.report .placeholder{ color:var(--muted); font-style:italic; }
.report .flagline{ color:var(--flag); font-weight:650; }

/* ---------------- example patient (js/patient/) ---------------- */
.pt-host{ margin:4px 0 22px; }
.pt-loading{
  border:2px solid var(--line); border-radius:var(--radius); background:var(--surface-2);
  min-height:380px; display:grid; place-items:center; margin:0;
  font-family:var(--mono); font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--muted);
}
.pt-legend-card h3{
  font-family:var(--mono); font-weight:600; font-size:11px;
  text-transform:uppercase; letter-spacing:.12em; color:var(--text-2);
  margin:16px 0 4px;
}
.pt-legend-card h3:first-child{ margin-top:4px; }
.pt-legend-card h3::before{ content:"( "; }
.pt-legend-card h3::after{ content:" )"; }
.pt-legend-card .pt-legend li{ font-size:14.2px; line-height:1.45; }
.pt-stage{
  border:2px solid var(--line); border-radius:var(--radius);
  background:var(--surface-2); overflow:hidden;
}
.pt-tools{
  display:flex; flex-wrap:wrap; gap:6px; align-items:center;
  padding:10px 12px; border-bottom:1.5px solid var(--line); background:var(--surface);
}
.pt-tools-gap{ flex:1; }
.pt-canvas{
  position:relative; height:min(620px, 72vh); min-height:380px;
  touch-action:none; cursor:grab;
}
.pt-canvas:active{ cursor:grabbing; }
.pt-canvas canvas{ display:block; width:100%; height:100%; outline:none; }
.pt-leaders{ position:absolute; inset:0; pointer-events:none; overflow:visible; }
.pt-leader{ stroke:var(--line); stroke-width:1.5; }
.pt-leader.flag{ stroke:var(--flag); }
.pt-labels{ position:absolute; inset:0; pointer-events:none; }
.pt-label{
  position:absolute; left:0; top:0; max-width:46%;
  display:flex; align-items:center; gap:6px;
  padding:3px 10px 3px 3px; border-radius:var(--pill);
  background:var(--surface); border:1.5px solid var(--line);
  font-size:12.2px; font-weight:620; line-height:1.2; white-space:nowrap;
  transition:opacity .2s;
}
.pt-label.flag{ border-color:var(--flag); box-shadow:3px 3px 0 var(--flag); }
.pt-label-text{ overflow:hidden; text-overflow:ellipsis; }
.pt-label-num, .pt-chip{
  flex:none; width:20px; height:20px; border-radius:50%;
  display:grid; place-items:center;
  border:1.5px solid var(--line); color:var(--text);
  font-family:var(--mono); font-size:10.5px; font-weight:700;
}
.pt-status{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  font-family:var(--mono); font-size:11px; letter-spacing:.12em; text-transform:uppercase;
  color:var(--muted); text-align:center; max-width:80%;
}
.pt-legend{ list-style:none; padding:0 !important; margin:0 0 12px !important; }
.pt-legend li{
  display:flex; gap:10px; align-items:flex-start;
  padding:8px 0; border-bottom:1.5px solid var(--border); margin:0 !important;
}
.pt-legend li:last-child{ border-bottom:0; }
.pt-legend .pt-chip{ margin-top:1px; }
.pt-legend-label{ font-weight:620; display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.pt-legend li.flag .pt-legend-label{ color:var(--flag); }
.pt-legend-src{ font-size:12.4px; color:var(--muted); margin-top:2px; }
@media (max-width:600px){
  .pt-tools{ flex-wrap:nowrap; overflow-x:auto; }
  .pt-tools .btn{ flex:none; }
  .pt-tools-gap{ flex:0 0 4px; }
  .pt-canvas{ height:62vh; min-height:340px; }
  .pt-label{ font-size:11px; max-width:44%; }
  .pt-label-text{ max-width:110px; }
}
@media print{ .pt-tools, .pt-labels, .pt-leaders{ display:none !important; } .pt-canvas{ height:420px; } }

.isbar-block{ margin-bottom:18px; display:grid; grid-template-columns:30px 1fr; gap:14px; }
.isbar-letter{
  width:30px; height:30px; border-radius:50%; display:grid; place-items:center;
  background:var(--accent); color:var(--accent-text); font-weight:800; font-size:14px;
}
.isbar-block h3{
  margin:4px 0 4px; font-family:var(--mono); font-weight:600;
  font-size:11px; text-transform:uppercase; letter-spacing:.12em; color:var(--text-2);
}

.ddx-table{ width:100%; border-collapse:collapse; font-size:13.8px; }
.ddx-table th{
  text-align:left; font-size:10px;
  color:var(--text-2); border-bottom:2px solid var(--line); padding:7px 8px;
}
.ddx-table td{ padding:9px 8px; border-bottom:1.5px solid var(--border); vertical-align:top; }
.ddx-table .for{ color:var(--pos); }
.ddx-table .against{ color:var(--neg); }
.ddx-rank{ font-family:var(--mono); font-weight:700; color:var(--text-2); }

pre.plain{
  font-family:var(--mono); font-size:12.6px; line-height:1.65;
  white-space:pre-wrap; word-wrap:break-word;
  background:var(--surface-2); border:1.5px solid var(--border-strong);
  border-radius:var(--radius-s); padding:18px; margin:0;
  max-height:70vh; overflow:auto;
}

/* ---------------- date field + calendar (js/ui/datepicker.js) ---------------- */
.dp-field{ position:relative; display:inline-flex; align-items:center; }
.dp-field .dp-input{ width:150px; min-width:0; padding-right:34px; font-variant-numeric:tabular-nums; }
/* a plain glyph inside the box, like the original date field — no disc */
.dp-btn{
  position:absolute; right:5px; top:50%; transform:translateY(-50%);
  width:26px; height:26px; padding:0; border:0; border-radius:7px;
  display:grid; place-items:center; cursor:pointer;
  background:transparent; color:var(--text);
  transition:background .15s;
}
.dp-btn svg{ width:16px; height:16px; }
.dp-btn:hover{ background:var(--hover); }
.dp-btn:focus-visible{ outline:2px solid var(--text); outline-offset:1px; }

.dp-pop{
  position:fixed; z-index:150; width:312px;
  background:var(--surface); color:var(--text);
  border:2px solid var(--line); border-radius:22px;
  box-shadow:6px 6px 0 var(--line);
  overflow:hidden; font-family:var(--font);
  animation:pop .3s var(--ease);
}
.dp-pop.sheet{
  left:50%; top:50%; transform:translate(-50%,-50%);
  width:min(344px, calc(100vw - 32px)); animation:none;
}
.dp-backdrop{ position:fixed; inset:0; z-index:149; background:rgba(14,14,12,.5); }

.dp-head{
  display:flex; align-items:center; gap:8px;
  padding:12px; background:var(--bg); border-bottom:2px solid var(--line);
}
.dp-nav{
  flex:none; width:34px; height:34px; padding:0; border-radius:50%;
  display:grid; place-items:center; cursor:pointer;
  border:1.5px solid var(--line); background:var(--surface); color:var(--text);
  font:inherit; font-size:20px; font-weight:700; line-height:1;
  transition:transform .35s var(--bounce), background .15s, color .15s;
}
.dp-nav:hover{ background:var(--text); color:var(--bg); transform:scale(1.08); }
.dp-title{
  flex:1; min-width:0; display:flex; align-items:baseline; justify-content:center; gap:7px;
  padding:5px 8px; border:0; border-radius:var(--pill);
  background:transparent; color:var(--text); cursor:pointer; font:inherit;
}
.dp-title:hover{ background:var(--hover); }
.dp-title b{ font-size:19px; font-weight:780; letter-spacing:-.035em; }
.dp-title span{ font-family:var(--mono); font-size:11.5px; font-weight:600; letter-spacing:.1em; }
.dp-title::after{ content:"▾"; font-size:10px; align-self:center; }

.dp-body{ padding:12px 12px 10px; }
.dp-week{ display:grid; grid-template-columns:repeat(7,1fr); margin-bottom:6px; }
.dp-week span{
  text-align:center; font-family:var(--mono); font-size:10px; font-weight:600;
  letter-spacing:.08em; text-transform:uppercase; color:var(--text-2);
}
.dp-week span:nth-child(n+6){ color:var(--muted); }
.dp-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:3px; }
.dp-day{
  aspect-ratio:1; padding:0; border-radius:50%;
  display:grid; place-items:center; cursor:pointer;
  border:1.5px solid transparent; background:transparent; color:var(--text);
  font:inherit; font-size:13.4px; font-weight:560; font-variant-numeric:tabular-nums;
  transition:transform .3s var(--bounce), background .12s, border-color .12s;
}
.dp-day:hover{ background:var(--dot); border-color:var(--line); transform:scale(1.08); }
.dp-day.out{ color:var(--muted); }
.dp-day.today{ border:1.5px dashed var(--line); font-weight:750; }
.dp-day.sel{ background:var(--text); border:1.5px solid var(--text); color:var(--bg); font-weight:750; }
.dp-day.sel:hover{ background:var(--text); }
.dp-day:focus-visible{ outline:2.5px solid var(--fuzz); outline-offset:1px; }

.dp-months{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; padding:2px 0 4px; }
.dp-month{
  padding:10px 0; border-radius:var(--pill); cursor:pointer;
  border:1.5px solid var(--border-strong); background:var(--surface); color:var(--text);
  font:inherit; font-size:13.4px; font-weight:620;
  transition:transform .3s var(--bounce), background .12s, border-color .12s;
}
.dp-month:hover{ background:var(--dot); border-color:var(--line); transform:translateY(-1px); }
.dp-month.now{ border:1.5px dashed var(--line); }
.dp-month.sel{ background:var(--text); border:1.5px solid var(--text); color:var(--bg); }

.dp-foot{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:10px 12px 12px; border-top:1.5px solid var(--border);
}
.dp-picked{
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  font-family:var(--mono); font-size:10.5px; font-weight:600;
  letter-spacing:.08em; text-transform:uppercase; color:var(--text-2);
}
.dp-actions{ display:flex; gap:6px; flex:none; }

/* ---------------- modal ---------------- */
.modal-wrap{
  position:fixed; inset:0; z-index:100;
  background:rgba(14,14,12,.58);
  -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px);
  display:flex; align-items:flex-start; justify-content:center;
  padding:56px 18px 32px; overflow-y:auto;
}
.modal{
  background:var(--surface); border:2px solid var(--line);
  border-radius:24px; box-shadow:0 24px 70px rgba(0,0,0,.3);
  width:100%; max-width:620px; overflow:hidden;
  animation:pop .45s var(--ease);
}
.modal.wide{ max-width:860px; }
/* dialogs that wear the calendar's hard ink shadow: AI settings and the
   working-differential detail */
.modal.modal-shadow{ box-shadow:6px 6px 0 var(--line); }
.ai-warn{
  background:var(--warn-soft); color:var(--warn);
  border:2px solid var(--line); border-radius:14px;
  padding:12px 14px; margin:14px 0;
  font-size:13px; line-height:1.55;
}

/* AI chat popup (App.aiChat): your questions on the right in highlighter,
   the AI's answers on the left on paper */
.modal.ai-chat-modal{ max-width:700px; }
.ai-chat-about{
  font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.1em;
  text-transform:uppercase; color:var(--text-2); margin-bottom:12px;
}
.ai-chat-log{ display:flex; flex-direction:column; gap:10px; }
.ai-chat-log:not(:empty){ margin-bottom:14px; }
.ai-msg{
  max-width:88%; padding:10px 14px; border:1.5px solid var(--line); border-radius:16px;
  font-size:14px; line-height:1.6; overflow-wrap:anywhere;
}
.ai-msg-user{ align-self:flex-end; background:var(--accent-soft); border-bottom-right-radius:4px; white-space:pre-wrap; }
.ai-msg-ai{ align-self:flex-start; background:var(--surface-2); border-bottom-left-radius:4px; }
.ai-msg-ai p{ margin:0 0 8px; }
.ai-msg-ai ul, .ai-msg-ai ol{ margin:0 0 8px; padding-left:20px; }
.ai-msg-ai li{ margin-bottom:3px; }
.ai-msg-ai > :last-child{ margin-bottom:0; }
.ai-thinking{ color:var(--muted); font-style:italic; }
.ai-msg-err{ align-self:stretch; max-width:none; background:var(--flag-soft); color:var(--flag); border-color:var(--flag); font-size:13px; }
.ai-copy{ display:block; margin-top:8px; }
.ai-chat-starters{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px; }
.ai-chat-starters .chip{ text-align:left; }
.ai-chat-form{ display:flex; gap:8px; align-items:flex-end; }
.ai-chat-form .inp{ flex:1; min-width:0; resize:none; min-height:44px; }
.ai-chat-note{ margin:10px 0 0; font-size:11.5px; color:var(--muted); line-height:1.45; }

/* AI probability, under the live differential: the same bars, on a
   dashed paper card so it never reads as the app's own heuristic */
.ai-prob{
  margin-top:14px; padding:10px 11px 9px;
  border:1.5px dashed var(--line); border-radius:var(--radius-s); background:var(--surface-2);
}
.ai-prob.stale{ opacity:.6; }
.ai-prob-head{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.ai-prob-title{
  font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.1em;
  text-transform:uppercase; color:var(--text-2);
}
.ai-prob-row{ --c:var(--fuzz); margin-bottom:10px; cursor:pointer; }
.ai-prob-row.mustnotmiss{ --c:var(--spike-hot); }
.ai-prob-row:hover .ddx-name{ text-decoration:underline; text-underline-offset:3px; }
.ai-prob-note{ margin:4px 0 0; font-size:11.2px; color:var(--muted); line-height:1.45; }

/* the AI-polished history, kept beside the generated draft */
.ai-card{
  margin-top:14px; padding:14px 16px;
  border:2px dashed var(--line); border-radius:var(--radius); background:var(--surface-2);
}
.ai-card.stale{ opacity:.65; }
.ai-card h2{ margin-top:0; }
.ai-card-meta{ font-size:12.4px; color:var(--muted); }
.ai-card-use{ display:flex; align-items:center; gap:6px; font-size:13.4px; font-weight:600; margin:8px 0 10px; cursor:pointer; }

/* "Go deeper": the AI's explanation inside the why panel */
.ai-deeper:not(:empty){ margin-top:16px; padding-top:4px; border-top:1.5px dashed var(--border); }
.ai-deeper-tag{
  display:inline-block; margin:10px 0 2px; font-family:var(--mono); font-size:10px; font-weight:600;
  letter-spacing:.08em; text-transform:uppercase; color:var(--text-2);
  border:1.2px solid var(--line); border-radius:var(--pill); padding:1px 8px; background:var(--fuzz);
}

.modal-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:16px 20px; border-bottom:2px solid var(--line); background:var(--bg);
}
.modal-head h2{ font-size:20px; letter-spacing:-.03em; }
.modal-head .btn-ghost{ font-size:20px; line-height:1; width:36px; height:36px; padding:0; border-radius:50%; }
.modal-body{ padding:20px; max-height:64vh; overflow-y:auto; }
.modal-foot{
  display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap;
  padding:14px 20px; border-top:1.5px solid var(--border); background:var(--surface-2);
}
.modal-foot:empty{ display:none; }

.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12.8px; font-weight:650; color:var(--text); margin-bottom:5px; }
.field .inp{ width:100%; }
.field .hint{ font-size:12px; color:var(--muted); margin-top:4px; }

.case-row{
  display:flex; align-items:center; gap:12px;
  padding:10px 10px; border-bottom:1.5px solid var(--border);
}
.case-row:last-child{ border-bottom:0; }
.case-main{ flex:1; min-width:0; }
.case-title{ font-size:14px; font-weight:650; }
.case-meta{ font-family:var(--mono); font-size:11px; color:var(--muted); }

/* ---------------- toasts ---------------- */
.toast-host{ position:fixed; bottom:18px; right:18px; z-index:200; display:flex; flex-direction:column; gap:8px; }
.toast{
  background:var(--text); color:var(--bg);
  padding:10px 18px; border-radius:16px;
  font-size:13.4px; font-weight:560; box-shadow:0 10px 28px rgba(0,0,0,.25);
  max-width:340px; animation:pop .4s var(--bounce);
}
.toast.err{ background:var(--flag); color:#fff; }

.spinner{
  display:inline-block; width:12px; height:12px;
  border:2px solid var(--border-strong); border-top-color:var(--text);
  border-radius:50%; animation:spin .7s linear infinite; vertical-align:-1px;
}

/* ---------------- records ---------------- */
.rec-card .card-head{ flex-wrap:wrap; }
/* name, age and status tags on one evenly spaced, centred line */
.rec-card .card-head h2{
  display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px;
}
.rec-card .card-head h2 .tag{ font-size:9.4px; padding:3px 9px; }
.rec-current{ border-width:2.5px; box-shadow:6px 6px 0 var(--line); }
.rec-sub{ font-weight:450; font-size:13.4px; color:var(--text-2); }
.rec-meta{ font-family:var(--mono); font-size:11px; letter-spacing:.02em; color:var(--muted); margin:6px 0 0; }
.rec-actions{ flex:none; }

/* empty state — one line of text wherever there is nothing to show yet */
.empty-note{ margin:0; padding:6px 0 2px; font-size:13.6px; }
.card-body > .empty-note{ padding-top:12px; }

/* ---------------- sign-in gate (js/firebase/gate.js) ---------------- */
/* While the gate shows, the app behind it is not drawn at all. */
.gate:not([hidden]) ~ .masthead, .gate:not([hidden]) ~ .shell{ display:none !important; }
.gate{
  position:relative; overflow-x:hidden;
  flex:1; min-height:100vh; min-height:100dvh; overflow-y:auto;
  display:grid; place-items:center; padding:32px 16px;
  background:var(--bg);
}
.gate-card{
  position:relative; z-index:2;
  width:100%; max-width:460px;
  background:var(--surface); border:2px solid var(--line); border-radius:24px;
  box-shadow:6px 6px 0 var(--line);
  padding:26px 26px 22px;
  animation:pop .45s var(--ease);
}
.gate-card .brand{ margin-bottom:26px; }
.gate-card .brand-name{ font-size:44px; }
.gate-card .page-eyebrow{ margin-bottom:10px; }
.gate-card h1{ font-size:30px; font-weight:760; line-height:1.05; letter-spacing:-.045em; margin-bottom:12px; }
.gate-text{ color:var(--text-2); font-size:14.4px; font-weight:500; min-height:1.5em; }
.gate-actions{ display:flex; gap:8px; flex-wrap:wrap; margin:18px 0 20px; }
.gate-actions:empty{ display:none; }
.gate[data-state="loading"] h1::after{
  content:""; display:inline-block; width:18px; height:18px; margin-left:10px; vertical-align:2px;
  border:2.5px solid var(--border-strong); border-top-color:var(--text);
  border-radius:50%; animation:spin .7s linear infinite;
}

/* ---------------- profile menu: a divider ---------------- */
.profile-sep{ border:0; border-top:1.5px solid var(--border); margin:6px 4px; }

/* ---------------- celebrations (js/play/play.js) ---------------- */
.modal.modal-celebrate{ max-width:520px; box-shadow:6px 6px 0 var(--line); }
.celebrate{ text-align:center; }
/* one drawing, centred on the page colour */
.celebrate-scene{
  display:flex; align-items:center; justify-content:center; box-sizing:border-box;
  height:230px; margin:-6px -6px 6px; padding:18px;
  background:var(--bg); border:2px solid var(--line); border-radius:18px; overflow:hidden;
}
.celebrate-scene img{
  display:block; height:100%; width:auto; max-width:100%; object-fit:contain;
  animation:celebrate-in .55s var(--bounce) both;
}
@keyframes celebrate-in{ from{ opacity:0; transform:translateY(24px) scale(.96); } to{ opacity:1; transform:none; } }
.celebrate-big{ font-size:30px; font-weight:780; letter-spacing:-.04em; margin:14px 0 4px; }
.celebrate-sub{ color:var(--text-2); font-weight:500; max-width:400px; margin:0 auto 4px; }
.celebrate-badges{ margin-top:14px; padding-top:12px; border-top:1.5px solid var(--border); text-align:left; }
.celebrate-badges .mono-label{ font-size:10.5px; margin-bottom:6px; }
.celebrate-badge{ margin:0 0 4px; font-size:13.6px; color:var(--text-2); }
.celebrate-badge strong{ color:var(--text); }

/* ---------------- sticker popups (js/play/play.js) ----------------
   Celebrations and nudges pop up in the bottom-right corner, with no
   backdrop: the page stays usable. The character stands as drawn (no
   frame), talking through a speech bubble in the calendar's yellow, ink
   outline and hard shadow, which holds the message and its buttons.
   Wide screens: bubble to his left. Phones: bubble above him. The popup
   title is kept for screen readers only. */
.modal-wrap:has(> .modal-sticker){
  background:transparent; -webkit-backdrop-filter:none; backdrop-filter:none;
  pointer-events:none; overflow:visible;
  align-items:flex-end; justify-content:flex-end; padding:16px;
}
.modal.modal-sticker{
  pointer-events:auto; width:auto; max-width:100%;
  background:transparent; border:0; border-radius:0; box-shadow:none;
  overflow:visible; animation:none;
}
.modal-sticker .modal-head{
  position:absolute; width:1px; height:1px; padding:0; border:0;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap;
}
.modal-sticker .modal-body{ padding:0; max-height:none; overflow:visible; }
.sticker-pop{ display:flex; flex-direction:row-reverse; align-items:flex-end; gap:4px; }
/* each drawing is trimmed to its own shape: fit it in a box that grows
   with the screen, standing on the bottom edge */
.sticker{
  flex:none; display:flex; align-items:flex-end; justify-content:center;
  width:clamp(160px, 16vw, 230px); height:clamp(150px, 16vw, 210px);
  transform-origin:50% 100%;
  animation:sticker-in .6s var(--bounce) both;
}
.sticker img{ display:block; max-width:100%; max-height:100%; width:auto; height:auto; }
@keyframes sticker-in{ from{ opacity:0; transform:translateY(30px) scale(.6); } to{ opacity:1; transform:none; } }
.sticker-bubble{
  position:relative; flex:0 1 330px; min-width:0; margin:0 14px 46px 0;
  background:var(--bg); color:var(--text);
  border:2px solid var(--line); border-radius:22px;
  box-shadow:6px 6px 0 var(--line);
  padding:16px 18px 14px; text-align:left;
  animation:bubble-in .4s var(--bounce) .18s both;
}
@keyframes bubble-in{ from{ opacity:0; transform:translateX(16px) scale(.94); } to{ opacity:1; transform:none; } }
/* the tail, pointing right at him: an ink triangle with a yellow one inside */
.sticker-bubble::before, .sticker-bubble::after{
  content:""; position:absolute; border-style:solid; border-color:transparent;
}
.sticker-bubble::before{ right:-15px; bottom:30px; border-width:11px 0 11px 15px; border-left-color:var(--line); }
.sticker-bubble::after{ right:-10px; bottom:33px; border-width:8px 0 8px 12px; border-left-color:var(--bg); }
.sticker-bubble .celebrate-big{ font-size:24px; margin:0 0 4px; }
.sticker-bubble .celebrate-sub{ font-size:13.8px; margin:0 0 4px; max-width:none; }
.sticker-bubble .celebrate-badges{ border-top-color:var(--line); }
.sticker-actions{ display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; margin-top:14px; }

/* phones: the bubble above him, the tail pointing down */
@media (max-width:600px){
  .modal-wrap:has(> .modal-sticker){ padding:12px; }
  .sticker-pop{ flex-direction:column-reverse; align-items:flex-end; gap:10px; }
  .sticker{ width:156px; height:142px; margin-right:6px; }
  .sticker-bubble{ flex:none; width:min(340px, calc(100vw - 30px)); margin:0; }
  .sticker-bubble::before{ right:44px; bottom:-15px; border-width:15px 11px 0 11px; border-color:var(--line) transparent transparent; }
  .sticker-bubble::after{ right:47px; bottom:-10px; border-width:12px 8px 0 8px; border-color:var(--bg) transparent transparent; }
  .sticker-bubble .celebrate-big{ font-size:22px; }
}

/* ---------------- achievements ---------------- */
.badge-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:8px; padding-top:14px; }
.badge{
  display:flex; align-items:center; gap:10px; padding:9px 11px;
  border:1.5px dashed var(--border-strong); border-radius:14px; color:var(--muted);
}
.badge-mark{
  flex:none; width:38px; height:38px; border-radius:50%;
  display:grid; place-items:center; border:1.5px dashed currentColor;
}
.badge-text{ display:flex; flex-direction:column; min-width:0; }
.badge-text strong{ font-size:13.6px; }
.badge-text span{ font-size:12px; }
.badge.have{ border:1.5px solid var(--line); background:var(--surface); color:var(--text); }
.badge.have .badge-mark{ background:var(--accent); color:var(--accent-text); border:1.5px solid var(--line); }
.badge.have .badge-text span{ color:var(--text-2); }

/* ---------------- the leaderboard ---------------- */
.lb-you .card-body{ display:flex; align-items:center; gap:18px; padding:18px; flex-wrap:wrap; }
.lb-you-avatar svg{ display:block; border:3px solid var(--line); border-radius:50%; }
.lb-you-main{ flex:1; min-width:200px; }
.lb-you-main .mono-label{ font-size:10.5px; color:var(--text-2); margin-bottom:4px; }
.lb-you-main h2{ font-size:22px; letter-spacing:-.03em; }
.lb-you-points{ margin:2px 0 0; font-size:14px; color:var(--text-2); }
.lb-you-points strong{ font-size:28px; color:var(--text); letter-spacing:-.04em; }
.lb-you-actions{ display:flex; flex-direction:column; gap:6px; }
.lb-tabs{ margin:0; }
.lb-list{ padding-top:6px; }
.lb-row{
  display:grid; grid-template-columns:34px 48px minmax(0,1fr) auto auto; align-items:center; gap:12px;
  padding:9px 6px; border-bottom:1.5px solid var(--border);
}
.lb-row:last-child{ border-bottom:0; }
.lb-rank{
  width:30px; height:30px; border-radius:50%; display:grid; place-items:center;
  font-family:var(--mono); font-size:12px; font-weight:700; border:1.5px solid var(--line);
}
.lb-row.top-1 .lb-rank{ background:var(--accent); color:var(--accent-text); }
.lb-row.top-2 .lb-rank, .lb-row.top-3 .lb-rank{ background:var(--surface-3); }
.lb-avatar svg{ display:block; border:2px solid var(--line); border-radius:50%; }
.lb-who{ display:flex; flex-direction:column; min-width:0; }
.lb-who strong{ display:flex; align-items:center; gap:8px; font-size:14.4px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lb-who .rec-meta{ margin:2px 0 0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lb-score{ display:flex; flex-direction:column; align-items:flex-end; }
.lb-score strong{ font-size:19px; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.lb-score span{ font-family:var(--mono); font-size:10px; text-transform:uppercase; letter-spacing:.1em; color:var(--muted); }
.lb-row.mine{ background:var(--accent-soft); border-radius:12px; border-bottom-color:transparent; }

/* ---------------- the avatar editor ---------------- */
.av-edit{ display:flex; gap:22px; flex-wrap:wrap; }
.av-left{ display:flex; flex-direction:column; align-items:center; gap:10px; flex:none; }
.av-preview svg{ display:block; border:3px solid var(--line); border-radius:50%; }
.av-right{ flex:1; min-width:240px; }
.av-right .field{ display:block; margin-bottom:12px; }
.av-right .field > span{ display:block; font-size:12.8px; font-weight:650; margin-bottom:5px; }
.av-right .field .inp{ width:100%; }
.av-row{ display:grid; grid-template-columns:96px 28px minmax(0,1fr) 28px; align-items:center; gap:8px; padding:5px 0; border-bottom:1.5px solid var(--border); }
.av-row:last-child{ border-bottom:0; }
.av-label{ font-weight:620; font-size:13.6px; }
.av-value{ text-align:center; font-family:var(--mono); font-size:11.5px; color:var(--text-2); }
.av-step{ width:26px; height:26px; font-size:16px; }

/* ---------------- MCQ practice ---------------- */
.quiz-start{ display:flex; align-items:center; gap:18px; padding-top:12px; }
.quiz-start h2{ font-size:20px; margin-bottom:6px; }
.quiz-progress{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; padding:12px 0 6px; }
.quiz-progress .mono-label{ font-size:10.5px; color:var(--text-2); }
.quiz-dots{ display:flex; gap:5px; }
.quiz-dot{ width:11px; height:11px; border-radius:50%; border:1.5px solid var(--line); background:var(--surface); }
.quiz-dot.now{ background:var(--accent); }
.quiz-dot.right{ background:var(--bit); }
.quiz-dot.wrong{ background:var(--spike); }
.quiz-stem{ font-size:17px; font-weight:620; line-height:1.45; margin:6px 0 14px; letter-spacing:-.01em; }
.quiz-options{ display:flex; flex-direction:column; gap:8px; }
.quiz-option{
  display:flex; align-items:flex-start; gap:12px; width:100%; text-align:left;
  padding:11px 14px; border:1.5px solid var(--border-strong); border-radius:14px;
  background:var(--surface); color:var(--text); font:inherit; font-size:14.4px; font-weight:520; cursor:pointer;
  transition:border-color .15s, background .15s;
}
.quiz-option:hover:not([disabled]){ border-color:var(--line); background:var(--surface-2); }
.quiz-option:focus-visible{ outline:2.5px solid var(--text); outline-offset:2px; }
.quiz-option[disabled]{ cursor:default; }
.quiz-letter{
  flex:none; width:26px; height:26px; border-radius:50%; display:grid; place-items:center;
  border:1.5px solid var(--line); font-family:var(--mono); font-size:11.5px; font-weight:700;
}
.quiz-option.right{ border:2px solid var(--line); background:var(--pos-soft); }
.quiz-option.right .quiz-letter{ background:var(--bit); }
.quiz-option.wrong{ border:2px solid var(--flag); background:var(--flag-soft); }
.quiz-option.wrong .quiz-letter{ background:var(--spike); }
.quiz-option.dim{ opacity:.6; }
.quiz-explain{ margin-top:14px; padding:12px 14px; border-radius:14px; border:1.5px solid var(--line); background:var(--surface-2); }
.quiz-explain strong{ display:block; margin-bottom:4px; }
.quiz-explain p{ margin:4px 0 0; }
.quiz-explain.right strong{ color:var(--pos); }
.quiz-explain.wrong strong{ color:var(--flag); }
.quiz-result{ text-align:center; padding:14px 0 6px; }
.quiz-result .mono-label{ font-size:10.5px; color:var(--text-2); }
.quiz-score{ font-size:46px; font-weight:780; letter-spacing:-.05em; margin:4px 0; }
.quiz-review{ margin:14px 0 0; padding-left:22px; }
.quiz-review li{ padding:8px 0; border-bottom:1.5px solid var(--border); }
.quiz-review li.wrong::marker{ color:var(--flag); }
.quiz-review-stem{ margin:0; font-weight:560; }
.quiz-review .rec-meta{ margin-top:3px; }

.lb-act{ display:flex; justify-content:flex-end; min-width:0; }

/* MCQ practice: long cases, true/false, the bonus round */
.quiz-group{ font-size:10.5px; color:var(--text-2); margin:20px 0 8px; }
.case-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:8px; }
.case-pick{
  display:flex; flex-direction:column; align-items:flex-start; gap:3px; text-align:left;
  padding:11px 13px; border:1.5px solid var(--line); border-radius:14px; background:var(--surface);
  color:var(--text); font:inherit; cursor:pointer; transition:background .15s, transform .15s;
}
.case-pick strong{ font-size:13.6px; line-height:1.25; }
.case-pick span{ font-family:var(--mono); font-size:10.5px; color:var(--text-2); }
.case-pick:hover:not([disabled]){ background:var(--accent-soft); }
.case-pick:focus-visible{ outline:2.5px solid var(--text); outline-offset:2px; }
.case-pick[disabled]{ border-style:dashed; border-color:var(--border-strong); color:var(--muted); cursor:default; }
.case-pick.topic{ background:var(--surface-2); }
/* a case round waiting: the details on the left, the button always in its
   own column on the right (under them on phones), however long the title */
.quiz-bonus{
  --c:var(--fuzz);
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:12px 20px;
  margin:12px 0 4px; padding:14px 16px;
  border:2px solid var(--line); border-radius:16px; box-shadow:4px 4px 0 var(--line);
  background:var(--c); color:var(--text);
}
.quiz-bonus.c1{ --c:var(--vortex); }
.quiz-bonus.c2{ --c:var(--bit); }
.quiz-bonus.c3{ --c:var(--halo); }
.quiz-bonus.c4{ --c:var(--puff); }
.quiz-bonus .mono-label{ font-size:10.5px; margin:0 0 3px; }
.quiz-bonus strong{ display:block; font-size:15px; line-height:1.35; }
.quiz-bonus .rec-meta{ margin:3px 0 0; color:var(--text-2); }
.quiz-bonus .btn{ white-space:nowrap; }
@media (max-width:600px){
  .quiz-bonus{ grid-template-columns:minmax(0,1fr); }
  .quiz-bonus .btn{ width:100%; justify-content:center; }
}
.quiz-kind{ font-size:10.5px; color:var(--text-2); margin:4px 0 0; }
.quiz-dot.part{ background:var(--accent); }
.quiz-explain.part strong{ color:var(--text); }
.tf-list{ display:flex; flex-direction:column; gap:6px; }
.tf-row{
  display:grid; grid-template-columns:26px minmax(0,1fr) auto; align-items:center; gap:10px;
  padding:9px 12px; border:1.5px solid var(--border-strong); border-radius:14px; background:var(--surface);
}
.tf-row .tf-key{ grid-column:2 / 4; font-family:var(--mono); font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-2); }
.tf-row.right{ border:2px solid var(--line); background:var(--pos-soft); }
.tf-row.wrong{ border:2px solid var(--flag); background:var(--flag-soft); }
.tf-text{ font-size:14.4px; font-weight:520; }
.tf-btns{ display:flex; gap:4px; }
.tf-btn{
  padding:5px 11px; border:1.5px solid var(--line); border-radius:999px; background:var(--surface);
  color:var(--text); font:inherit; font-size:12.5px; font-weight:650; cursor:pointer;
}
.tf-btn.on{ background:var(--text); color:var(--surface); }
.tf-btn[disabled]{ cursor:default; opacity:.75; }
.tf-btn:focus-visible{ outline:2.5px solid var(--text); outline-offset:2px; }
.celebrate-scene.duel-face svg{ display:block; height:100%; width:auto; border:3px solid var(--line); border-radius:50%; }

/* challenges */
.duel-clock{ height:10px; border:1.5px solid var(--line); border-radius:999px; overflow:hidden; background:var(--surface-2); margin:2px 0 12px; }
.duel-clock span{ display:block; height:100%; background:var(--text); transition:width .2s linear; }
.duel-clock.low span{ background:var(--flag); }
.duel-left{ font-family:var(--mono); font-size:13px; font-weight:700; font-variant-numeric:tabular-nums; }
.duel-verdict{ font-weight:650; margin-top:8px; }
.duel-list{ display:flex; flex-direction:column; gap:0; padding-top:6px; }
.duel-row{ display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:10px; padding:8px 4px; border-bottom:1.5px solid var(--border); }
.duel-row:last-child{ border-bottom:0; }
.duel-text{ font-size:13.6px; }
.duel-acts{ display:flex; gap:6px; }
.duel-tag{
  font-family:var(--mono); font-size:10px; text-transform:uppercase; letter-spacing:.08em; white-space:nowrap;
  padding:3px 8px; border:1.5px solid var(--line); border-radius:999px; background:var(--surface);
}
.duel-tag.won{ background:var(--accent); color:var(--accent-text); }
.duel-tag.your{ background:var(--text); color:var(--surface); }
.duel-tag.lost, .duel-tag.declined{ color:var(--muted); border-color:var(--border-strong); }

/* admin: the question bank */
.bank-row .adm-name{ font-weight:560; font-size:14px; }
.bank-actions{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.bank-filter{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin:6px 0 10px; }
.bank-filter .out-tabs{ margin:0; }
.bank-filter .inp{ flex:1; min-width:220px; }
.bank-row{ align-items:flex-start; }
.bank-row .adm-main{ flex:1; min-width:0; }
.bank-row .adm-acts{ display:flex; align-items:center; gap:8px; flex:none; }
.bank-edit .field{ display:block; margin-bottom:12px; }
.bank-edit .field > span{ display:block; font-size:12.8px; font-weight:650; margin-bottom:5px; }
.bank-edit .inp{ width:100%; }
.bank-opts{ display:flex; flex-direction:column; gap:6px; }
.bank-opt{ display:grid; grid-template-columns:26px minmax(0,1fr) auto; align-items:center; gap:8px; }

@media (prefers-reduced-motion:reduce){
  .celebrate-scene img{ animation:none !important; }
  .sticker, .sticker-bubble{ animation:none !important; }
}
@media (max-width:600px){
  .celebrate-scene{ height:190px; }
  .lb-row{ grid-template-columns:30px 40px minmax(0,1fr) auto; gap:8px; }
  .lb-act{ grid-column:3 / 5; justify-content:flex-start; }
  .tf-row{ grid-template-columns:26px minmax(0,1fr); }
  .tf-btns{ grid-column:2; }
  .duel-row{ grid-template-columns:auto minmax(0,1fr); }
  .duel-acts{ grid-column:1 / 3; }
  .lb-avatar svg{ width:38px; height:38px; }
  .lb-you-actions{ flex-direction:row; width:100%; }
  .lb-you-actions .btn{ flex:1; }
  .quiz-start{ flex-direction:column; text-align:center; }
  .quiz-start .out-tabs{ justify-content:center; }
  .av-left{ width:100%; }
}

/* ---------------- admin page (web/admin/) ---------------- */
/* a plain scrolling page, not the app's fixed three-column desk */
html:has(body.admin-page), body.admin-page{ height:auto !important; overflow-y:auto !important; }
body.admin-page{ display:block !important; }
.admin-page .topbar{ position:sticky; top:0; z-index:40; }
.admin-badge{
  margin-left:6px; padding:3px 10px; border:1.5px solid var(--line); border-radius:var(--pill);
  font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.12em; text-transform:uppercase;
  align-self:center;
}
.admin-who{ font-family:var(--mono); font-size:11px; color:var(--text-2); margin-right:4px;
  max-width:280px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.admin-main{ max-width:980px; margin:0 auto; padding:28px 18px 64px; }
.admin-signin{ margin:32px auto 0; }
.admin-body{ padding-top:10px; }
.admin-panel .out-tabs{ margin-bottom:14px; }

/* email and password form (the admin page's sign-in) */
.signin-form{ margin:18px 0 20px; }
.signin-form .field{ display:block; }
.signin-form .field > span{ display:block; font-size:12.8px; font-weight:650; margin-bottom:5px; }
.signin-form .inp{ width:100%; }
.signin-row{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.gate-foot{
  margin:0; padding-top:14px; border-top:1.5px solid var(--border);
  font-family:var(--mono); font-size:10.5px; letter-spacing:.04em; color:var(--muted);
}

/* ---------------- Finish & save confirmation ---------------- */
.finish-list{
  display:grid; grid-template-columns:auto minmax(0,1fr); gap:8px 18px;
  margin:0 0 16px; padding:14px 16px;
  background:var(--surface-2); border:1.5px solid var(--border); border-radius:14px;
}
.finish-list dt{ font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.1em; text-transform:uppercase; color:var(--text-2); padding-top:2px; }
.finish-list dd{ margin:0; font-weight:600; overflow-wrap:anywhere; }
.adm-err{ color:var(--flag); background:var(--flag-soft); border:1.5px solid var(--flag); border-radius:11px; padding:9px 12px; font-size:13px; }

/* ---------------- admin panel (js/firebase/admin.js) ---------------- */
.adm-row{
  display:flex; align-items:flex-start; gap:12px;
  padding:12px 2px; border-bottom:1.5px solid var(--border);
}
.adm-row:last-child{ border-bottom:0; }
.adm-col{ flex-direction:column; align-items:stretch; }
.adm-head{ display:flex; align-items:flex-start; gap:12px; }
.adm-main{ flex:1; min-width:0; }
.adm-name{ display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; font-weight:680; font-size:14.6px; overflow-wrap:anywhere; }
.adm-row .rec-meta{ margin-top:3px; overflow-wrap:anywhere; }
.adm-row .card-actions{ flex-wrap:wrap; justify-content:flex-end; }
.adm-st-pending{ background:var(--halo); color:var(--text); }
.adm-st-approved{ background:var(--bit); color:var(--text); }
.adm-st-rejected, .adm-st-disabled{ background:var(--spike); color:var(--text); }
.adm-search{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
.adm-search .inp{ flex:1 1 200px; min-width:0; }
.adm-preview{ margin-top:10px; }
.adm-preview pre.plain{ max-height:360px; overflow:auto; }

/* ---------------- responsive ---------------- */

/* Desktop, three columns. The page itself never scrolls: the masthead
   stays put and each column scrolls on its own — the history in the
   middle, the rails beside it when they outgrow the screen. Full-height
   ink rules divide navigation | history taking | live reasoning. */
@media (min-width:1281px){
  html, body{ height:100%; overflow:hidden; }
  body{ display:flex; flex-direction:column; }
  .masthead{ flex:none; position:relative; }
  .shell{
    flex:1; min-height:0; width:100%;
    padding:0 var(--pad); gap:0; align-items:stretch;
  }
  .rail, .main{ height:100%; min-height:0; overflow-y:auto; overscroll-behavior:contain; }
  .rail{ position:static; max-height:none; padding:20px 0 24px; }
  .rail-left{ padding-right:22px; }
  .rail-right{ padding-left:22px; }
  .main{
    padding:22px 22px 0;
    border-left:2px solid var(--line);
    border-right:2px solid var(--line);
  }
}

/* Below the three-column breakpoint the rails move UNDER the form rather
   than disappearing — the live differential and the outstanding-question
   list are the most useful part of the app on a phone. */
@media (max-width:1280px){
  .shell{ grid-template-columns:var(--rail-w) minmax(0,1fr); }
  .rail-right{
    grid-column:1 / -1;
    position:static; max-height:none; overflow:visible;
    display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px;
  }
  .rail-right .rail-card{ margin-bottom:0; }
}

/* Tablets and wide hubs (iPad Pro, Surface Pro, Nest Hub Max): the desktop
   desk in two columns. The page does not scroll; navigation and the work
   column (history taking, with the live reasoning under it) each scroll on
   their own, divided by a full-height ink rule. */
@media (min-width:901px) and (max-width:1280px){
  html, body{ height:100%; overflow:hidden; }
  body{ display:flex; flex-direction:column; }
  .masthead{ flex:none; position:relative; }
  .shell{
    flex:1; min-height:0; width:100%;
    padding:0 var(--pad); gap:0; align-items:stretch;
    grid-template-rows:minmax(0,1fr);
  }
  .rail-left, .workcol{ height:100%; min-height:0; overflow-y:auto; overscroll-behavior:contain; }
  .rail-left{ position:static; max-height:none; padding:20px 22px 24px 0; }
  .workcol{ display:block; min-width:0; border-left:2px solid var(--line); }
  .main{ padding:22px 22px 0; }
  .rail-right{ padding:8px 22px 24px; }
}

@media (max-width:900px){
  :root{ --mast-h:75px; }
  .shell{ grid-template-columns:minmax(0,1fr); padding:14px; gap:14px; }
  .rail-left{
    position:sticky; top:var(--mast-h); z-index:20;
    max-height:none; display:flex; gap:5px; overflow-x:auto;
    /* pulled up over the shell's top padding, so the strip starts right at
       the progress bar's border */
    padding:8px 2px; margin:-14px -14px 0; padding-left:14px; padding-right:14px;
    background:var(--bg); border-bottom:2px solid var(--line);
    -webkit-overflow-scrolling:touch;
  }
  .rail-left::-webkit-scrollbar{ display:none; }
  .nav-group-title{ display:none; }
  /* the top strip is for history taking only: Records is in the title bar,
     Leaderboard and MCQ practice in the profile menu */
  .nav-extra{ display:none; }
  .nav-item{ width:auto; flex:none; padding:8px 13px; margin-bottom:0; border:1.5px solid var(--line); }
  /* pills in the strip's yellow with ink text; the selected one turns
     ink, its text and number taking the yellow */
  .rail-left .nav-item{ background:var(--bg); color:var(--text); }
  .rail-left .nav-item .nav-num{ color:var(--text); }
  .rail-left .nav-item.active{ background:var(--accent); color:var(--bg); border-color:var(--accent); }
  .rail-left .nav-item.active .nav-num{ background:var(--bg); border-color:var(--bg); color:var(--accent); }
  .nav-label{ max-width:130px; }
  .nav-count{ display:none; }

  .q{ grid-template-columns:minmax(0,1fr); padding:12px 0; }
  .q-ctrl{ justify-content:flex-start; }
  .chips{ justify-content:flex-start; }
  .report{ padding:18px; }
  .report .kv{ grid-template-columns:1fr; }

  .topbar{ padding:8px 12px; gap:8px; }
  .topbar .brand-name{ font-size:28px; }
  .topbar-actions{ gap:2px; }
  .topbar-actions .btn{ padding:7px 10px; font-size:12.8px; }
  /* phones and tablets: the avatar alone */
  .profile-btn{ padding:3px; gap:0; }
  .profile-name, .profile-caret{ display:none; }
  .top-progress{ height:22px; }
  .top-progress-label{ padding:0 12px; font-size:9.5px; }

  .page-head{ margin-bottom:18px; }
  .page-head h1{ font-size:28px; }
  .card-head{ padding:13px 15px; flex-wrap:wrap; }
  .card-head-main{ flex:1 1 100%; }
  .card-actions{ flex:0 0 auto; }
  .card-body{ padding:6px 15px 14px; }
  .q-label{ font-size:14.8px; }
  .redflag-bar{ box-shadow:3px 3px 0 var(--line); }

  .rec-current{ box-shadow:4px 4px 0 var(--line); }
  .rec-actions{ width:100%; }
  .rec-actions .btn{ flex:1; }

  .gate-card{ padding:22px 18px 18px; box-shadow:4px 4px 0 var(--line); }
  .gate-card h1{ font-size:26px; }
  .gate-card .brand-name{ font-size:38px; }
  .adm-row, .adm-head{ flex-direction:column; }
  .adm-row .card-actions{ justify-content:flex-start; }
}

@media (max-width:900px){
  .admin-who{ display:none !important; }
  .admin-main{ padding:18px 14px 48px; }
  .admin-signin{ margin-top:12px; }
}

/* small phones: keep the title bar on one line */
@media (max-width:400px){
  .topbar .brand-name{ font-size:25px; }
  .topbar-actions .btn{ padding:7px 8px; }
}

/* Touch targets and the iOS zoom-on-focus problem: any control under 16px
   makes Safari zoom the whole page when it is tapped. */
@media (pointer:coarse){
  select.inp, input.inp, textarea.inp{ font-size:16px; padding:9px 12px; }
  input.inp.w-s{ width:96px; }
  .seg button{ padding:9px 17px; font-size:14px; }
  .chip{ padding:8px 15px; font-size:13.8px; }
  .btn{ padding:9px 16px; font-size:13.8px; }
  .btn-mini{ padding:6px 13px; font-size:12.6px; }
  .why-btn{ width:26px; height:26px; font-size:13px; }
  .gap-item{ padding:9px 8px; }
  .redflag-bar li > .gap-item{ padding:8px 14px !important; }
  .out-tab{ padding:9px 16px; }
  .nav-item{ padding:10px 13px; }
  .dp-field .dp-input{ width:166px; padding-right:42px; }
  .dp-btn{ width:36px; height:36px; right:3px; }
  .dp-btn svg{ width:18px; height:18px; }
  .dp-day{ font-size:15px; }
  .dp-nav{ width:40px; height:40px; }
  .dp-day:hover, .dp-month:hover{ transform:none; }
  /* hover lifts feel sticky on touch — keep the press feedback only */
  .btn:hover, .chip:hover, .cx-card:hover, .out-tab:hover{ transform:none; }
}

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

/* ---------------- print ---------------- */
@media print{
  :root{
    --bg:#fff; --surface:#fff; --surface-2:#fff; --text:#000; --text-2:#333; --muted:#555;
    --line:#000; --border:#ccc;
  }
  .masthead, .rail, .out-tabs, .step-foot, .card-actions, .redflag-bar button, .gate{ display:none !important; }
  /* undo the desktop's fixed-height columns so the write-up runs over
     as many pages as it needs */
  html, body{ height:auto !important; overflow:visible !important; }
  body{ display:block !important; background:#fff; color:#000; font-size:11.5pt; }
  .shell{ display:block; padding:0; max-width:none; min-height:0; }
  .main{ height:auto !important; overflow:visible !important; border:0 !important; padding:0 !important; }
  .workcol{ height:auto !important; overflow:visible !important; border:0 !important; }
  .report{ border:0; box-shadow:none; padding:0; }
  pre.plain{ max-height:none; border:0; background:#fff; }
}
