
/* Layout: the PP Rehearsal console, reused for study. Sticky header with modes and a study clock, a topic strip,
   then picture + key line + source slides on the left, and the lesson point by point on the right. */
:root {
  --bg: #F3F5F9; --surface: #FFFFFF; --sunk: #E8ECF3; --line: #D5DCE8;
  --fg: #0B1220; --muted: #586378; --accent: #1D4ED8; --accent-soft: #DCE6FD;
  --good: #047857; --good-soft: #D7F2E6; --warn: #B45309; --warn-soft: #FDEBD3; --over: #B91C1C;
  --f-display: "Archivo", "Noto Sans Sinhala", "Arial Narrow", Arial, sans-serif;
  --f-script: "Source Serif 4", "Noto Serif Sinhala", Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", Consolas, "Noto Sans Sinhala", "Courier New", monospace;
  --r: 10px;
}
/* Three themes, picked in the header and remembered: White (the default above), Blue (navy dark) and OLED (true black).
   With no choice saved and no script, the page follows the device's dark setting with the Blue theme. */
@media (prefers-color-scheme: dark) { :root:not([data-theme]) {
  --bg: #070A12; --surface: #0E1420; --sunk: #0A0F19; --line: #1E293B;
  --fg: #EEF2F8; --muted: #94A0B6; --accent: #60A5FA; --accent-soft: #13233F;
  --good: #34D399; --good-soft: #0D2A20; --warn: #F5A524; --warn-soft: #2E2210; --over: #F87171; color-scheme: dark } }
:root[data-theme="light"] { color-scheme: light }
:root[data-theme="dark"], :root[data-theme="blue"] {
  --bg: #070A12; --surface: #0E1420; --sunk: #0A0F19; --line: #1E293B;
  --fg: #EEF2F8; --muted: #94A0B6; --accent: #60A5FA; --accent-soft: #13233F;
  --good: #34D399; --good-soft: #0D2A20; --warn: #F5A524; --warn-soft: #2E2210; --over: #F87171; color-scheme: dark }
:root[data-theme="oled"] {
  --bg: #000000; --surface: #0A0A0B; --sunk: #141416; --line: #26262B;
  --fg: #F2F2F3; --muted: #9B9BA3; --accent: #60A5FA; --accent-soft: #0F1D33;
  --good: #34D399; --good-soft: #06231A; --warn: #F5A524; --warn-soft: #261B08; --over: #F87171; color-scheme: dark }

* { box-sizing: border-box }
[hidden] { display: none !important }
html { scroll-padding-top: env(safe-area-inset-top, 0px) }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--f-display); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0 }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface) }
button { font: inherit; color: inherit; cursor: pointer }
button:focus-visible, [tabindex]:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
code, .mono { font-family: var(--f-mono); font-size: .88em }
code { background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; white-space: pre-wrap; word-break: break-word }

header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line) }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-block: 10px }
.brand { display: flex; flex-direction: column; min-width: 0; margin-right: auto }
.brand b { font-weight: 700; font-size: 17px; letter-spacing: .01em }
.brand span { font-size: 12px; color: var(--muted) }
.modes { display: flex; gap: 2px; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 3px; overflow-x: auto; max-width: 100% }
.modes button { border: 0; background: none; padding: 6px 13px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap }
.modes button[aria-pressed="true"] { background: var(--accent); color: var(--surface) }
.prefs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.theme { display: flex; align-items: center; gap: 2px; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 3px }
.theme button { border: 0; background: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; padding: 0 }
.theme button[aria-pressed="true"] { background: var(--accent) }
.theme .sw { width: 16px; height: 16px; border-radius: 50%; display: block; border: 1px solid rgba(128,128,128,.55) }
.sw-light { background: #FFFFFF } .sw-blue { background: #1E3A8A } .sw-oled { background: #000000 }
.lang { display: flex; align-items: center; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 3px }
.lang button { border: 0; background: none; padding: 5px 11px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap }
.lang i { width: 1px; height: 14px; background: var(--line); margin: 0 1px }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--surface) }
/* Sinhala needs a little more line height for vowel signs above and below the letters. */
:root[lang="si"] body { line-height: 1.65 }
.clock { display: flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: 13px }
.clock .t { font-variant-numeric: tabular-nums; padding: 5px 9px; border-radius: 6px; background: var(--sunk); border: 1px solid var(--line); white-space: nowrap }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-weight: 600; font-size: 13.5px }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface) }
.btn.sm { border-radius: 999px; padding: 5px 12px; font-size: 12.5px; line-height: 1.3 }
.btn:disabled { opacity: .45; cursor: default }

.strip { display: flex; gap: 3px; padding-block: 0 10px; overflow-x: auto }
.seg { flex: 1 1 0; min-width: 40px; border: 0; padding: 0; background: none; text-align: left }
.seg i { display: block; height: 8px; border-radius: 3px; background: var(--line) }
.seg span { display: block; font-size: 10.5px; color: var(--muted); padding-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--f-mono) }
.seg.lecstart { margin-left: 6px }
.seg.done i { background: var(--accent-soft) }
.seg.cur i { background: var(--accent) }
.seg.cur span { color: var(--fg); font-weight: 600 }

main { padding-block: 20px 48px }
.view[hidden] { display: none }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 24px; align-items: start }
.stage > * { min-width: 0 }
@media (max-width: 860px) { .stage { grid-template-columns: minmax(0, 1fr) } }

.eyebrow { font-family: var(--f-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.15; margin: 4px 0 12px; text-wrap: balance; font-weight: 700 }
h2 { text-wrap: balance }
.fig { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); align-items: center }
.fig img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #FFFFFF }
.fig figcaption { padding: 12px 16px; font-family: var(--f-script); font-size: 16px; line-height: 1.45 }
.fig figcaption small { display: block; font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 6px }
@media (max-width: 520px) { .fig { grid-template-columns: 1fr } .fig img { aspect-ratio: 16/10 } }
.diagram { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 10px; overflow-x: auto }
.diagram .dcap { font-size: 12.5px; color: var(--muted); font-family: var(--f-mono); margin-bottom: 4px }
svg .bx { fill: var(--sunk); stroke: var(--line) }
svg .tx { fill: var(--fg); font: 13px var(--f-display) }
svg .tm { fill: var(--muted); font: 12px var(--f-mono) }
svg .ln { stroke: var(--accent); stroke-width: 1.6; fill: none }
svg .ln.hl { stroke: var(--good); stroke-width: 2.6 }
svg .ln.dim { stroke: var(--line) }
svg .cA { fill: var(--accent); fill-opacity: .14; stroke: var(--accent) }
svg .cB { fill: var(--good); fill-opacity: .14; stroke: var(--good) }
svg .mk { fill: var(--accent) }
svg .unused { fill: var(--muted) }
.key { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0 }
.key small { display: block; font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px }
.key p { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; text-wrap: balance }
.anchors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px }
.anchors span { font-family: var(--f-mono); font-size: 12.5px; padding: 4px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--fg) }
.srcs { margin-top: 16px }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 4px }
.thumb { flex: 0 0 auto; width: 128px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0; overflow: hidden; text-align: left; position: relative }
.thumb img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #FFFFFF }
.thumb span { display: block; font: 11px var(--f-mono); color: var(--muted); padding: 3px 6px }
.thumb.flagged::after { content: "!"; position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--warn); color: var(--surface); font: 700 12px/18px var(--f-mono); text-align: center }
.playlink { margin-top: 12px }

