/* ============================================================
   Medcue — Gotchas  ·  Circuit reskin
   Warm bone ground, ink text, discipline-coded colour accents.
   Bricolage Grotesque (display) · General Sans (body) · IBM Plex Mono (data).
   Self-contained: all component styles are prefixed .gx-* so they never
   touch the shared topnav / app shell. Chrome follows light/dark.
   ============================================================ */

/* ---------------- tokens (light default) ---------------- */
:root {
  --teal: #0E7A6B;   --teal-d: #0a5f54;
  --tomato: #DA4A2A; --tomato-d: #b63a1e;
  --mustard: #E7A81B;--mustard-d: #9a6f08;
  --chalk: #5E9CB2;  --chalk-d: #3f7185;
  --plum: #6D2F4E;   --plum-d: #54233c;

  --gx-bg: #FBF8F1;
  --gx-surface: #ffffff;
  --gx-surface-2: #f6f1e5;
  --gx-ink: #181712;
  --gx-ink-2: #43403a;
  --gx-muted: #736c5d;
  --gx-line: #e4ddcb;
  --gx-line-2: #d6cdb5;
  --gx-shadow: 0 1px 2px rgba(24,23,18,.05), 0 14px 34px rgba(24,23,18,.09);
  --gx-shadow-sm: 0 1px 2px rgba(24,23,18,.05);

  --disp: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'General Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --gx-top: 56px;      /* set by JS to the shared topnav height */
  --gx-tools-h: 54px;  /* set by JS */
  --gx-r: 12px;
  --gx-r-sm: 8px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* dark chrome — pinned via [data-gx-theme], and as the system default when un-pinned */
:root[data-gx-theme="dark"] {
  --gx-bg: #16140f;
  --gx-surface: #201d16;
  --gx-surface-2: #26221a;
  --gx-ink: #efe9db;
  --gx-ink-2: #c7bda9;
  --gx-muted: #948b78;
  --gx-line: #383226;
  --gx-line-2: #4a4234;
  --gx-shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.5);
  --gx-shadow-sm: 0 1px 2px rgba(0,0,0,.35);
}

/* ---------------- category colour map ---------------- */
.c-med   { --cat: var(--teal);    --cat-d: var(--teal-d); }
.c-surg  { --cat: var(--tomato);  --cat-d: var(--tomato-d); }
.c-og    { --cat: var(--mustard); --cat-d: var(--mustard-d); }
.c-paeds { --cat: var(--chalk);   --cat-d: var(--chalk-d); }
.c-psych { --cat: var(--plum);    --cat-d: var(--plum-d); }
.c-other { --cat: var(--gx-ink-2);--cat-d: var(--gx-ink); }
.gx-navgroup, .gx-modhead, .gx-content {
  --cat-soft: color-mix(in srgb, var(--cat) 12%, var(--gx-surface));
  --cat-line: color-mix(in srgb, var(--cat) 34%, var(--gx-surface));
  --cat-ink:  color-mix(in srgb, var(--cat) 62%, var(--gx-ink));
}

/* ---------------- page ground ---------------- */
body.gx-body {
  margin: 0;
  background: var(--gx-bg);
  color: var(--gx-ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  transition: background .2s var(--ease), color .2s var(--ease);
}
body.gx-body .mono { font-family: var(--mono); }
.gx *, .gx-modal *, .gx-lightbox * { box-sizing: border-box; }
.gx button { font-family: inherit; }
body.gx-body ::selection { background: color-mix(in srgb, var(--mustard) 40%, transparent); }
.gx :focus-visible,
.gx-modal :focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; border-radius: 3px; }

/* ---------------- tools bar (secondary, under the shared topnav) ---------------- */
.gx-tools {
  position: sticky; top: var(--gx-top); z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 26px;
  background: color-mix(in srgb, var(--gx-bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--gx-line);
}
.gx-brand { display: flex; flex-direction: column; line-height: 1.05; flex: 0 0 auto; }
.gx-brand .gx-kicker { font-size: 13px; font-weight: 600; letter-spacing: .16em; color: var(--tomato); }
.gx-brand .gx-tagline { font-size: 11px; color: var(--gx-muted); margin-top: 2px; white-space: nowrap; }

.gx-search { flex: 1; max-width: 460px; position: relative; display: flex; }
.gx-search input {
  width: 100%; padding: 9px 32px 9px 34px;
  border: 1px solid var(--gx-line-2); border-radius: var(--gx-r-sm);
  background: var(--gx-surface); color: var(--gx-ink);
  font-family: var(--body); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.gx-search input::placeholder { color: var(--gx-muted); }
.gx-search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent); }
.gx-search::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gx-muted); font-size: 17px; pointer-events: none;
}
.gx-searchclear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--gx-muted); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.gx-searchclear:hover { color: var(--tomato); }