.script { display: flex; flex-direction: column; gap: 10px; min-width: 0 }
.script-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap }
.seg3 { display: flex; gap: 2px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 2px }
.seg3 button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: var(--muted) }
.seg3 button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12) }
.budget { font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; transition: border-color .15s, opacity .15s; cursor: pointer }
.step.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) }
.step.past { opacity: .62 }
.step.future { opacity: .9 }
.step .sh { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap }
.chip { font-family: var(--f-mono); font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 9px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); color: var(--muted); text-transform: uppercase }
.step.cur .chip.layer { background: var(--accent); border-color: var(--accent); color: var(--surface) }
.src { font-family: var(--f-mono); font-size: 11.5px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--accent); background: none; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap }
.src:hover { background: var(--accent-soft) }
.src svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2 }
.extra { font-family: var(--f-mono); font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: var(--sunk); color: var(--muted); border: 1px dashed var(--line); text-transform: uppercase; letter-spacing: .04em }
.sh .srcwrap { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap }
.step .body { font-family: var(--f-script); font-size: 17px; line-height: 1.55; overflow-wrap: anywhere }
.step .body code { font-size: 13.5px }
.step.flag { background: var(--warn-soft); border-color: var(--warn) }
.step.flag .chip.layer { background: var(--warn); border-color: var(--warn); color: var(--surface) }
.step.chk .ans { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line) }
.step.hidden .body { filter: blur(6px); user-select: none; opacity: .5 }
.recall-note { font-size: 13px; color: var(--muted); margin: 0 }

.nav { position: fixed; z-index: 6; display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18) }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; display: block }
.nav .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px }
.nav .hint { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap }
.nav #dock .lb { font-family: var(--f-mono); font-size: 12px }
.nav[data-dock="bottom"] { left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom, 0px)); width: max-content; max-width: calc(100vw - 32px) }
.nav[data-dock="bottom"] .ic { display: none }
.nav[data-dock="bottom"] #next { min-width: 152px }
.nav[data-dock="bottom"] #dock { order: 9 }
@media (max-width: 720px) { .nav[data-dock="bottom"] .hint { display: none } }
.nav[data-dock="right"], .nav[data-dock="left"] { top: 50%; transform: translateY(-50%); flex-direction: column; padding: 8px; border-radius: 999px }
.nav[data-dock="right"] { right: max(16px, env(safe-area-inset-right, 0px)) }
.nav[data-dock="left"] { left: max(16px, env(safe-area-inset-left, 0px)) }
.nav[data-dock="right"] .lb, .nav[data-dock="left"] .lb, .nav[data-dock="right"] .hint, .nav[data-dock="left"] .hint { display: none }
.nav[data-dock="right"] .btn, .nav[data-dock="left"] .btn { width: 52px; height: 52px; padding: 0; border-radius: 50% }
.nav[data-dock="right"] #nslide, .nav[data-dock="left"] #nslide { order: 1 }
.nav[data-dock="right"] #next, .nav[data-dock="left"] #next { order: 2 }
.nav[data-dock="right"] #pprev, .nav[data-dock="left"] #pprev { order: 3 }
.nav[data-dock="right"] #prev, .nav[data-dock="left"] #prev { order: 4 }
.nav[data-dock="right"] #dock, .nav[data-dock="left"] #dock { order: 5; width: 40px; height: 40px; margin-top: 6px }
.nav[data-dock="right"] #dock svg, .nav[data-dock="left"] #dock svg { width: 18px; height: 18px }
@media (max-width: 1400px) {
  body[data-dock="right"] main.wrap { padding-right: max(84px, env(safe-area-inset-right, 0px)) }
  body[data-dock="left"] main.wrap { padding-left: max(84px, env(safe-area-inset-left, 0px)) }
}
body[data-dock="bottom"] #v-learn { padding-bottom: 72px }
body:not([data-mode="learn"]) .nav { display: none }
body:not([data-mode="learn"]) main.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
kbd { font-family: var(--f-mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--sunk) }

details.qa { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r) }
details.qa + details.qa { margin-top: 8px }
details.qa summary { padding: 10px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 8px }
details.qa summary::before { content: "Q"; font-family: var(--f-mono); color: var(--accent) }
details.qa[open] summary { border-bottom: 1px solid var(--line) }
details.qa .qa-a { padding: 10px 14px 12px; font-family: var(--f-script); font-size: 16px }
details.qa .qa-src { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px }
.qa-title { margin: 22px 0 10px }

.drill { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px }
.drill-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between }
.meter { flex: 1 1 160px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 0 }
.meter i { display: block; height: 100%; background: var(--good); width: 0 }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px }
.card .from { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-family: var(--f-mono); font-size: 12px; color: var(--muted) }
.card h2 { font-size: clamp(19px, 2.4vw, 24px); line-height: 1.3; margin: 8px 0 16px; font-weight: 600; overflow-wrap: anywhere }
.card h2 code { font-size: 15px }
.card .ans { font-family: var(--f-script); font-size: 18px; line-height: 1.55; padding-top: 14px; border-top: 1px solid var(--line); overflow-wrap: anywhere }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px }
.card .row .push { margin-left: auto }
/* Working pad under each drill question: typed notes plus a sketch, saved per question. */
.pad { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px }
.pad-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap }
.pad-saved { font-size: 12px; color: var(--muted) }
.pad textarea { width: 100%; box-sizing: border-box; min-height: 96px; resize: vertical; font-family: var(--f-mono); font-size: 14px; line-height: 1.5; color: var(--fg); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px }
.pad textarea:focus, .pad canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.pad-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.pad-tools .eyebrow { margin-right: 4px }
.pad-tools .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent) }
.pad canvas { display: block; width: 100%; aspect-ratio: 8 / 5; touch-action: none; cursor: crosshair; color: var(--fg); background: var(--sunk); border: 1px solid var(--line); border-radius: 8px }
.own { display: inline-block; margin-top: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); border: 1px dashed var(--line); border-radius: 5px; padding: 2px 7px }
select { font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 8px; padding: 5px 8px; max-width: 100% }
.note { color: var(--muted); font-size: 14px; margin: 0 0 16px; max-width: 70ch }

/* Machines */
.mlist { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px }
.mlist button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft) }
.mhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-bottom: 14px }
.mhead img { width: 120px; height: 120px; border-radius: var(--r); object-fit: cover; border: 1px solid var(--line); background: #FFFFFF }
.mhead p { margin: 4px 0 0; font-family: var(--f-script); font-size: 16px; max-width: 70ch }
.chunks { display: flex; flex-direction: column; gap: 10px }
.chunk { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface) }
@media (max-width: 760px) { .chunk { grid-template-columns: 1fr } }
.chunk pre { margin: 0; padding: 12px 14px; background: var(--sunk); font: 13px/1.5 var(--f-mono); overflow-x: auto; border-right: 1px solid var(--line) }
.chunk .cn { padding: 12px 14px; font-family: var(--f-script); font-size: 16px; line-height: 1.5; display: flex; flex-direction: column; gap: 8px }
.chunk .cn .srcrow { display: flex; gap: 6px; flex-wrap: wrap }
.chunk.bug { border-color: var(--over) }
.chunk.bug .cn { background: var(--warn-soft) }
.bugtag { font-family: var(--f-mono); font-size: 11px; font-weight: 600; color: var(--over); text-transform: uppercase; letter-spacing: .05em }

/* Playground */
.ptabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px }
.ptabs button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft) }
.pg { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 14px }
.pg h2 { margin: 0; font-size: 20px }
.pg .lead { margin: 0; font-family: var(--f-script); font-size: 16px; color: var(--fg); max-width: 75ch }
.pg label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; min-width: 0 }
.pg input[type="text"], .pg input[type="search"] { font: 14px var(--f-mono); border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0 }
/* Read the code tab. The font shorthand resets ligatures, so they're switched off again: <-- and /= must show as typed. */
#v-code * { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0 }
.rc-intro { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap }
.rc-intro .note { flex: 1 1 320px; margin: 0 0 12px }
.rc-drawer { position: fixed; z-index: 30; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,.18) }
body:not([data-mode="code"]) .rc-drawer { display: none }
/* Tablets and PCs: a side panel whose width can be dragged (--rc-w, set by code.js). Phones: a bottom sheet
   whose height can be dragged (--rc-h). The grip sits on the panel's inner edge. */
@media (min-width: 768px) {
  .rc-drawer { top: var(--rc-top, 0px); right: 0; bottom: 0; width: var(--rc-w, clamp(340px, 42vw, 560px)); border-width: 0 0 0 1px }
  body.rc-open[data-mode="code"] main.wrap { padding-right: calc(var(--rc-w, clamp(340px, 42vw, 560px)) + 20px) }
  .rc-grip { left: -7px; top: 0; bottom: 0; width: 14px; cursor: col-resize }
  .rc-grip::after { width: 4px; height: 44px }
}
@media (max-width: 767px) {
  .rc-drawer { left: 0; right: 0; bottom: 0; height: var(--rc-h, 72vh); border-radius: 16px 16px 0 0; border-width: 1px 0 0 }
  body.rc-open[data-mode="code"] main.wrap { padding-bottom: calc(var(--rc-h, 72vh) + 2vh) }
  .rc-grip { top: -2px; left: 0; right: 0; height: 22px; cursor: row-resize }
  .rc-grip::after { width: 44px; height: 4px; margin-top: 4px }
}
.rc-grip { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none }
.rc-grip::after { content: ""; border-radius: 999px; background: var(--line); transition: background .15s }
.rc-grip:hover::after, .rc-grip:focus-visible::after, .rc-grip.rc-dragging::after { background: var(--accent) }
body.rc-resizing, body.rc-resizing * { user-select: none !important; cursor: inherit }
@media (max-width: 767px) { .rc-dhead { padding-top: 18px } }
.rc-dhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line) }
.rc-dhead b { display: block; font: 700 15px var(--f-mono) }
.rc-dhead span { font-size: 12px; color: var(--muted) }
.rc-mach { margin: 0; flex: 1; overflow: auto; position: relative; padding: 10px 0 max(16px, env(safe-area-inset-bottom, 0px)); font: 12.5px/1.6 var(--f-mono); background: var(--bg) }
.rc-mach { width: 100% } .rc-mach span { display: block; min-width: max-content; padding: 0 14px 0 0; white-space: pre }
.rc-mach i { display: inline-block; width: 34px; padding-right: 10px; text-align: right; color: var(--muted); font-style: normal; user-select: none }
.rc-mach .rc-mhl { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn) }
.rc-drawer, .rc-drawer * { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0 }
.rc .rc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap }
.rc-op { display: inline-block; font: 600 11.5px var(--f-mono); color: var(--muted); background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px }
.rc-line { font: 17px/2.3 var(--f-mono); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; overflow-wrap: anywhere; white-space: pre-wrap }
.rc-line .rc-plain { font-size: 16px; background: none; border: 0; padding: 0 }
.rc-tok { font: inherit; background: none; border: 0; border-bottom: 2px dotted var(--accent); border-radius: 4px; padding: 0 3px; color: var(--fg) }
.rc-tok:hover { background: var(--accent-soft) }
.rc-tok[aria-pressed="true"] { background: var(--accent); color: var(--surface); border-bottom-color: var(--accent) }
.rc-meaning { min-height: 46px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0; font-size: 15px }
.rc-say { font-family: var(--f-script); font-size: 17px; padding: 10px 12px; border-left: 3px solid var(--good); background: var(--good-soft); border-radius: 0 }
.rc-row { display: flex; gap: 8px; flex-wrap: wrap }
.rc-row .push { margin-left: auto }
.rc-opts { display: flex; flex-direction: column; gap: 8px }
.rc-opt { text-align: left; font-weight: 500; padding: 10px 12px; white-space: normal }
.rc-opt.rc-right { border-color: var(--good); background: var(--good-soft); color: var(--fg) }
.rc-opt.rc-wrong { border-color: var(--over); color: var(--over) }
.rc-fb { min-height: 22px; font-size: 14.5px }
.qa-bar { margin-bottom: 12px }
.qa-opts { margin: 4px 0 6px } .qa-opts .rc-opt { font-family: var(--f-display) } .qa-opts code { font-size: 13px; white-space: normal }
#v-drill .rc-opt, #v-drill .rc-qn { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0 }
#qa-results .rc-miss li { font-size: 14px }
.rc-machines { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px }
.rc-mlabel { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px }
.rc-machines button[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--surface) }
.rc-machines small { font-weight: 500; opacity: .75; margin-left: 4px }
.rc-like { margin: 0; font-size: 13.5px; color: var(--muted) }
.rc-like code { font-size: 12.5px }
.rc-ex { padding: 10px 14px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--surface); font-size: 14.5px }
.rc-ex b { display: block; margin-bottom: 4px; color: var(--accent) }
.rc-ex ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; font-family: var(--f-mono); font-size: 13px; overflow-wrap: anywhere }
.rc-fb .rc-ex, .rc-fb .rc-like { margin-top: 10px }
.rc-qbar { display: flex; flex-wrap: wrap; gap: 5px }
.rc-qn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font: 600 12.5px var(--f-mono) }
.rc-qn.rc-qok { background: var(--good-soft); border-color: var(--good); color: var(--good) }
.rc-qn.rc-qno { background: var(--surface); border-color: var(--over); color: var(--over) }
.rc-qn[aria-current="step"] { outline: 2px solid var(--accent); outline-offset: 1px; color: var(--fg) }
.rc-qn.rc-qres { font-family: var(--f-display) }
.rc-good { color: var(--good) } .rc-bad { color: var(--over) }
.rc-small { font-size: 13px; color: var(--muted) }
.rc-score { font-size: 22px; font-weight: 700; margin: 0 }
.rc-miss { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px }
.rc-task { margin: 0; font-family: var(--f-script); font-size: 19px }
.rc-answer, .rc-pool { display: flex; flex-wrap: wrap; gap: 6px; min-height: 48px; padding: 8px; border-radius: 10px }
.rc-answer { background: var(--bg); border: 1px dashed var(--line) }
.rc-ph { color: var(--muted); font-size: 13px; align-self: center }
.rc-tile { font: 600 15px var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; color: var(--fg) }
.rc-answer .rc-tile { border-color: var(--accent); background: var(--accent-soft) }
.rc-tile.rc-used { opacity: .3 }
.rc-ops { display: flex; gap: 6px; flex-wrap: wrap }
.rc-ops button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft) }
.rc-call { margin: 0 } .rc-call code { font-size: 15px }
.rc-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start }
@media (max-width: 760px) { .rc-grid { grid-template-columns: minmax(0, 1fr) } }
.rc-code { margin: 0; font: 13px/1.7 var(--f-mono); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto }
.rc-code span { display: block; padding: 0 4px; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere }
.rc-code .rc-hl { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn) }
.rc-note { padding: 10px 12px; border-left: 3px solid var(--warn); background: var(--warn-soft); font-size: 15px; margin-bottom: 10px }
.rc-state { width: 100%; border-collapse: collapse; font-size: 13.5px }
.rc-state caption { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 4px }
.rc-state th { text-align: left; font: 500 12.5px var(--f-mono); color: var(--muted); padding: 5px 8px; border-bottom: 1px solid var(--line); width: 45% }
.rc-state td { font-family: var(--f-mono); padding: 5px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere }
.rc-state tr.rc-ch td, .rc-state tr.rc-ch th { background: var(--good-soft); color: var(--good); font-weight: 700 }
.pg .inrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px }
.presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.presets span { font-size: 12.5px; color: var(--muted) }
.out { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; align-items: baseline; font-size: 14px }
.out dt { font-family: var(--f-mono); font-size: 13px; color: var(--accent); white-space: nowrap }
.out dd { margin: 0; font-family: var(--f-mono); font-size: 13px; overflow-wrap: anywhere }
.verdicts { display: flex; flex-wrap: wrap; gap: 8px }
.vd { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 150px; flex: 1 1 150px; background: var(--bg) }
.vd b { display: flex; gap: 6px; align-items: center; font-size: 14px }
.vd small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere }
.vd.yes { border-color: var(--good); background: var(--good-soft) }
.vd.no { border-color: var(--line) }
.yes-dot, .no-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block }
.yes-dot { background: var(--good) } .no-dot { background: var(--over) }
.mx { overflow-x: auto }
.mx table { border-collapse: collapse; font: 12.5px var(--f-mono) }
.mx th, .mx td { border: 1px solid var(--line); padding: 0; text-align: center }
.mx th { padding: 4px 8px; background: var(--sunk); font-weight: 600; white-space: nowrap }
.mx td button { width: 34px; height: 30px; border: 0; background: none; font: 600 14px var(--f-mono); color: var(--accent) }
.mx td button[aria-pressed="true"] { background: var(--accent); color: var(--surface) }
.pick { display: flex; gap: 4px; flex-wrap: wrap }
.pick button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 2px 10px; font: 12.5px var(--f-mono) }
.pick button[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: var(--surface) }
.tt { overflow-x: auto }
.tt table { border-collapse: collapse; font: 13px var(--f-mono); font-variant-numeric: tabular-nums }
.tt th, .tt td { border: 1px solid var(--line); padding: 4px 10px; text-align: center }
.tt th { background: var(--sunk) }
.tt td.T { color: var(--good); font-weight: 600 } .tt td.F { color: var(--over) }
.tt th.res, .tt td.res { border-left: 2px solid var(--accent) }
.err { color: var(--over); font-size: 13.5px; font-family: var(--f-mono) }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px }