.gx-mode {
  display: inline-flex; flex: 0 0 auto; padding: 3px; gap: 2px;
  background: var(--gx-surface-2); border: 1px solid var(--gx-line-2); border-radius: 999px;
}
.gx-mode button {
  font-family: var(--body); font-size: 12.5px; font-weight: 600;
  padding: 6px 13px; border-radius: 999px; border: none; cursor: pointer;
  background: transparent; color: var(--gx-ink-2); white-space: nowrap; transition: .14s var(--ease);
}
.gx-mode button:hover:not(.active) { color: var(--gx-ink); }
.gx-mode button.active { background: var(--gx-ink); color: var(--gx-bg); }

.gx-revise {
  flex: 0 0 auto; font-size: 13px; font-weight: 600; padding: 8px 13px; border-radius: var(--gx-r-sm);
  border: 1px solid var(--gx-line-2); background: var(--gx-surface); color: var(--gx-ink-2);
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; transition: .14s;
}
.gx-revise:hover, .gx-revise.has { border-color: var(--tomato); color: var(--tomato); }
.gx-revise .ct, .gx-revise #gx-revise-count {
  font-family: var(--mono); font-size: 11px; font-weight: 600; min-width: 18px; text-align: center;
  background: var(--gx-surface-2); color: var(--gx-muted); border-radius: 999px; padding: 1px 6px;
}
.gx-revise.has #gx-revise-count { background: var(--tomato); color: #fff; }

.gx-theme {
  flex: 0 0 auto; width: 38px; height: 38px; padding: 0; font-size: 17px; line-height: 1;
  border: 1px solid var(--gx-line-2); border-radius: var(--gx-r-sm);
  background: var(--gx-surface); color: var(--gx-ink-2); cursor: pointer; transition: .14s;
}
.gx-theme:hover { border-color: var(--teal); color: var(--teal); }

.gx-navtoggle {
  display: none; flex: 0 0 auto; width: 38px; height: 38px; padding: 0; gap: 4px;
  flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--gx-line-2); border-radius: var(--gx-r-sm);
  background: var(--gx-surface); cursor: pointer;
}
.gx-navtoggle span { display: block; width: 17px; height: 2px; background: var(--gx-ink-2); border-radius: 2px; transition: .2s; }
body.gx-navopen .gx-navtoggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.gx-navopen .gx-navtoggle span:nth-child(2) { opacity: 0; }
body.gx-navopen .gx-navtoggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------------- layout ---------------- */
.gx-layout {
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
  align-items: start; max-width: 1280px; margin: 0 auto;
}
.gx-drawer { display: contents; }
.gx-drawer[hidden] { display: none; }
.gx-drawer-close { display: none; }
.gx-side {
  position: sticky; top: calc(var(--gx-top) + var(--gx-tools-h)); align-self: start;
  height: calc(100vh - var(--gx-top) - var(--gx-tools-h)); overflow-y: auto;
  padding: 18px 14px 56px; border-right: 1px solid var(--gx-line);
}
.gx-navgroup { margin-bottom: 4px; }
.gx-navgroup h3 {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--cat-d); margin: 16px 10px 7px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.gx-navgroup h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cat); flex: 0 0 auto; }
.gx-navgroup h3::after { content: ""; flex: 1; height: 1px; background: var(--gx-line); }
.gx-navgroup:first-child h3 { margin-top: 2px; }

.gx-modlink {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; padding: 8px 11px; border-radius: var(--gx-r-sm);
  cursor: pointer; font-size: 14px; color: var(--gx-ink-2); background: transparent;
  border: 1px solid transparent; transition: background .12s, color .12s, border-color .12s;
}
.gx-modlink:hover { background: var(--gx-surface-2); color: var(--gx-ink); }
.gx-modlink.active { background: var(--cat-soft); color: var(--cat-d); font-weight: 600; border-color: var(--cat-line); }
.gx-modlink .nm { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.gx-modlink .ct {
  flex: 0 0 auto; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--gx-muted);
  background: var(--gx-surface-2); padding: 1px 8px; border-radius: 999px; min-width: 24px; text-align: center;
}
.gx-modlink.active .ct { color: var(--cat-d); background: var(--gx-surface); }
.gx-modlink.is-locked { color: var(--gx-muted); cursor: pointer; }
.gx-modlink.is-locked:hover { color: var(--tomato); background: var(--gx-surface-2); }
.gx-modlink.is-locked .nm { opacity: .8; }
.gx-modlink .lk { color: var(--gx-muted); display: inline-flex; }
.gx-navnote { font-size: 12px; color: var(--gx-muted); line-height: 1.5; padding: 12px 11px; margin-top: 6px; border-top: 1px solid var(--gx-line); }

.gx-content { padding: 26px 34px 120px; min-width: 0; }

/* ---------------- module header ---------------- */
.gx-modhead { margin-bottom: 4px; }
.gx-modhead .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .16em; color: var(--cat-d); font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.gx-modhead .kicker::before { content: ""; width: 22px; height: 3px; border-radius: 2px; background: var(--cat); }
.gx-modhead h1 { font-family: var(--disp); font-weight: 700; font-size: clamp(26px, 3.4vw, 38px); margin: 0 0 8px; letter-spacing: -.02em; line-height: 1.02; }
.gx-modhead .sub { color: var(--gx-ink-2); font-size: 15px; max-width: 74ch; }
.gx-modhead .countline { color: var(--gx-muted); font-size: 12px; margin-top: 10px; letter-spacing: .02em; }

/* sub-area filter chips */
.gx-subfilter { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 22px; }
.gx-chip {
  font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--gx-surface); border: 1px solid var(--gx-line-2); color: var(--gx-ink-2); transition: .12s;
}
.gx-chip .n { color: var(--gx-muted); font-weight: 500; margin-left: 3px; }
.gx-chip:hover:not(.active) { border-color: var(--cat); color: var(--cat-d); }
.gx-chip.active { background: var(--cat-soft); color: var(--cat-d); border-color: var(--cat-line); font-weight: 700; }
.gx-chip.active .n { color: var(--cat-d); opacity: .7; }