/* Words */
.words { max-width: 860px; margin: 0 auto }
.words input { width: 100%; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg) }
.words dl { margin: 16px 0 0 }
.words .w { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px }
.words dt { font-weight: 700; font-size: 16px; text-transform: capitalize }
.words dt .sy { font-family: var(--f-mono); font-weight: 600; font-size: 13px; color: var(--accent); text-transform: none; margin-left: 8px }
.words dd { margin: 0; font-family: var(--f-script); font-size: 16px; line-height: 1.5; grid-column: 1 }
.words .ws { grid-row: 1 / span 2; grid-column: 2; align-self: start }

/* Blocks split into short lines; a new sentence gets a little extra space */
.ln { display: block }
.ln.sb { margin-top: .45em }
/* Items of a " · " list: one per line with a bullet; a wrapped item's next line lines up under its text */
.ln.li, .ln.lic { padding-left: 1.1em; position: relative }
.ln.li::before { content: "•"; position: absolute; left: .25em; color: var(--muted) }

/* Read aloud */
.tts { flex: 0 0 auto; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); vertical-align: middle; margin-left: 4px; text-transform: none; letter-spacing: 0 }
.tts:hover { color: var(--accent); border-color: var(--accent) }
.tts svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.tts svg path:first-child { fill: currentColor }
.tts.on { background: var(--accent); border-color: var(--accent); color: var(--surface) }
.tts.on .w1, .tts.on .w2 { animation: tts-wave 1s ease-in-out infinite }
.tts.on .w2 { animation-delay: .25s }
@keyframes tts-wave { 50% { opacity: .2 } }
.saying { outline: 2px solid var(--accent-soft); outline-offset: 2px }
.no-tts .tts, .no-tts #voice-btn { display: none }
.sayrow { display: flex !important; align-items: center; justify-content: space-between; gap: 8px }
.step .sh .tts { margin-left: 0 }
details.qa summary > span { flex: 1 1 auto; min-width: 0 }
details.qa summary .tts { margin-left: auto }
.chunk .cn > .tts { align-self: flex-end; margin-bottom: -4px }
.card .ans > .tts { float: right; margin: 0 0 6px 8px }
.fig figcaption .tts { margin-left: 2px }
.pit li .tts { width: 24px; height: 24px }
.voice-pop { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: 100%; z-index: 7; width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.2); padding: 14px; display: flex; flex-direction: column; gap: 6px }
.voice-pop label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between }
.voice-pop select, .voice-pop input[type="range"] { width: 100% }
.voice-pop input[type="range"] { accent-color: var(--accent) }
.voice-row { display: flex; gap: 6px; margin-top: 4px }
.voice-note { margin: 4px 0 0; font-size: 12.5px; color: var(--muted) }
header.top .bar { position: relative }