/* ---------------- sub-area section (level-1 collapse) ---------------- */
.gx-subgroup { margin-bottom: 2px; }
.gx-subhead {
  position: sticky; top: calc(var(--gx-top) + var(--gx-tools-h)); z-index: 8;
  width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  font-family: var(--disp); font-weight: 600; font-size: 16px; color: var(--gx-ink-2);
  margin: 22px 0 12px; padding: 8px 0 7px; border: none; border-bottom: 1px solid var(--gx-line);
  background: color-mix(in srgb, var(--gx-bg) 92%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.gx-subgroup:first-child .gx-subhead { margin-top: 4px; }
.gx-subhead:hover .sa-name { color: var(--gx-ink); }
.gx-subhead .sa-name { flex: 0 1 auto; }
.gx-subhead .n { font-family: var(--mono); font-size: 11px; color: var(--gx-muted); font-weight: 600; margin-left: 2px; }
.sa-chev { width: 13px; height: 13px; flex: 0 0 auto; color: var(--gx-muted); transition: transform .18s var(--ease); }
.gx-subgroup.collapsed .sa-chev { transform: rotate(-90deg); }
.gx-subgroup.collapsed .gx-subcards { display: none; }

/* ---------------- cards (dense rows, level-2 collapse) ---------------- */
.gx-cards { display: block; }
.gx-card { position: relative; border-bottom: 1px solid var(--gx-line); transition: background .16s var(--ease); }
.gx-cardhead {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 34px 8px 10px; min-height: 40px; overflow: hidden;
  background: transparent; border: none; cursor: pointer; color: inherit; font: inherit;
}
.gx-cardhead:hover { background: var(--gx-surface-2); }
.gx-cardhead .chev { width: 13px; height: 13px; flex: 0 0 auto; color: var(--gx-muted); transition: transform .18s var(--ease); }
.gx-card.open > .gx-cardhead .chev { transform: rotate(180deg); color: var(--cat, var(--tomato)); }
.ch-title { font-family: var(--disp); font-size: 14.5px; font-weight: 600; color: var(--gx-ink); white-space: nowrap; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.gx-card.open > .gx-cardhead .ch-title { color: var(--cat-d, var(--gx-ink)); }
.ch-hook { font-size: 13px; color: var(--gx-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.ch-hook::before { content: "— "; color: var(--gx-muted); }
.ch-flags { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; margin-left: 6px; }
.ch-img { color: var(--cat-d, var(--teal-d)); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.ch-img svg { display: block; }
.ch-tc { width: 7px; height: 7px; border-radius: 50%; background: var(--tomato); display: inline-block; }

.gx-verified { font-size: 12px; color: var(--teal-d); display: inline-flex; align-items: center; gap: 4px; }
.gx-verified.no { color: var(--mustard-d); }
.gx-verified .vt { font-family: var(--mono); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--gx-muted); }
@media (max-width: 720px) { .gx-verified .vt { display: none; } }

/* raised open card */
.gx-card.open {
  margin: 8px 0; border-bottom: none; border-radius: var(--gx-r);
  background: var(--gx-surface); box-shadow: var(--gx-shadow); border: 1px solid var(--gx-line);
}
.gx-card.tc { box-shadow: inset 3px 0 0 var(--tomato); }
.gx-card.open.tc { border-left: 3px solid var(--tomato); box-shadow: var(--gx-shadow); }

.gx-cardouter { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .26s var(--ease); }
.gx-card.open .gx-cardouter { grid-template-rows: 1fr; }
.gx-cardinner { overflow: hidden; min-height: 0; }
.gx-cardbody { padding: 4px 18px 16px 32px; border-top: 1px solid var(--gx-line); margin-top: 2px; }
.gx-card.open .gx-cardbody { padding-top: 12px; }
@supports not (grid-template-rows: 1fr) {
  .gx-cardouter { display: block; max-height: 0; overflow: hidden; transition: max-height .26s var(--ease); }
  .gx-card.open .gx-cardouter { max-height: 6000px; }
}

/* select checkbox */
.gx-select { position: absolute; top: 10px; right: 11px; z-index: 3; cursor: pointer; line-height: 0; }
.gx-selbox { width: 15px; height: 15px; cursor: pointer; accent-color: var(--tomato); margin: 0; }
.gx-card.selected { background: color-mix(in srgb, var(--tomato) 8%, transparent); }
.gx-card.selected:not(.open) { box-shadow: inset 3px 0 0 var(--tomato); }
.gx-card.selected.open { border-color: color-mix(in srgb, var(--tomato) 40%, var(--gx-line)); }
.gx-card.selected > .gx-cardhead .ch-title { color: var(--tomato-d); }

/* ---------------- tags ---------------- */
.gx-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 12px; }
.gx-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 5px; background: var(--gx-surface-2); color: var(--gx-muted); border: 1px solid var(--gx-line);
}
.gx-tag.tc { background: color-mix(in srgb, var(--tomato) 12%, var(--gx-surface)); color: var(--tomato-d); border-color: color-mix(in srgb, var(--tomato) 30%, var(--gx-surface)); }
.gx-tag.cut { background: color-mix(in srgb, var(--teal) 12%, var(--gx-surface)); color: var(--teal-d); border-color: color-mix(in srgb, var(--teal) 30%, var(--gx-surface)); }

/* ---------------- fields ---------------- */
.gx-field { margin-top: 13px; }
.gx-field:first-child { margin-top: 4px; }
.gx-field .lbl {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
  color: color-mix(in srgb, var(--f, var(--gx-muted)) 66%, var(--gx-ink));
  margin-bottom: 5px; display: flex; align-items: center; gap: 7px;
}
.gx-field .lbl::before { content: ""; width: 12px; height: 2px; border-radius: 2px; background: var(--f, var(--gx-line-2)); }
.gx-field .val { font-size: 14.5px; color: var(--gx-ink); }
.gx-field .val p { margin: 0 0 6px; } .gx-field .val p:last-child { margin-bottom: 0; }
.gx-field .val ul { margin: 5px 0 0; padding-left: 19px; list-style: disc; }
.gx-field .val ul ul { margin: 3px 0; padding-left: 18px; list-style: circle; }
.gx-field .val li { margin: 3px 0; }
.gx-field .val li::marker { color: var(--f, var(--cat, var(--tomato))); }
.gx-field .val strong { font-weight: 700; color: var(--gx-ink); }

.gx-field.trap { --f: var(--mustard); }
.gx-field.redflags { --f: var(--tomato); }
.gx-field.mcq { --f: var(--plum); }
.gx-field.discrim { --f: var(--chalk-d); }
.gx-field.whatfirst { --f: var(--teal); }
.gx-field.cutoffs { --f: var(--teal); }

/* trap + red-flags get a full tinted box */
.gx-field.trap, .gx-field.redflags {
  padding: 11px 14px; border-radius: var(--gx-r-sm);
  background: color-mix(in srgb, var(--f) 11%, var(--gx-surface));
  border: 1px solid color-mix(in srgb, var(--f) 26%, var(--gx-surface));
  border-left: 3px solid var(--f);
}
.gx-field.trap .val, .gx-field.redflags .val { font-size: 14px; }

/* cut-offs as number chips */
.gx-field.cutoffs .val ul { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 5px; }
.gx-field.cutoffs .val li {
  margin: 0; padding: 5px 11px; border-radius: var(--gx-r-sm); position: relative; padding-left: 24px;
  background: color-mix(in srgb, var(--teal) 9%, var(--gx-surface));
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--gx-surface));
  font-size: 13.5px; line-height: 1.4;
}
.gx-field.cutoffs .val li::marker { content: none; }
.gx-field.cutoffs .val li::before {
  content: "#"; position: absolute; left: 9px; top: 5px; font-family: var(--mono);
  font-size: 12px; font-weight: 600; color: var(--teal-d);
}
.gx-trapans { margin-top: 8px !important; font-size: 13.5px; color: var(--gx-ink-2); }
.gx-trapans b { color: var(--plum); }

/* VIVA block */
.gx-viva {
  margin-top: 15px; padding: 12px 14px; border-radius: var(--gx-r-sm);
  background: color-mix(in srgb, var(--teal) 11%, var(--gx-surface));
  border: 1px solid color-mix(in srgb, var(--teal) 26%, var(--gx-surface));
  border-left: 3px solid var(--teal);
}
.gx-viva .lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--teal-d); margin-bottom: 5px; }
.gx-viva .val { font-size: 14px; }
.gx-viva .val p { margin: 0 0 6px; } .gx-viva .val p:last-child { margin-bottom: 0; }
.gx-viva .val ul { margin: 5px 0 0; padding-left: 19px; } .gx-viva .val li { margin: 3px 0; }
.gx-viva .val strong { color: var(--gx-ink); font-weight: 700; }