/* Coursework */
.cw { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px }
.cw section > h2 { font-size: 21px; margin: 0 0 4px }
.cw section > .note { margin-bottom: 12px }
.cw-hero { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px }
.cw-hero h1 { margin: 0 }
.due { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap }
.due b { font: 700 30px var(--f-mono); font-variant-numeric: tabular-nums; color: var(--accent) }
.due b.soon { color: var(--warn) }
.facts { display: flex; flex-wrap: wrap; gap: 6px }
.facts span { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line) }
.facts span em { font-style: normal; color: var(--muted); margin-right: 4px }
.facts span.viva { background: var(--warn-soft); border-color: var(--warn) }
.mbar { display: flex; gap: 3px; height: 34px; border-radius: 8px; overflow: hidden }
.mbar button { border: 0; padding: 0 4px; background: var(--accent-soft); color: var(--fg); font: 600 11.5px var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0 }
.mbar button.big { background: var(--accent); color: var(--surface) }
.mlegend { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 16px; margin-top: 8px; font-size: 13.5px }
.mlegend span b { font-family: var(--f-mono); color: var(--accent); margin-right: 6px }
.mrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line) }
.mrow input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--good) }
.mrow .mt { font-family: var(--f-script); font-size: 16px; line-height: 1.45 }
.mrow .mu { font-size: 12.5px; color: var(--muted); margin-top: 2px }
.mrow .ml { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 260px }
.mrow.nice .mt { color: var(--muted) }
@media (max-width: 600px) { .mrow { grid-template-columns: auto minmax(0, 1fr) } .mrow .ml { grid-column: 2; justify-content: flex-start; max-width: none } }
.lesbtn { font: 12px var(--f-mono); padding: 2px 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--sunk); color: var(--fg) }
.lesbtn:hover { border-color: var(--accent) }
.tag { font: 600 10.5px var(--f-mono); text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent) }
.tag.opt { background: var(--sunk); color: var(--muted) }
.cwstep { scroll-margin-top: 130px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px }
.cwstep + .cwstep { margin-top: 12px }
.cwstep.done { border-color: var(--good) }
.cwstep header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.cwstep header .n { font: 700 13px var(--f-mono); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--surface); flex: 0 0 auto }
.cwstep.done header .n { background: var(--good) }
.cwstep header h3 { margin: 0; font: 600 16.5px var(--f-mono); overflow-wrap: anywhere; min-width: 0 }
.cwstep header .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap }
.cwstep header label { font-size: 12.5px; color: var(--muted); display: flex; gap: 4px; align-items: center }
.cwstep .brief { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; font-family: var(--f-script); font-size: 15.5px; color: var(--muted) }
.cwstep .brief small, .cwstep .lab { display: block; font: 600 11px var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px }
.cwstep .plain { font-family: var(--f-script); font-size: 17px; line-height: 1.55 }
.cwstep ul { margin: 0; padding-left: 18px; font-family: var(--f-script); font-size: 16px; line-height: 1.5; display: flex; flex-direction: column; gap: 6px }
.hints { display: flex; flex-direction: column; gap: 8px }
.hint { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-family: var(--f-script); font-size: 16px; line-height: 1.5 }
.hint b.hn { font: 600 11px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); display: block }
.tests label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 3px 0 }
.tests input { margin-top: 3px; accent-color: var(--good) }
.tests label code { font-size: 12.5px }
.cwrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center }
.phase-svg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; overflow-x: auto }
.simwrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #0b0e14 }
.simframe { display: block; width: 100%; height: 760px; max-height: 85vh; border: 0 }
a.btn { text-decoration: none; display: inline-block }
.unclear { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--r); padding: 12px 14px; font-family: var(--f-script); font-size: 16px; display: flex; flex-direction: column; gap: 6px }
.unclear + .unclear { margin-top: 8px }
.pit { margin: 0; padding-left: 20px; font-family: var(--f-script); font-size: 16px; line-height: 1.5; display: flex; flex-direction: column; gap: 6px }
.ptimg { margin: 12px 0 2px; display: flex; flex-direction: column; gap: 6px }
.ptimg > button[data-img] { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: zoom-in }
/* contain: the whole diagram always shows; labels must never be cropped */
.ptimg img { display: block; width: 100%; height: auto; aspect-ratio: 1280 / 714; max-height: 420px; object-fit: contain; max-width: 100% }
.ptimg figcaption { font: 12px/1.45 var(--f-mono); color: var(--muted) }
.ptimg figcaption span { opacity: .75 }
.cwimg { margin: 0; display: flex; flex-direction: column; gap: 6px }
.cwimg > button[data-img] { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0D1117; cursor: zoom-in }
/* contain, not cover: the whole picture always shows; on wide cards the side margins take the image's own edge colour */
.cwimg img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 320px; object-fit: contain; max-width: 100% }
.cwimg figcaption { font: 11.5px/1.45 var(--f-mono); letter-spacing: .02em; color: var(--muted) }
.cwimg figcaption span { opacity: .75 }
.integrity { font-size: 13.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px }

/* Tooltip and slide viewer */
.term { text-decoration: underline dotted var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: help; border-radius: 3px }
.term:hover, .term.on { background: var(--accent-soft) }
.tip { position: fixed; z-index: 30; max-width: min(340px, calc(100vw - 32px)); background: var(--fg); color: var(--bg); padding: 10px 12px; border-radius: 8px; font: 14px/1.45 var(--f-display); box-shadow: 0 6px 24px rgba(0,0,0,.25); pointer-events: none }
.tip b { display: block; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; opacity: .75; margin-bottom: 2px }
.tip .sy { font-family: var(--f-mono); font-size: 12.5px; opacity: .85; display: block; margin-top: 4px }
.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(3,5,10,.88); display: flex; flex-direction: column; align-items: center; gap: 10px; overflow-y: auto; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
.lb-bar { width: min(1100px, 100%); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: #EEF2F8 }
.lb-bar .lb-t { margin-right: auto; display: flex; flex-direction: column; min-width: 0 }
.lb-bar .lb-t b { font-size: 15px }
.lb-bar .lb-t span { font: 12px var(--f-mono); opacity: .75 }
.lb-bar .btn { background: #0E1420; color: #EEF2F8; border-color: #2B3A55 }
.lb-img { width: min(1100px, 100%); overflow: auto; border-radius: 8px; background: #FFFFFF }
.lb-img img { display: block; width: 100%; height: auto; cursor: zoom-in }
.lb-img.zoom img { width: 200%; max-width: none; cursor: zoom-out }
.lb-flag { width: min(1100px, 100%); background: var(--warn-soft); color: var(--fg); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 14px; font-family: var(--f-script); font-size: 16px }
.lb-flag b { font-family: var(--f-display); color: var(--warn); display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase }
.lightbox[hidden] { display: none }
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }

/* Animation guide (ported from the ChessTournament Decoder; every rule is scoped to .ag) */
.ag { --panel: var(--surface); --rule: var(--line); --ink: var(--fg); --accent-ink: var(--accent); --ok: var(--good); --bad: var(--over);
  --red: #BC3A2C; --blue: #2C5FC0; --green: #1F7C4A; --red-soft: #F6DCD7; --blue-soft: #DAE4F7; --green-soft: #D5EEDF; --k-def: #A02F69;
  max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .ag { --red: #E66E60; --blue: #78A2F2; --green: #52C287; --red-soft: #3D2320; --blue-soft: #1F2B44; --green-soft: #1A3527; --k-def: #F18DC0 } }
:root[data-theme="dark"] .ag, :root[data-theme="blue"] .ag, :root[data-theme="oled"] .ag { --red: #E66E60; --blue: #78A2F2; --green: #52C287; --red-soft: #3D2320; --blue-soft: #1F2B44; --green-soft: #1A3527; --k-def: #F18DC0 }
.ag h1 { margin: 2px 0 0 }
.ag h2 { font-size: 21px; margin: 0 }
.ag h3 { font-size: 16px; margin: 0 }
.ag p { margin: 0 }
.ag .sec { display: flex; flex-direction: column; gap: 14px }
.ag .sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap }
.ag .lead { color: var(--muted); max-width: 75ch; font-family: var(--f-script); font-size: 16.5px; line-height: 1.5 }
.ag .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0 }
.ag .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px }
.ag .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.ag .small { font-size: 13.5px }
.ag .muted { color: var(--muted) }
.ag .scroll-x { overflow-x: auto; max-width: 100% }
.ag .callout { border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--fg); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 14px }
.ag .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent) }
.ag table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px }
.ag table.grid th, .ag table.grid td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top }
.ag table.grid th { font: 600 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.ag .statebar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r) }
.ag .statebar .sum { margin-left: auto; font-size: 13px; color: var(--muted) }
.ag .phasepill { font: 600 13px var(--f-mono); padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent) }
.ag .t-red { --tc: var(--red) } .ag .t-blue { --tc: var(--blue) } .ag .t-green { --tc: var(--green) }
.ag svg.map { width: 100%; height: auto; display: block }
.ag svg text { fill: var(--fg); font-family: var(--f-display); font-size: 13px }
.ag svg .ax { fill: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600 }
.ag svg .fd text { fill: var(--muted); opacity: .6 }
.ag svg .fd circle { opacity: .4 }
.ag .codeblk { position: relative; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; overflow-x: auto }
.ag .codeblk pre { margin: 0; font: 12.5px/1.6 var(--f-mono); white-space: pre }
.ag .codeblk .copy { position: absolute; top: 8px; right: 8px }
.ag .pgrid { display: inline-grid; width: max-content; gap: 1px; background: var(--line); border: 1px solid var(--line); font: 11.5px var(--f-mono) }
.ag .pgrid span { background: var(--surface); min-width: 22px; height: 24px; padding: 0 4px; display: grid; place-items: center; white-space: nowrap }
.ag .pgrid.regions span[data-f="F"] { background: var(--accent-soft) } .ag .pgrid.regions span[data-f="F1"] { background: var(--blue-soft) }
.ag .pgrid.regions span[data-f="F2"] { background: var(--green-soft) } .ag .pgrid.regions span[data-f="F3"] { background: var(--red-soft) }
.ag .pgrid.regions span[data-f="F4"] { background: var(--sunk); outline: 2px solid var(--accent); outline-offset: -2px } .ag .pgrid.regions span[data-f="F5"] { background: color-mix(in srgb, var(--k-def) 18%, var(--surface)) }
.ag .pgrid .tn { font-weight: 600; color: var(--tc) }
.ag .legend2 { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted) }
.ag .legend2 i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--line) }
.ag .bsgrid { display: inline-grid; gap: 1px }
.ag .bsgrid span { width: 22px; height: 22px; display: block; background-size: cover; border-radius: 2px; cursor: crosshair }
.ag .bsgrid span.hl { outline: 2px solid var(--accent) }
.ag .tiles { display: inline-grid; gap: 2px }
.ag .tiles span { width: 22px; height: 22px; border-radius: 3px }
.ag .tiles .i0 { background: var(--sunk) } .ag .tiles .i1 { background: repeating-linear-gradient(135deg, var(--sunk) 0 3px, var(--muted) 3px 4px) }
.ag .tiles .i2 { background: var(--accent) } .ag .tiles .i3 { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent) }
.ag .checklist { display: flex; flex-direction: column; gap: 10px; counter-reset: ck; margin: 0; padding: 0; list-style: none }
.ag .checklist li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; font-family: var(--f-script); font-size: 15.5px }
.ag .checklist li b { font-family: var(--f-display) }
.ag .checklist li::before { counter-increment: ck; content: counter(ck); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--surface); display: grid; place-items: center; font: 600 13px var(--f-mono) }
.ag .pitfalls { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px }
.ag .pitfalls div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: 13.5px }
.ag .pitfalls b { display: block; margin-bottom: 4px }
.ag .triples { font: 12px/1.7 var(--f-mono); display: flex; flex-wrap: wrap; gap: 4px }
.ag .triples span { padding: 1px 6px; border-radius: 4px; background: var(--sunk) }
.ag .triples span.hl, .ag .mini span.hl { background: var(--accent); color: var(--surface) }
.ag .mini { display: inline-grid; gap: 2px; font: 12px var(--f-mono) }
.ag .mini span { width: 46px; height: 32px; display: grid; place-items: center; background: var(--sunk); border-radius: 4px }
.ag .mini .hd { background: none; color: var(--muted); font-size: 10.5px }
@media (max-width: 900px) { .ag .two { grid-template-columns: minmax(0, 1fr) } .ag .statebar .sum { margin-left: 0 } }
.ag .ag-intro { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap }
.ag .ag-intro .lead { flex: 1 1 320px }
/* Paragraphs shown as bullet points */
.ag ul.ag-pts { margin: 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 4px }
.ag ul.ag-pts li::marker { color: var(--accent) }
.ag .callout ul.ag-pts { gap: 3px }
/* The embedded interactive lesson (learn/animation.html) */
.ag .ag-learn { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #f8fafc }
.ag .ag-learnframe { display: block; width: 100%; height: 820px; max-height: 85vh; border: 0 }
/* Phones: the lesson is too wide to embed, so it opens on its own page instead (the hidden frame never loads) */
@media (max-width: 640px) { .ag .ag-learn { display: none } .ag .ag-learnopen { background: var(--accent); border-color: var(--accent); color: var(--surface) } }
.ag .legend2 .ag-find { font: inherit; color: inherit; background: none; border: 0; padding: 2px 4px; border-radius: 4px; text-align: left; cursor: pointer }
.ag .legend2 .ag-find:hover { background: var(--sunk); color: var(--fg) }
.ag label[data-line] { cursor: pointer }
/* The Battleships drawer reuses the Read the code drawer styles, shown only in this tab. */
body[data-mode="anim"] .rc-drawer.ag-drawer { display: flex }
body:not([data-mode="anim"]) .ag-drawer { display: none }
@media (min-width: 768px) { body.ag-open[data-mode="anim"] main.wrap { padding-right: calc(var(--rc-w, clamp(340px, 42vw, 560px)) + 20px) } }
@media (max-width: 767px) { body.ag-open[data-mode="anim"] main.wrap { padding-bottom: calc(var(--rc-h, 72vh) + 2vh) } }



/* Dashboard Custom Extension (sharing exact same design tokens, font stacks, and themes) */
.dash-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 24px 60px;
}
@media (max-width: 900px) {
  .dash-wrap { padding: 14px 14px 40px; }
}