/* mnemonic block */
.gx-mnemonic {
  margin-top: 15px; padding: 12px 14px; border-radius: var(--gx-r-sm);
  background: color-mix(in srgb, var(--mustard) 14%, var(--gx-surface));
  border: 1px solid color-mix(in srgb, var(--mustard) 30%, var(--gx-surface));
  border-left: 3px solid var(--mustard);
}
.gx-mnemonic .lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--mustard-d); margin-bottom: 5px; }
.gx-mnemonic .val { font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.gx-mnemonic .val strong { color: var(--gx-ink); }

.gx-source { margin-top: 15px; padding-top: 11px; border-top: 1px dashed var(--gx-line-2); font-size: 12px; color: var(--gx-muted); }
.gx-source b { color: var(--gx-ink-2); font-weight: 600; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-right: 6px; }

/* card tools (read-aloud) */
.gx-cardtools { margin-top: 14px; }
.gx-speak {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--gx-surface-2); border: 1px solid var(--gx-line-2); color: var(--gx-ink-2); transition: .14s;
}
.gx-speak:hover { border-color: var(--teal); color: var(--teal-d); }
.gx-speak.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.gx-speak svg { display: block; }

/* ---------------- image gallery + lightbox ---------------- */
.gx-gallery { display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-start; margin: 6px 0 13px; }
.gx-img, .gx-gallery.multi .gx-img { flex: 0 0 auto; width: 156px; max-width: 156px; margin: 0; }
.gx-img img {
  width: 156px; height: 116px; object-fit: contain; background: var(--gx-surface);
  border: 1px solid var(--gx-line); border-radius: var(--gx-r-sm); cursor: zoom-in; display: block;
}
.gx-img figcaption { max-width: 156px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; margin-top: 3px; color: var(--gx-muted); }
.gx-lightbox {
  position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center;
  background: rgba(18,13,7,.88); padding: 4vmin; cursor: zoom-out;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.gx-lightbox.open { display: flex; }
.gx-lightbox figure { margin: 0; max-width: 92vw; display: flex; flex-direction: column; align-items: center; }
.gx-lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 10px; box-shadow: 0 14px 44px rgba(0,0,0,.55); background: #fff; }
.gx-lightbox figcaption { color: #f1ebe0; font-size: 13px; margin-top: 11px; text-align: center; max-width: 72ch; line-height: 1.45; }
.gx-lightbox figcaption b { color: #fff; }
.gx-lbclose { position: fixed; top: 15px; right: 19px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.gx-lbclose:hover { background: rgba(255,255,255,.26); }

/* ---------------- gv-* authored visual blocks (Circuit reskin) ---------------- */
.gx-gv { margin-top: 14px; }
.gx-gv .gv-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0; }
.gx-gv .gv-table th, .gx-gv .gv-table td { border: 1px solid var(--gx-line-2); padding: 6px 9px; text-align: left; vertical-align: top; }
.gx-gv .gv-table thead th, .gx-gv .gv-table tr:first-child th {
  background: color-mix(in srgb, var(--teal) 12%, var(--gx-surface)); color: var(--teal-d); font-weight: 700;
}
.gx-gv .gv-table tbody tr:nth-child(even), .gx-gv .gv-table tr:nth-child(even) { background: var(--gx-surface-2); }
.gx-gv .gv-flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; margin: 8px 0; }
.gx-gv .gv-step {
  position: relative; background: color-mix(in srgb, var(--teal) 12%, var(--gx-surface));
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--gx-surface));
  color: var(--teal-d); font-size: 12.5px; font-weight: 600; padding: 7px 12px; margin: 0 18px 9px 0; border-radius: var(--gx-r-sm); line-height: 1.3;
}
.gx-gv .gv-step::after { content: "→"; position: absolute; right: -15px; top: 50%; transform: translateY(-50%); color: var(--tomato); font-weight: 700; }
.gx-gv .gv-step:last-child { margin-right: 0; }
.gx-gv .gv-step:last-child::after { content: ""; }
.gx-gv .gv-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.gx-gv .gv-pill { font-size: 12px; padding: 4px 11px; border-radius: 999px; background: var(--gx-surface-2); border: 1px solid var(--gx-line-2); color: var(--gx-ink-2); }
.gx-gv .gv-num, .gx-field .gv-num, .gx-viva .gv-num {
  font-family: var(--mono); font-weight: 600; color: var(--teal-d);
  background: color-mix(in srgb, var(--teal) 14%, var(--gx-surface)); padding: 0 5px; border-radius: 5px; white-space: nowrap;
}