/* Schedule calendar grid */
.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .grid { grid-template-columns: 1fr; } }

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
  min-width: 0;
}
.day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.day h3 {
  margin: 2px 0 10px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.day.today h3 { color: var(--accent); }

.sess {
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.sess:hover {
  border-color: var(--accent);
  background: var(--surface);
}
.sess b { color: var(--accent); font-size: 13.5px; }
.sess .t { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--accent);
}
.card.critical-card {
  border-left: 4px solid var(--over);
}
.card .code {
  font-family: var(--f-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
}

/* Pills & Chips */
.pill {
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  background: var(--surface);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.pill.danger { border-color: var(--over); color: var(--over); background: #FEE2E2; }
:root[data-theme="dark"] .pill.danger, :root[data-theme="blue"] .pill.danger { background: #3B1212; color: #F87171; }
.pill.acc { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pill.success { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.pill.bb { border-color: #F59E0B; color: #92400E; background: #FEF3C7; font-weight: 600; }
:root[data-theme="dark"] .pill.bb, :root[data-theme="blue"] .pill.bb { background: #2E2210; color: #F5A524; }
.pill.gcal { border-color: #3B82F6; color: #1D4ED8; background: #EFF6FF; font-weight: 600; }
:root[data-theme="dark"] .pill.gcal, :root[data-theme="blue"] .pill.gcal { background: #13233F; color: #60A5FA; }
.pill.rev { border-color: #8B5CF6; color: #6D28D9; background: #F5F3FF; font-weight: 600; }
:root[data-theme="dark"] .pill.rev, :root[data-theme="blue"] .pill.rev { background: #2A1D4E; color: #C4B5FD; }
.pill.drive { border-color: #10B981; color: #065F46; background: #ECFDF5; font-weight: 600; }
:root[data-theme="dark"] .pill.drive, :root[data-theme="blue"] .pill.drive { background: #0D2A20; color: #34D399; }

/* Countdowns & Alert Banners */
.cd-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 11px;
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--sunk);
  border: 1px solid var(--line);
  margin-top: 6px;
  color: var(--accent);
}
.cd-badge.urgent {
  border-color: var(--over);
  color: var(--over);
  background: #FEE2E2;
}
:root[data-theme="dark"] .cd-badge.urgent, :root[data-theme="blue"] .cd-badge.urgent { background: #3B1212; color: #F87171; }
.cd-badge.soon {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-soft);
}

.banner {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-left: 5px solid var(--accent);
  border-radius: var(--r);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.banner b { color: var(--accent); }
.banner .cd {
  display: inline-flex;
  align-items: center;
  height: 28px;
  box-sizing: border-box;
  font-size: 11.5px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0 12px;
  border-radius: 999px;
  font-family: var(--f-mono);
  font-weight: 600;
  white-space: nowrap;
}
.banner .pill {
  height: 28px;
  box-sizing: border-box;
  padding: 0 12px !important;
  font-size: 11.5px;
}

.tag-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); flex-grow: 1; }
.tag-list li { margin-bottom: 3px; }
.links-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.lec-link {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: all .15s;
}
.lec-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* Module Switcher Dropdown on Workspace Card */
.mod-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}
.mod-select-wrap .mod-select-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--accent);
  pointer-events: none;
}
.mod-select-wrap .mod-select-arrow {
  position: absolute;
  right: 10px;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.mod-select-picker {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--f-display);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 30px 6px 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--fg);
  cursor: pointer;
  outline: none;
  transition: all .15s;
  max-width: min(420px, calc(100vw - 60px));
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mod-select-picker:hover {
  border-color: var(--accent);
  background: var(--surface);
}
.mod-select-picker:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Module Workspace in Step Style */
.mod-workspace {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px 24px;
  margin-top: 16px;
}
.mod-pills-bar {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 10px;
  margin-bottom: 16px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.mod-pills-bar::-webkit-scrollbar {
  height: 4px;
}
.mod-pills-bar::-webkit-scrollbar-track {
  background: transparent;
}
.mod-pills-bar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}
.mod-sel-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mod-sel-pill:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.mod-sel-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.mod-sel-pill .mod-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.6;
}
.mod-sel-pill.active .mod-dot {
  background: #FFFFFF;
  opacity: 1;
}

.mod-subtabs {
  display: flex;
  gap: 6px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin: 18px 0;
  overflow-x: auto;
  width: max-content;
  max-width: 100%;
}
.mod-subtab-btn {
  border: 0;
  background: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.mod-subtab-btn:hover { color: var(--fg); }
.mod-subtab-btn.active {
  background: var(--accent);
  color: var(--surface);
}

.res-card {
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  transition: all .15s;
}
.res-card:hover {
  border-color: var(--accent);
  background: var(--surface);
}

/* Detail Modal */
#detail {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
#detail.open { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px 26px;
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  margin: auto;
  box-shadow: 0 12px 36px rgba(0,0,0,.25);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
}
.modal-close:hover {
  background: var(--sunk);
  color: var(--fg);
}
#detail a { color: var(--accent); }
.mut { color: var(--muted); }
.mono { font-family: var(--f-mono); }

/* Lucide Icons Integration */
.lucide, i[data-lucide] {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: -2.5px;
  stroke-width: 2px;
  stroke: currentColor;
  fill: none;
}
.modes .lucide, .modes i[data-lucide] {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 4px;
}
.pill .lucide, .pill i[data-lucide], .chip .lucide, .chip i[data-lucide] {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 3px;
}
.nav .lucide, .nav i[data-lucide] {
  width: 22px;
  height: 22px;
  stroke-width: 2.2px;
  display: block;
}
.res-card .lucide, .res-card i[data-lucide] {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

/* Header Hide / Show & Fullscreen pill matching formal-methods.vercel.app exactly */
.fs {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.fs button, .hdr-show {
  border: 0;
  background: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.fs button:hover, .hdr-show:hover {
  color: var(--accent);
  background: rgba(128,128,128,0.12);
}
.fs button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--surface);
}
.fs svg, .hdr-show svg, .fs i[data-lucide], .hdr-show i[data-lucide] {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
body.hdr-off header.top {
  display: none !important;
}
body.hdr-off::before {
  display: none;
}
.hdr-show {
  position: fixed;
  z-index: 70;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: max(16px, env(safe-area-inset-right, 0px));
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  opacity: .8;
}
.hdr-show:hover, .hdr-show:focus-visible {
  opacity: 1;
}
body:not(.hdr-off) .hdr-show {
  display: none !important;
}

/* Exact Header Two-Row Layout matching CP/FM Rehearsal */
.top .bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding-block: 14px 12px;
}
.hdr-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand b {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.2px;
  color: var(--fg);
}
.brand span {
  font-family: var(--f-display);
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.prefs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hdr-row-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.modes {
  display: inline-flex;
  gap: 2px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  overflow-x: auto;
  max-width: 100%;
}
.modes button {
  border: 0;
  background: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: all .15s;
}
.modes button:hover {
  color: var(--fg);
}
.modes button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--surface);
}

.clock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 13px;
}

/* Schedule Specific Typography: Compact, dense, highly-legible without affecting the rest of the site */
#viewS .grid {
  gap: 8px;
}
#viewS .day {
  padding: 8px;
}
#viewS .day h3 {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 700;
  margin: 1px 0 6px;
  letter-spacing: .04em;
}
#viewS .sess {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
}
#viewS .sess b {
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
}
#viewS .sess-title {
  font-family: var(--f-display);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1px;
  display: block;
}
#viewS .sess .t {
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}
#viewS .sess .chip {
  font-size: 9.5px;
  padding: 1px 5px;
  line-height: 1;
}
#viewS .lec-link {
  font-size: 11px;
}