/* ---------------- lock / upgrade banner ---------------- */
.gx-lockbanner {
  display: flex; gap: 18px; align-items: flex-start;
  background: var(--gx-ink); color: var(--gx-bg); border-radius: var(--gx-r); padding: 22px 24px; margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.gx-lockbanner.flash { animation: gxflash .9s var(--ease); }
@keyframes gxflash { 0%,100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--mustard) 70%, transparent); } }
.gx-lockbanner .lb-mark { flex: 0 0 auto; font-size: 11px; letter-spacing: .16em; font-weight: 600; color: var(--mustard); border: 1px solid color-mix(in srgb, var(--mustard) 50%, transparent); border-radius: 4px; padding: 4px 8px; margin-top: 2px; }
.gx-lockbanner .lb-body h2 { font-family: var(--disp); font-weight: 700; font-size: 20px; margin: 0 0 6px; letter-spacing: -.01em; }
.gx-lockbanner .lb-body p { font-size: 14px; color: #d9d3c7; line-height: 1.5; max-width: 70ch; margin: 0 0 14px; }
.gx-lockbanner .lb-body b { color: var(--mustard); }
.gx-lockbanner .lb-btn { display: inline-block; background: var(--mustard); color: var(--gx-ink); font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 4px; transition: filter .14s; }
.gx-lockbanner .lb-btn:hover { filter: brightness(1.06); }

/* ---------------- empty / loading ---------------- */
.gx-empty { padding: 60px 20px; text-align: center; color: var(--gx-muted); }
.gx-empty .big { font-family: var(--disp); font-weight: 700; font-size: 22px; color: var(--gx-ink-2); margin-bottom: 8px; }

/* ---------------- scrim ---------------- */
.gx-scrim { position: fixed; inset: 0 0 0 0; z-index: 25; background: rgba(20,16,10,.4); border: 0; }
.gx-scrim[hidden] { display: none; }

/* ---------------- revise modal ---------------- */
.gx-modal { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center; background: rgba(20,15,8,.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); padding: 4vmin; }
.gx-modal[hidden] { display: none; }
.gx-panel { background: var(--gx-surface); border: 1px solid var(--gx-line-2); border-radius: var(--gx-r); box-shadow: var(--gx-shadow); width: min(680px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.gx-panelhead { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--gx-line); }
.gx-panelhead h2 { font-family: var(--disp); font-weight: 700; font-size: 19px; margin: 0; }
.gx-panelhead h2 span { color: var(--tomato); }
.gx-panelx { border: none; background: transparent; font-size: 24px; line-height: 1; color: var(--gx-muted); cursor: pointer; padding: 0 4px; }
.gx-panelx:hover { color: var(--tomato); }
.gx-reviseempty { padding: 16px 18px; color: var(--gx-muted); font-size: 14px; }
.gx-reviselist { padding: 10px 18px 4px; overflow-y: auto; max-height: 28vh; display: flex; flex-direction: column; gap: 5px; }
.gx-reviseitem { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; padding: 6px 10px; background: var(--gx-surface-2); border: 1px solid var(--gx-line); border-radius: var(--gx-r-sm); }
.gx-reviseitem em { color: var(--gx-muted); font-style: normal; font-size: 11px; font-family: var(--mono); }
.gx-reviserm { border: none; background: transparent; color: var(--gx-muted); font-size: 18px; line-height: 1; cursor: pointer; }
.gx-reviserm:hover { color: var(--tomato); }
.gx-revisetext { margin: 8px 18px; min-height: 130px; max-height: 32vh; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; padding: 11px 12px; border: 1px solid var(--gx-line-2); border-radius: var(--gx-r-sm); background: var(--gx-surface-2); color: var(--gx-ink); }
.gx-reviseactions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--gx-line); }
.gx-reviseactions button { font-size: 13.5px; font-weight: 600; padding: 9px 15px; border-radius: var(--gx-r-sm); border: 1px solid var(--tomato); background: var(--tomato); color: #fff; cursor: pointer; transition: filter .14s; }
.gx-reviseactions button:hover { filter: brightness(1.06); }
.gx-reviseactions button.ghost { background: transparent; color: var(--gx-ink-2); border-color: var(--gx-line-2); margin-left: auto; }
.gx-reviseactions button.ghost:hover { border-color: var(--tomato); color: var(--tomato); filter: none; }

/* ---------------- footer ---------------- */
.gx-foot { background: transparent; color: var(--gx-muted); padding: 30px 34px 60px; font-size: 12px; line-height: 1.6; border-top: 1px solid var(--gx-line); max-width: 1280px; margin: 0 auto; }
.gx-foot a { color: var(--gx-ink-2); }
.gx-foot a:hover { color: var(--gx-ink); }

/* ---------------- responsive ---------------- */
/* SPLASH generation — dense study reference in warm, calm chrome. */
body.gx-body.splash-student {
  --gx-bg: var(--cc-canvas);
  --gx-surface: var(--cc-surface);
  --gx-surface-2: var(--cc-surface-subtle);
  --gx-ink: var(--cc-ink);
  --gx-ink-2: var(--cc-ink-secondary);
  --gx-muted: var(--cc-ink-muted);
  --gx-line: var(--cc-separator);
  --gx-line-2: var(--cc-separator-strong);
  --gx-shadow: var(--splash-shadow-warm);
  --gx-shadow-sm: var(--cc-shadow-sm);
  --gx-r: 20px;
  --gx-r-sm: 12px;
  --disp: var(--cc-display-font);
  --body: var(--cc-font);
  --mono: var(--cc-data-font);
  background: var(--cc-canvas);
  color: var(--cc-ink);
}
:root[data-gx-theme='dark'] body.gx-body.splash-student,
html[data-theme='dark'] body.gx-body.splash-student {
  --gx-bg: var(--cc-canvas);
  --gx-surface: var(--cc-surface);
  --gx-surface-2: var(--cc-surface-subtle);
  --gx-ink: var(--cc-ink);
  --gx-ink-2: var(--cc-ink-secondary);
  --gx-muted: var(--cc-ink-muted);
  --gx-line: var(--cc-separator);
  --gx-line-2: var(--cc-separator-strong);
  --gx-shadow: var(--splash-shadow-warm);
}
body.gx-body.splash-student .gx-tools {
  padding-block: 9px;
  border-bottom-color: var(--cc-separator);
  background: color-mix(in srgb, var(--cc-canvas) 92%, transparent);
}
body.gx-body.splash-student .gx-brand .gx-kicker {
  color: var(--cc-primary);
  font-family: var(--cc-display-font);
  font-weight: 750;
}
body.gx-body.splash-student :is(.gx-search input, .gx-revise, .gx-theme, .gx-navtoggle) {
  border-color: var(--cc-separator-strong);
  border-radius: 12px;
  background: var(--cc-surface);
  color: var(--cc-ink-secondary);
}
body.gx-body.splash-student .gx-mode {
  border-color: var(--cc-separator);
  background: var(--cc-surface-subtle);
}
body.gx-body.splash-student .gx-mode button.active { background: var(--cc-ink); color: var(--cc-canvas); }
body.gx-body.splash-student .gx-side { border-right-color: var(--cc-separator); }
body.gx-body.splash-student .gx-modlink { border-radius: 12px; }
body.gx-body.splash-student .gx-modhead h1 {
  color: var(--cc-ink);
  font-family: var(--cc-display-font);
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 800;
  letter-spacing: -.03em;
}
body.gx-body.splash-student .gx-subhead {
  border-color: var(--cc-separator);
  background: color-mix(in srgb, var(--cc-canvas) 94%, transparent);
  font-family: var(--cc-display-font);
  font-size: 18px;
}
body.gx-body.splash-student .gx-card.open {
  border-color: var(--cc-separator);
  border-radius: 20px;
  background: var(--cc-surface);
  box-shadow: var(--splash-shadow-warm);
}
body.gx-body.splash-student .gx-card.open::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  border-radius: 20px 20px 0 0;
  background: var(--splash-grad-sunrise);
  content: '';
}
body.gx-body.splash-student .gx-cardhead { border-radius: 18px; }
body.gx-body.splash-student .ch-title { font-family: var(--cc-display-font); font-weight: 700; }
body.gx-body.splash-student .gx-panel {
  border-color: var(--cc-separator);
  border-radius: var(--splash-r-card);
  background: var(--cc-surface);
  box-shadow: var(--splash-shadow-warm);
}
body.gx-body.splash-student .gx-lockbanner { border-radius: var(--splash-r-card); animation: none; }
body.gx-body.splash-student :is(.gx-card, .gx-cardouter, .gx-cardhead, .gx-subhead, .sa-chev) { transition: none; }