/* Match header and body width exactly */
header.top .wrap.bar, .dash-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 24px !important;
  padding-right: 24px !important;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  header.top .wrap.bar, .dash-wrap {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

/* Search & Group Input Styling matching FM/CP Rehearsal design */
.search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-wrap .search-ic {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.top .clock input, #q {
  font-family: var(--f-display);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--fg);
  border-radius: 999px;
  height: 34px;
  box-sizing: border-box;
  padding: 0 14px 0 32px;
  width: 220px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.top .clock select, #group, .top .clock .btn {
  height: 34px;
  box-sizing: border-box;
}
.top .clock input:hover, #q:hover {
  border-color: var(--accent);
}
.top .clock input:focus, #q:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.top .clock input::placeholder, #q::placeholder {
  color: var(--muted);
  font-family: var(--f-display);
  font-size: 13px;
  opacity: 0.8;
}

/* Matching Pill Select for Timetable Group */
.top .clock select, #group {
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--fg);
  border-radius: 999px;
  padding: 6px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.top .clock select:hover, #group:hover {
  border-color: var(--accent);
}
.top .clock select:focus, #group:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Button hover & Report a mistake styling matching revision sites */
.btn {
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover {
  border-color: var(--accent);
}
.btn.rp-open {
  font-family: var(--f-mono);
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--over) !important;
  color: var(--over);
}
.btn.rp-open:hover {
  border-color: var(--over) !important;
  background: rgba(239, 68, 68, 0.12);
  color: var(--over);
}
.rp-flag {
  display: none !important;
}

/* Site Footer */
.dash-footer {
  margin-top: 48px;
  margin-bottom: 24px;
}
.dash-footer .footer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r, 12px);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}
.dash-footer .footer-msg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}
.dash-footer a.footer-author {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  font-weight: 700;
  transition: color .15s, text-decoration-color .15s;
}
.dash-footer a.footer-author:hover {
  color: var(--accent);
}
.dash-footer .footer-heart {
  width: 16px;
  height: 16px;
  color: var(--fg);
  fill: #FFFFFF;
  stroke: var(--fg);
  stroke-width: 2;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
[data-theme="blue"] .dash-footer .footer-heart,
[data-theme="oled"] .dash-footer .footer-heart {
  color: #FFFFFF;
  fill: #FFFFFF;
  stroke: #FFFFFF;
}
.dash-footer .footer-sub {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}
.dash-footer .footer-sub .sep {
  opacity: 0.5;
}
@media (max-width: 620px) {
  .dash-footer {
    margin-top: 36px;
    margin-bottom: 30px;
  }
  .dash-footer .footer-card {
    padding: 14px 16px;
  }
  .dash-footer .footer-msg {
    font-size: 13px;
  }
  .dash-footer .footer-sub {
    font-size: 11px;
    gap: 4px;
  }
}

/* Assessment Amber / Gold Highlight Box */
.alert-box {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--warn);
  background: transparent;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--warn);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}
.alert-box svg, .alert-box [data-lucide] {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Hub Quick Links Grid */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.hub-grid .hub-span-2 {
  grid-column: span 2;
}

/* Module Hero Header */
.mod-hero-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.mod-hero-main {
  flex: 1 1 300px;
  min-width: 0;
}

/* Responsive Mobile Polish */
@media (max-width: 768px) {
  .hdr-row-main {
    gap: 10px;
  }
  .hdr-row-sub {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #mainModes.modes {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
  }
  #degModes.modes, .deg-modes.modes {
    width: 100%;
    display: flex;
    gap: 2px;
    overflow: visible;
  }
  #degModes.modes button, .deg-modes.modes button {
    flex: 1 1 auto;
    justify-content: center;
    padding: 7px 8px;
    font-size: 12px;
  }
  .modes button {
    justify-content: center;
    padding: 7px 4px;
    font-size: 12px;
    min-width: 0;
    gap: 4px;
  }
  .modes .lucide, .modes i[data-lucide] {
    width: 14px;
    height: 14px;
    margin-right: 0;
    flex-shrink: 0;
  }
  .clock {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .top .clock select, #group {
    flex: 0 1 auto;
    max-width: 100%;
  }
  .search-wrap {
    flex: 1 1 160px;
    min-width: 0;
  }
  .top .clock input, #q {
    width: 100%;
    min-width: 0;
  }
  #hubBtn, .btn.rp-open {
    flex: 1 1 auto;
    justify-content: center;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .mod-hero-row {
    flex-direction: column;
    align-items: stretch;
  }
  .mod-hero-main {
    flex: 1 1 auto;
    width: 100%;
  }
  .mod-workspace {
    padding: 16px 14px;
  }
  .mod-select-wrap {
    width: 100%;
    max-width: 100%;
  }
  .mod-select-picker {
    width: 100%;
    max-width: 100%;
  }
  .mod-subtabs {
    width: 100%;
    flex-wrap: wrap;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    overflow: visible;
  }
  .mod-subtab-btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
    padding: 6px 10px;
    font-size: 12px;
  }
  .modal-box {
    padding: 18px 16px;
  }
}

@media (max-width: 540px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
  .hub-grid .hub-span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 420px) {
  .modes button {
    font-size: 11px;
    padding: 6px 2px;
    gap: 3px;
  }
  .modes .lucide, .modes i[data-lucide] {
    width: 13px;
    height: 13px;
  }
}

/* Floating Changelog Button (top-right corner on wide screens, bottom-right on smaller) */
.cl-fab {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
  cursor: pointer;
  transition: border-color .18s, color .18s, gap .2s, padding .2s, box-shadow .18s;
}
.cl-fab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.cl-fab .cl-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .22s ease, opacity .18s ease;
}
.cl-fab:hover, .cl-fab:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  gap: 7px;
  padding: 0 14px 0 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.cl-fab:hover .cl-label, .cl-fab:focus-visible .cl-label {
  max-width: 90px;
  opacity: 1;
}
@media (max-width: 1519px) {
  .cl-fab {
    top: auto;
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
  }
}

/* Collapsed older changelog entries */
.cl-older {
  margin: 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2, rgba(255, 255, 255, .02));
}
.cl-older summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.cl-older summary::-webkit-details-marker { display: none; }
.cl-older summary:hover { color: var(--fg); }
.cl-older .cl-chev {
  width: 14px;
  height: 14px;
  transition: transform .18s ease;
}
.cl-older[open] .cl-chev { transform: rotate(90deg); }
.cl-older-body { padding: 4px 12px 2px; }