@media (prefers-reduced-motion: no-preference) {
  body.gx-body.splash-student :is(.gx-cardhead, .gx-subhead) {
    transition: background-color .16s ease, color .16s ease;
  }
}

@media (max-width: 900px) {
  .gx-drawer { display: block; position: fixed; inset: 0; z-index: 45; }
  .gx-drawer-close { display: block; min-height: var(--control-height); margin-bottom: var(--space-4); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text); font: 600 var(--type-label)/var(--leading-body) var(--font-body); }
  .gx-navtoggle { display: flex; }
  .gx-brand .gx-tagline { display: none; }
  .gx-layout { display: block; }
  .gx-side {
    position: fixed; top: var(--gx-top); left: 0; z-index: 40;
    width: 280px; max-width: 84vw; height: calc(100vh - var(--gx-top));
    background: var(--gx-surface); border-right: 1px solid var(--gx-line);
    transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--gx-shadow);
  }
  body.gx-navopen .gx-side { transform: translateX(0); }
  .gx-content { padding: 22px 18px 100px; }
  .gx-subhead, .gx-side { top: calc(var(--gx-top) + var(--gx-tools-h)); }
  body.gx-navopen .gx-side { top: var(--gx-top); }
}
@media (max-width: 620px) {
  .gx-tools { gap: 10px; padding: 9px 14px; }
  .gx-brand { display: none; }
  .gx-mode button { padding: 6px 10px; }
  .gx-content { padding: 18px 13px 90px; }
  .gx-cardhead { flex-wrap: wrap; min-height: 44px; padding: 9px 34px 9px 11px; }
  .ch-title { flex: 1 1 auto; }
  .ch-flags { order: 1; }
  .ch-hook { display: block; flex: 1 0 100%; order: 2; white-space: normal; margin: 1px 0 0 22px; font-size: 12.5px; line-height: 1.34; }
  .ch-hook::before { content: ""; }
  .gx-img, .gx-gallery.multi .gx-img { width: 47%; max-width: 47%; }
  .gx-img img { width: 100%; height: 104px; }
  .gx-lockbanner { flex-direction: column; gap: 12px; }
}
@media (max-width: 520px) {
  .gx-tools { flex-wrap: wrap; min-width: 0; }
  .gx-tools > *, .gx-search, .gx-mode { min-width: 0; max-width: 100%; }
  .gx-search { flex: 1 1 100%; width: 100%; }
}
@media (max-width: 400px) {
  .gx-search { max-width: none; }
  .gx-revise span:not(#gx-revise-count) { display: none; }
}
@media (pointer: coarse) { .gx-cardhead { min-height: 44px; } }

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  body.gx-body *, .gx-modal *, .gx-lightbox * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------------- system dark default (only when the user hasn't pinned a theme) ---------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-gx-theme="light"]) {
    --gx-bg: #16140f;
    --gx-surface: #201d16;
    --gx-surface-2: #26221a;
    --gx-ink: #efe9db;
    --gx-ink-2: #c7bda9;
    --gx-muted: #948b78;
    --gx-line: #383226;
    --gx-line-2: #4a4234;
    --gx-shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.5);
    --gx-shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  }
}

/* attribute [hidden] must beat author display rules (else upsell/modals leak) */
[hidden]{display:none!important}

body.gx-body.splash-student .gx-card, body.gx-body.splash-student .gx-toolbar, body.gx-body.splash-student .gx-main { box-shadow: none; }
body.gx-body .ch-title { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; }
body.gx-body .gx-verified .vt { display: inline; font-family: inherit; font-size: 12px; text-transform: none; letter-spacing: 0; }
body.gx-body .ch-flags { flex-wrap: wrap; }
@media (max-width: 720px) { body.gx-body .gx-cardhead { flex-wrap: wrap; gap: 8px; } body.gx-body .ch-flags { margin-left: 24px; } }

/* Reserve the reading area while the catalogue loads; defer offscreen layout. */
.gx-content { min-height: calc(100svh - 160px); }
.gx-card { content-visibility: auto; contain-intrinsic-size: auto 90px; }
.gx-card.open { contain-intrinsic-size: auto 600px; }
@media print { .gx-card { content-visibility: visible; } }
