/* ICSE Resources — black glass UI with white glow
   Tokens first, then layout, components, reader. */

:root {
  --bg: #000;
  --text: #f5f5f6;
  --muted: rgba(var(--w), 0.6);
  --dim: rgba(var(--w), 0.4);
  --line: rgba(var(--w), 0.1);
  --line-hi: rgba(var(--w), 0.3);
  --glass: rgba(var(--w), 0.045);
  --glass-hi: rgba(var(--w), 0.085);
  --glow: 0 0 40px rgba(var(--w), 0.09);
  --glow-hi: 0 0 60px rgba(var(--w), 0.18);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1180px;
  color-scheme: dark;

  /* tint channel: white tints on dark, black tints on light */
  --w: 255, 255, 255;
  --wi: 0, 0, 0;
  --strong: #fff;
  --paper: #000;
  --btn-glow: 0 0 22px rgba(255, 255, 255, 0.28);
  --btn-glow-hi: 0 0 36px rgba(255, 255, 255, 0.55);
  --badge-glow: 0 0 14px rgba(255, 255, 255, 0.45);
  --search-glow: 0 0 0 5px rgba(255, 255, 255, 0.06), 0 0 70px rgba(255, 255, 255, 0.2);
  --text-glow: 0 0 60px rgba(255, 255, 255, 0.28);
  --shell-shadow: 0 0 90px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --qr-shadow: 0 0 50px rgba(255, 255, 255, 0.22);
  --toast-shadow: 0 0 40px rgba(255, 255, 255, 0.12);
  --pg-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 14px 44px rgba(0, 0, 0, 0.7), 0 0 70px rgba(255, 255, 255, 0.06);
  --prog-glow: 0 0 12px #fff;
  --dlg-shadow: 0 0 80px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --panel: rgba(14, 14, 14, 0.78);
  --nav-bg: rgba(12, 12, 12, 0.62);
  --toast-bg: rgba(20, 20, 20, 0.85);
  --glass-solid: rgba(22, 22, 22, 0.92);
  --scrim: rgba(0, 0, 0, 0.78);
  --scrim-2: rgba(0, 0, 0, 0.6);
  --shell-bg: rgba(8, 8, 8, 0.7);
  --fs-bg: #000;
  --reader-bg: #050505;
  --lift: #000;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.no-scroll, html.no-scroll body { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--strong); outline-offset: 3px; border-radius: 6px; }

.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Ambient glow ---------- */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); background: rgb(var(--w)); }
.orb.o1 { width: 62vw; height: 38vh; left: 50%; top: -22vh; transform: translateX(-50%); opacity: 0.17; }
.orb.o2 { width: 36vw; height: 36vw; right: -14vw; top: 46vh; opacity: 0.05; }
.orb.o3 { width: 30vw; height: 30vw; left: -12vw; top: 90vh; opacity: 0.045; }
.spot {
  position: absolute; left: 0; top: 0; width: 620px; height: 620px; margin: -310px 0 0 -310px;
  background: radial-gradient(circle, rgba(var(--w), 0.075), transparent 65%);
  opacity: 0; transition: opacity 0.4s; will-change: transform;
}
.spot.on { opacity: 1; }

/* ---------- Glass primitive ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(var(--w), 0.07);
}
@supports not (backdrop-filter: blur(1px)) {
  .glass { background: var(--glass-solid); }
}

/* hover glow that follows the pointer */
.gh { position: relative; isolation: isolate; overflow: hidden; transition: border-color 0.25s, box-shadow 0.3s, transform 0.25s, background 0.25s; }
.gh::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity 0.3s; pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 0%), rgba(var(--w), 0.13), transparent 62%);
}
.gh:hover { border-color: var(--line-hi); box-shadow: inset 0 1px 0 rgba(var(--w), 0.12), var(--glow), 0 24px 50px -24px var(--lift); transform: translateY(-2px); }
.gh:hover::before { opacity: 1; }

/* ---------- Page frame ---------- */
.page { position: relative; z-index: 1; }
.wrap { width: min(var(--maxw), 100% - 2 * var(--gutter)); margin-inline: auto; }

.nav { position: sticky; top: 12px; z-index: 20; margin-top: 12px; }
.nav-in { background: var(--nav-bg); display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.9rem; transition: color 0.2s; white-space: nowrap; }
.back:hover { color: var(--strong); }
.brand { margin-inline: auto; font-family: var(--font-display); font-weight: 650; letter-spacing: -0.01em; font-size: 1.02rem; white-space: nowrap; }
.brand span { color: var(--dim); font-weight: 500; }

/* ---------- Buttons ---------- */
.btn, .pill, .ib {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--glass); color: var(--text);
  transition: border-color 0.2s, box-shadow 0.25s, background 0.2s, transform 0.15s, color 0.2s;
}
.btn { height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 550; font-size: 0.93rem; white-space: nowrap; }
.pill { height: 40px; padding: 0 14px; border-radius: 999px; font-size: 0.9rem; font-weight: 550; }
.ib { width: 38px; height: 38px; border-radius: 11px; padding: 0; flex: none; }
.btn:hover, .pill:hover, .ib:hover { border-color: var(--line-hi); background: var(--glass-hi); box-shadow: var(--glow); }
.btn:active, .pill:active, .ib:active { transform: scale(0.97); }
.btn[disabled], .ib[disabled] { opacity: 0.35; pointer-events: none; }

.btn-primary { background: var(--strong); color: var(--paper); border-color: var(--strong); box-shadow: var(--btn-glow); }
.btn-primary:hover { background: var(--strong); border-color: var(--strong); box-shadow: var(--btn-glow-hi); }

.pill .n { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: rgba(var(--w), 0.14); font-size: 0.75rem; }
.pill[aria-pressed="true"] { background: var(--strong); color: var(--paper); border-color: var(--strong); box-shadow: var(--btn-glow); }
.pill[aria-pressed="true"] .n { background: rgba(var(--wi), 0.14); }
.saved .ic { fill: currentColor; }

/* ---------- Hero ---------- */
.hero { padding: clamp(56px, 11vh, 120px) 0 clamp(28px, 5vh, 48px); }
.hero h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.5rem, 7.4vw, 5.6rem);
  line-height: 0.98; letter-spacing: -0.04em; max-width: 14ch; text-wrap: balance;
  text-shadow: var(--text-glow);
}
.hero p { margin-top: 20px; max-width: 52ch; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); }

.search {
  margin-top: clamp(28px, 5vh, 44px); display: flex; align-items: center; gap: 14px;
  height: 66px; padding: 0 14px 0 22px; border-radius: 22px; max-width: 760px;
  transition: border-color 0.25s, box-shadow 0.3s, background 0.25s;
}
.search:hover { border-color: rgba(var(--w), 0.2); }
.search:focus-within { border-color: rgba(var(--w), 0.55); background: var(--glass-hi); box-shadow: var(--search-glow); }
.search .ic { width: 22px; height: 22px; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; font-size: clamp(1rem, 2.4vw, 1.2rem); }
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { display: none; }
.kbd { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-size: 0.8rem; }
.kbd kbd { min-width: 26px; height: 26px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: rgba(var(--w), 0.05); font: inherit; color: var(--muted); }
.search .clear { width: 34px; height: 34px; }
.hero .quick { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--dim); font-size: 0.9rem; }
.quick button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 0.85rem; transition: all 0.2s; }
.quick button:hover { color: var(--strong); border-color: var(--line-hi); box-shadow: var(--glow); }

/* ---------- Sections ---------- */
section[id] { scroll-margin-top: 84px; }
.block { padding: clamp(24px, 4vw, 40px) 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.block-head h2 { font-family: var(--font-display); font-weight: 650; font-size: clamp(1.35rem, 3vw, 1.8rem); letter-spacing: -0.025em; }
.block-head .sub { color: var(--dim); font-size: 0.92rem; }

/* recent strip */
.strip { display: flex; gap: 14px; overflow-x: auto; padding: 6px var(--gutter) 22px; margin-inline: calc(-1 * var(--gutter)); scroll-snap-type: x proximity; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.mini { flex: 0 0 min(290px, 78vw); scroll-snap-align: start; display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 14px; border-radius: 18px; }
.mini h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.25; letter-spacing: -0.01em; }
.mini .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.mini .when { color: var(--dim); font-size: 0.82rem; }
.mini .tl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.84rem; }

/* subject cards */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.subj { display: flex; flex-direction: column; gap: 22px; padding: 20px; border-radius: var(--r-lg); text-align: left; min-height: 150px; width: 100%; }
.subj:hover { box-shadow: inset 0 1px 0 rgba(var(--w), 0.12), 0 0 44px color-mix(in srgb, var(--accent) 28%, transparent), 0 24px 50px -24px var(--lift); border-color: color-mix(in srgb, var(--accent) 60%, white 0%); }
.subj::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); opacity: 0.55; transition: opacity 0.3s, left 0.3s, right 0.3s; }
.subj:hover::after { opacity: 1; left: 0; right: 0; }
.subj .top { display: flex; justify-content: space-between; align-items: flex-start; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent, #fff); box-shadow: 0 0 14px var(--accent, #fff); flex: none; }
.subj .cnt { font-family: var(--font-display); font-weight: 650; font-size: 2.4rem; line-height: 1; letter-spacing: -0.04em; color: var(--accent); }
.subj h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.18rem; letter-spacing: -0.015em; margin-top: auto; }
.subj .meta { color: var(--dim); font-size: 0.86rem; margin-top: 2px; }

/* ---------- Filters ---------- */
.filters { display: grid; gap: 12px; padding: 16px; border-radius: var(--r-lg); }
.frow { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 12px; }
.frow > label { color: var(--dim); font-size: 0.88rem; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 3px; margin: -3px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(var(--w), 0.03);
  color: var(--muted); font-size: 0.88rem; font-weight: 500; transition: all 0.2s;
}
.chip:hover { color: var(--strong); border-color: var(--line-hi); box-shadow: var(--glow); }
.chip[aria-pressed="true"] { background: var(--strong); color: var(--paper); border-color: var(--strong); box-shadow: var(--btn-glow); }
.chip .dot { width: 8px; height: 8px; box-shadow: none; }

.filters[hidden] { display: none; }
.filters:not([hidden]) { margin-bottom: 4px; animation: fin 0.2s ease; }
@keyframes fin { from { opacity: 0; transform: translateY(-6px); } }
.tb-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-btn { height: 40px; gap: 8px; }
.tb-btn .ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tb-btn[aria-pressed="true"], .tb-btn[aria-expanded="true"] { background: var(--strong); color: var(--paper); border-color: var(--strong); }
.tb-btn .chev { width: 14px; height: 14px; margin-left: -2px; transition: transform 0.2s; }
.tb-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sort-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-left: 6px; }
.fcount { font-style: normal; font-size: 0.72rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--strong); color: var(--paper); }
.tb-btn[aria-expanded="true"] .fcount { background: var(--paper); color: var(--strong); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 16px; }
.count { color: var(--muted); font-size: 0.95rem; }
.count b { color: var(--strong); font-weight: 600; }
.count button { margin-left: 10px; background: none; border: 0; color: var(--strong); text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.seg { display: inline-flex; padding: 4px; border-radius: 13px; gap: 2px; }
.seg button { white-space: nowrap; height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--muted); font-size: 0.88rem; font-weight: 500; transition: all 0.2s; }
.seg button:hover { color: var(--strong); }
.seg button[aria-pressed="true"] { background: var(--glass-hi); border-color: var(--line-hi); color: var(--strong); box-shadow: var(--glow); }

/* ---------- Resource cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--r-lg); }
.card .tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-right: 44px; color: var(--muted); font-size: 0.85rem; }
.card .tags .sj { display: inline-flex; align-items: center; gap: 8px; }
.card .tags .ty { color: var(--dim); }
.card h3 { font-family: var(--font-display); font-weight: 620; font-size: 1.28rem; line-height: 1.2; letter-spacing: -0.02em; }
.card h3 a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(var(--w), 0.4); }
.card .desc { color: var(--muted); font-size: 0.94rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--dim); font-size: 0.84rem; margin-top: auto; }
.card .acts { display: flex; gap: 8px; }
.card .acts .btn { flex: 1; }
.card .acts .btn-primary { flex: 1.25; }
.card .corner { position: absolute; top: 14px; right: 14px; }
.card .more { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .more .ib { width: 32px; height: 32px; border-color: transparent; background: none; color: var(--dim); }
.card .more .ib:hover { color: var(--strong); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 650; letter-spacing: 0.01em; border: 1px solid; }
.badge.new { color: var(--paper); background: var(--strong); border-color: var(--strong); box-shadow: var(--badge-glow); }
.badge.pop { color: var(--strong); border-color: rgba(var(--w), 0.45); background: rgba(var(--w), 0.1); }
/* Download tiers: each tier sets its own colour in --tc (config.js) */
.badge.pop.tier { white-space: nowrap; color: var(--tc); border-color: color-mix(in srgb, var(--tc) 55%, transparent); background: color-mix(in srgb, var(--tc) 13%, transparent); cursor: help; }
.badge.pop.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; box-shadow: 0 0 14px color-mix(in srgb, var(--tc) 35%, transparent); }
:root[data-theme="light"] .badge.pop.tier { color: color-mix(in srgb, var(--tc) 55%, #000); border-color: color-mix(in srgb, var(--tc) 70%, transparent); background: color-mix(in srgb, var(--tc) 20%, #fff); }
:root[data-theme="light"] .badge.pop.code { box-shadow: none; }

.empty { grid-column: 1 / -1; text-align: center; padding: 56px 20px; border-radius: var(--r-lg); color: var(--muted); }
.empty h3 { font-family: var(--font-display); color: var(--strong); font-size: 1.4rem; margin-bottom: 8px; }
.empty .btn { margin-top: 18px; }

.foot { padding: 48px 0 56px; color: var(--dim); font-size: 0.9rem; }
.foot .glass { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center; padding: 18px 22px; border-radius: var(--r-lg); }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot a:hover { color: var(--strong); }

.is-filtering #recent, .is-filtering #subjects { display: none; }
.is-filtering .hero { padding-bottom: 20px; }

/* ---------- Reader ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; display: flex; background: var(--scrim); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px); opacity: 0; transition: opacity 0.2s; }
.viewer.on { opacity: 1; }
.v-shell { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; margin-inline: auto; background: var(--shell-bg); transform: scale(0.985); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); min-height: 0; }
.viewer.on .v-shell { transform: none; }
@media (min-width: 900px) {
  .viewer { padding: 18px; }
  .v-shell { max-width: 1280px; border-radius: 24px; border: 1px solid var(--line-hi); overflow: hidden; box-shadow: var(--shell-shadow); }
}
.viewer:fullscreen { padding: 0; background: var(--fs-bg); }
.viewer:fullscreen .v-shell { max-width: none; border-radius: 0; border: 0; }

.v-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: rgba(var(--w), 0.04); }
/* Desktop: this wrapper is transparent — its children lay out directly as .v-bar's own flex
   items, exactly as if there were no wrapper at all. Only overridden on narrow screens below. */
#vBar2 { display: contents; }
.v-title { flex: 1 1 160px; min-width: 0; line-height: 1.25; }
.v-title strong { display: block; font-family: var(--font-display); font-weight: 620; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title span { display: block; color: var(--dim); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border-radius: 13px; border: 1px solid var(--line); background: rgba(var(--w), 0.03); flex: none; }
.grp .ib { width: 32px; height: 32px; border-color: transparent; background: none; }
.grp .ib:hover { background: var(--glass-hi); }
.pg-in { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pg-in input { width: 3.1em; height: 30px; text-align: center; border-radius: 9px; border: 1px solid var(--line); background: rgba(var(--w), 0.06); outline: 0; -moz-appearance: textfield; appearance: textfield; appearance: textfield; }
.pg-in input::-webkit-outer-spin-button, .pg-in input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.pg-in input:focus { border-color: var(--strong); box-shadow: 0 0 0 3px rgba(var(--w), 0.12); }
.zl { min-width: 3.4em; text-align: center; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.v-bar .btn { height: 38px; }

.v-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; background: radial-gradient(ellipse at 50% 0%, rgba(var(--w), 0.06), transparent 55%), var(--reader-bg); -webkit-overflow-scrolling: touch; }
.v-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; width: max-content; min-width: 100%; padding: 24px 32px 48px; transform-origin: 0 0; }
.pg { position: relative; flex: none; background: #fff; border-radius: 3px; overflow: hidden; box-shadow: var(--pg-shadow); }
.pg:not(.ready)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(0, 0, 0, 0.06) 50%, transparent 70%); background-size: 250% 100%; animation: shimmer 1.3s linear infinite; }
.pg canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Selectable text over the page image (PDF.js text layer) */
.textLayer { position: absolute; inset: 0; overflow: hidden; opacity: 0.25; line-height: 1; text-align: initial; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0 0; }
.textLayer ::selection { background: rgb(0, 0, 255); }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }
.textLayer .endOfContent.active { top: 0; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }

.v-status { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px; color: var(--muted); pointer-events: none; }
.v-status a, .v-status button { pointer-events: auto; }
.v-status:empty { display: none; }
.v-retry { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(var(--w), 0.15); border-top-color: var(--strong); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ---------- Compare (split view) ---------- */
.v-body { display: flex; flex: 1; min-height: 0; }
.v-body .v-scroll, .v-body .v-cmp { min-width: 0; min-height: 0; }
.v-cmp { flex: 1; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--shell-bg); }
.v-cmp[hidden] { display: none; }
/* Compare "below" layout: stack the two panes instead of placing them side by side */
.v-body.stacked { flex-direction: column; }
.v-body.stacked .v-cmp { border-left: 0; border-top: 1px solid var(--line); }

/* Draggable divider between the main pane and the compare pane */
.v-resizer { flex: 0 0 10px; position: relative; cursor: col-resize; touch-action: none; }
.v-resizer[hidden] { display: none; }
.v-resizer::after { content: ""; position: absolute; inset: 0; margin: auto; width: 2px; height: 32px; border-radius: 2px; background: var(--line); }
.v-resizer:hover::after, .v-resizer:focus-visible::after { background: var(--strong); }
.v-resizer:focus-visible { outline: 0; }
.v-body.stacked .v-resizer { cursor: row-resize; }
.v-body.stacked .v-resizer::after { width: 32px; height: 2px; }
.v-cmp-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: rgba(var(--w), 0.04); }
.v-cmp-title { flex: 1; font-weight: 600; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.v-cmp-pick { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.v-cmp-pick[hidden] { display: none; }
#cmpSearch { height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(var(--w), 0.06); padding: 0 12px; font: inherit; color: inherit; outline: 0; }
#cmpSearch:focus { border-color: var(--strong); box-shadow: 0 0 0 3px rgba(var(--w), 0.12); }
.v-cmp-results { display: flex; flex-direction: column; gap: 6px; }
.v-cmp-empty { font-size: 0.85rem; color: var(--muted); margin: 4px 2px; }
.v-cmp-refs { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.v-cmp-refs[hidden] { display: none; }
.v-cmp-refs-h { font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin: 0 2px 2px; }
.v-cmp-ref-missing { opacity: 0.55; cursor: not-allowed; }
.v-cmp-ref-missing:hover { background: rgba(var(--w), 0.03); }
.v-cmp-result { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(var(--w), 0.03); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.v-cmp-result b { font-size: 0.86rem; font-weight: 600; }
.v-cmp-result span { font-size: 0.76rem; color: var(--muted); }
.v-cmp-result:hover, .v-cmp-result:focus-visible { background: rgba(var(--w), 0.08); outline: 0; }
@media (max-width: 900px) {
  /* Too narrow for side-by-side panes, so Compare always opens below instead — the
     layout toggle has nothing to toggle here, so it's hidden rather than shown disabled. */
  .v-body { flex-direction: column; }
  .v-cmp { border-left: 0; border-top: 1px solid var(--line); }
  #cmpLayout { display: none; }
  .v-resizer { cursor: row-resize; }
  .v-resizer::after { width: 32px; height: 2px; }
}

.v-prog { height: 2px; background: rgba(var(--w), 0.06); }
.v-prog i { display: block; height: 100%; width: 0; background: var(--strong); box-shadow: var(--prog-glow); transition: width 0.12s; }

@media (max-width: 760px) {
  .v-bar > .o-close { order: 0; }
  .v-bar > .v-title { order: 1; }
  .v-bar > .o-dl { order: 2; }
  /* The row of secondary buttons scrolls sideways instead of wrapping onto more lines — a
     flex-wrap container can only ever grow taller, never scroll, so this needs its own
     nowrap+overflow context rather than trying to make .v-bar itself scroll. */
  #vBar2 {
    display: flex; flex-wrap: nowrap; align-items: center; gap: 8px 10px;
    order: 3; flex-basis: 100%; width: 100%; min-width: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  #vBar2::-webkit-scrollbar { display: none; }
  #vBar2 > * { flex: 0 0 auto; }   /* buttons/groups keep their natural size, never shrink to fit */
  .v-bar .zbtn, .v-bar .zl, .v-bar .o-full { display: none; }
  .v-pages { padding: 14px 12px 40px; gap: 12px; }
}

/* ---------- Share dialog + toasts ---------- */
.dlg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: var(--scrim-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.dlg-card { position: relative; width: min(400px, 100%); padding: 26px 24px 22px; border-radius: 26px; background: var(--panel); border-color: var(--line-hi); box-shadow: var(--dlg-shadow); animation: pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { opacity: 0; transform: scale(0.95) translateY(8px); } }
.dlg-card h3 { font-family: var(--font-display); font-size: 1.35rem; letter-spacing: -0.02em; }
.dlg-card .nm { color: var(--muted); font-size: 0.92rem; margin-top: 2px; padding-right: 36px; }
.dlg-x { position: absolute; top: 14px; right: 14px; }
.qr { width: 188px; height: 188px; margin: 20px auto 18px; padding: 12px; border-radius: 18px; background: #fff; box-shadow: var(--qr-shadow); }
.qr svg { display: block; width: 100%; height: 100%; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(var(--w), 0.05); font-size: 0.85rem; color: var(--muted); outline: 0; }
.copy input:focus { border-color: var(--strong); }
.dlg-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dlg-acts .btn { flex: 1 1 calc(50% - 4px); min-width: 0; justify-content: center; }
.dlg-acts #shReport { flex-basis: 100%; }

/* Messages: a glass capsule that slides in from the right and slides back out */
#toasts { position: fixed; z-index: 90; right: 16px; bottom: 24px; display: grid; gap: 10px; justify-items: end; pointer-events: none; width: max-content; max-width: min(400px, calc(100% - 32px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-radius: 999px; background: var(--toast-bg); border: 1px solid var(--line-hi); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: var(--toast-shadow), inset 0 1px 0 rgba(var(--w), 0.08); font-size: 0.92rem; line-height: 1.35; animation: toast-in 0.38s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.toast.out { animation: toast-out 0.26s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateX(calc(100% + 24px)); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(calc(100% + 24px)); } }
/* A message that asks a question (replaces the browser's own confirm box) */
.toast.ask { pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; border-radius: 24px; padding: 14px 16px 12px 20px; }
.toast.ask .t-msg { flex: 1 1 100%; }
.toast.ask .t-acts { display: flex; gap: 8px; }
.toast.ask .btn { height: 36px; padding: 0 14px; border-radius: 999px; font-size: 0.88rem; }


/* ---------- Visitor statistics notice (shown once; built by analytics.js) ---------- */
.consent { position: fixed; z-index: 65; left: 24px; bottom: 24px; display: flex; align-items: center; gap: 12px 16px; width: min(460px, calc(100% - 48px)); padding: 14px 14px 14px 20px; border-radius: 20px; border-color: var(--line-hi); background: var(--toast-bg); box-shadow: var(--toast-shadow), inset 0 1px 0 rgba(var(--w), 0.08); animation: consent-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.consent p { flex: 1 1 auto; margin: 0; font-size: 0.86rem; line-height: 1.5; color: var(--muted); text-wrap: pretty; }
.consent p a { color: var(--strong); font-weight: 550; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(var(--w), 0.35); transition: text-decoration-color 0.2s; }
.consent p a:hover { text-decoration-color: currentColor; }
.consent-btns { flex: none; display: flex; }
.consent .btn { height: 38px; padding: 0 18px; border-radius: 999px; font-size: 0.88rem; }
.consent.out { animation: consent-out 0.26s ease-in both; pointer-events: none; }
@keyframes consent-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes consent-out { to { opacity: 0; transform: translateY(16px); } }
@media (max-width: 640px) {
  .consent { left: 12px; right: 12px; bottom: 12px; width: auto; flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; border-radius: 22px; }
  .consent p { font-size: 0.88rem; }
  .consent-btns .btn { flex: 1; height: 42px; }
}
@media (prefers-reduced-motion: reduce) { .consent, .consent.out { animation-duration: 0.01s; } }
/* Keep the back-to-top button clear of the notice while it is showing */
@media (max-width: 1100px) { body:has(.consent:not(.out)) .to-top { bottom: 124px; } }
@media (max-width: 640px) { body:has(.consent:not(.out)) .to-top { bottom: 172px; } }

/* ---------- Back to top (glass pill; a round icon button on phones) ---------- */
.to-top { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none; height: 44px; padding: 0 18px 0 14px; cursor: pointer; backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); transition: opacity 0.25s, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.3s, border-color 0.2s, box-shadow 0.25s, background 0.2s; }
.to-top.on { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); transition-delay: 0s; }
.to-top.on:active { transform: translate(-50%, 0) scale(0.97); }
html.no-scroll .to-top { display: none; }
@media (max-width: 640px) {
  .to-top { left: auto; right: 16px; bottom: 20px; width: 48px; height: 48px; padding: 0; border-radius: 50%; transform: translateY(16px); }
  .to-top span { display: none; }
  .to-top.on { transform: none; }
  .to-top.on:active { transform: scale(0.94); }
  body.to-top-on #toasts { bottom: 80px; }
}
/* Admin: always the round corner button, lifted above the sticky action bars */
.adm .to-top { left: auto; right: 20px; bottom: 88px; width: 48px; height: 48px; padding: 0; border-radius: 50%; transform: translateY(16px); }
.adm .to-top span { display: none; }
.adm .to-top.on { transform: none; }
.adm .to-top.on:active { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) { .to-top, .to-top.on { transition: opacity 0.01s, visibility 0s; } }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .back .t { display: none; }
  .frow { grid-template-columns: 1fr; gap: 6px; }
  .search { height: 58px; padding-left: 16px; border-radius: 18px; }
  .kbd { display: none; }
  .toolbar { align-items: flex-start; }
  .toolbar, .tb-right { width: 100%; }
  .sort-label { width: 100%; order: 2; margin: 2px 0 -4px 2px; }
  .seg { width: 100%; order: 3; }
  .seg button { flex: 1; padding: 0 4px; font-size: 0.82rem; }
}

@media (hover: none) { .spot { display: none; } .gh:hover { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spot { display: none; }
}

/* Filters applied from the search text */
.auto-note { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--dim); font-size: 0.88rem; }
.auto-note[hidden] { display: none; }
.auto-note span { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-hi); color: var(--strong); background: var(--glass); }
/* Static copy for crawlers; the live page replaces it */
.js-ready .seo-static .seo-list { display: none; }
.seo-static { padding: 24px 0; color: var(--muted); }
.seo-static a { color: var(--strong); }
.seo-static ul { padding-left: 1.1em; display: grid; gap: 6px; }

/* Browse links (also how search engines find every landing page) */
.seo-browse { display: grid; gap: 10px; margin-bottom: 14px; color: var(--dim); font-size: 0.85rem; }
.seo-browse div { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.seo-browse b { color: var(--muted); font-weight: 600; min-width: 112px; }
.seo-browse a { color: var(--muted); text-decoration: none; }
.seo-browse a:hover, .seo-browse a[aria-current] { color: var(--strong); text-decoration: underline; text-underline-offset: 3px; }

.foot .disclaimer { margin: 14px 4px 0; max-width: 80ch; color: var(--dim); font-size: 0.78rem; line-height: 1.6; }

/* About link in the top bar: stays visible on phones, the bar is tightened to make room */
.nav-about { text-decoration: none; }
@media (max-width: 560px) {
  .nav-in { gap: 6px; padding: 6px 6px 6px 12px; }
  .brand { font-size: 0.95rem; }
  .nav-about { padding: 0 11px; font-size: 0.85rem; }
}
@media (max-width: 420px) { .brand span { display: none; } } /* small phones: just "ICSE" */

/* Exam countdown */
.exams { padding-top: 0; padding-bottom: 8px; }
.exam-card { border-radius: var(--r-lg); padding: 16px 20px; }
.exam-main { display: flex; align-items: center; gap: 14px; }
.exam-main > .ic { width: 26px; height: 26px; flex: none; color: var(--muted); }
.exam-main > div:nth-child(2) { flex: 1; min-width: 0; }
.exam-title { color: var(--dim); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.exam-next { margin-top: 2px; color: var(--muted); }
.exam-next b { color: var(--strong); font-weight: 600; }
.exam-days { display: flex; gap: clamp(10px, 2.4vw, 22px); }
.exam-days > div { text-align: center; line-height: 1.1; min-width: 2.4ch; }
.exam-days b { display: block; font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: clamp(1.4rem, 4.4vw, 2.2rem); font-weight: 700; letter-spacing: -0.03em; text-shadow: var(--text-glow); }
.exam-days span { color: var(--dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 560px) { .exam-main { flex-wrap: wrap; } .exam-days { width: 100%; justify-content: space-between; padding: 6px 4px 0; } }
.is-filtering #exams { display: none; }
/* About page */
.about { padding: clamp(40px, 8vh, 90px) 0 20px; max-width: 760px; }
.about h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: -0.035em; line-height: 1.05; }
.about .lead { margin-top: 18px; color: var(--muted); font-size: clamp(1.02rem, 2vw, 1.18rem); }
.about section { margin-top: 34px; }
.about h2 { font-family: var(--font-display); font-weight: 650; font-size: 1.25rem; letter-spacing: -0.02em; margin-bottom: 10px; }
.about p, .about li { color: var(--muted); }
.about ul { padding-left: 1.2em; display: grid; gap: 6px; }
.about a:not(.btn) { color: var(--strong); text-underline-offset: 3px; }
.about .glass { padding: 18px 22px; border-radius: var(--r-lg); }
.about .back-cta { margin-top: 34px; display: inline-flex; }

/* ---------- Theme toggle ---------- */
.theme-btn { flex: none; }
.theme-btn .i-moon { display: none; }
html[data-theme="light"] .theme-btn .i-sun { display: none; }
html[data-theme="light"] .theme-btn .i-moon { display: inline-block; }

/* ---------- Light theme (public site only; the admin never sets data-theme) ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --text: #0a0a0b;
  --w: 0, 0, 0;
  --wi: 255, 255, 255;
  --strong: #0a0a0b;
  --paper: #fff;
  --muted: rgba(0, 0, 0, 0.64);
  --dim: rgba(0, 0, 0, 0.55);
  --line: rgba(0, 0, 0, 0.12);
  --line-hi: rgba(0, 0, 0, 0.3);
  --glass: rgba(0, 0, 0, 0.035);
  --glass-hi: rgba(0, 0, 0, 0.07);
  --glow: 0 8px 26px -12px rgba(0, 0, 0, 0.2);
  --glow-hi: 0 10px 30px -12px rgba(0, 0, 0, 0.26);
  --btn-glow: none;
  --btn-glow-hi: none;
  --badge-glow: none;
  --search-glow: 0 0 0 4px rgba(0, 0, 0, 0.06);
  --text-glow: none;
  --shell-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.35);
  --qr-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  --toast-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.3);
  --pg-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 10px 30px -10px rgba(0, 0, 0, 0.28);
  --prog-glow: none;
  --dlg-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.4);
  --panel: rgba(255, 255, 255, 0.86);
  --nav-bg: rgba(255, 255, 255, 0.9);
  --toast-bg: rgba(255, 255, 255, 0.94);
  --glass-solid: rgba(246, 246, 248, 0.97);
  --scrim: rgba(255, 255, 255, 0.74);
  --scrim-2: rgba(255, 255, 255, 0.55);
  --shell-bg: rgba(250, 250, 251, 0.82);
  --fs-bg: #f2f3f5;
  --reader-bg: #eceef1;
  --lift: rgba(0, 0, 0, 0.2);
}
html[data-theme="light"] .orb, html[data-theme="light"] .spot { display: none; }
html[data-theme="light"] .glass { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 30px -16px rgba(0, 0, 0, 0.12); }
html[data-theme="light"] .gh::before { display: none; }
html[data-theme="light"] .gh:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glow); }
/* Subject colours in light mode: keep the true, bright colour and let it tint the card softly (no darkening) */
html[data-theme="light"] .dot { background: var(--accent, #000); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #000) 30%, transparent), 0 0 14px var(--accent, #000); }
html[data-theme="light"] .chip .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #000) 30%, transparent), 0 0 9px var(--accent, #000); }
html[data-theme="light"] .subj {
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 30%, #fff) 0%, color-mix(in srgb, var(--accent) 9%, #fff) 100%);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
html[data-theme="light"] .subj .cnt { color: var(--strong); }
html[data-theme="light"] .subj::after { opacity: 1; height: 3px; box-shadow: 0 0 12px var(--accent); }
html[data-theme="light"] .subj:hover { border-color: color-mix(in srgb, var(--accent) 80%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 16px 36px -14px color-mix(in srgb, var(--accent) 75%, transparent); }
html[data-theme="light"] .exam-days b, html[data-theme="light"] .hero h1 { text-shadow: none; }
html[data-theme="light"] .btn-primary { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
html[data-theme="light"] .btn-primary:hover { box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.45); }

/* ---------- Theme change: light to dark paints from top to bottom, dark to light from bottom to top ---------- */
html.theme-wiping *, html.theme-wiping *::before, html.theme-wiping *::after { transition: none !important; }
html.theme-wiping::view-transition-old(root),
html.theme-wiping::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-wiping::view-transition-new(root) {
  animation: theme-wipe 1.5s cubic-bezier(0.4, 0, 0.3, 1) both;
  /* soft edge: opaque on top, fading to clear over ~40% of the screen height */
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 41.7%, transparent 58.3%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 41.7%, transparent 58.3%, transparent 100%);
  -webkit-mask-size: 100% 240%; mask-size: 100% 240%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
@keyframes theme-wipe {
  from { -webkit-mask-position: 0 100%; mask-position: 0 100%; }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}
/* dark to light: the same wipe, running from the bottom to the top */
html.theme-wiping.theme-wipe-up::view-transition-new(root) {
  animation-name: theme-wipe-up;
  -webkit-mask-image: linear-gradient(to top, #000 0, #000 41.7%, transparent 58.3%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0, #000 41.7%, transparent 58.3%, transparent 100%);
}
@keyframes theme-wipe-up {
  from { -webkit-mask-position: 0 0; mask-position: 0 0; }
  to { -webkit-mask-position: 0 100%; mask-position: 0 100%; }
}

/* ---------- Paper pages (generated by scripts/build-seo.js) ---------- */
.paper .crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 18px; font-size: 0.86rem; color: var(--muted); }
.paper .crumbs a:not(.btn) { color: var(--muted); text-decoration: none; }
.paper .crumbs a:not(.btn):hover { color: var(--strong); text-decoration: underline; }
.paper .crumbs span { opacity: 0.45; }
.paper-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.paper-cta .btn { text-decoration: none; }
.paper-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.paper-facts dt { color: var(--muted); }
.paper-facts dd { margin: 0; color: var(--text); }
.paper-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.paper-tags span { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 0.86rem; }
.about ul.paper-related { list-style: none; padding-left: 0; }
.paper-note { font-size: 0.86rem; }

/* ---------- Timed exam mode ---------- */
.x-chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 12px; border-radius: 12px; border: 1px solid var(--line-hi); background: rgba(var(--w), 0.06); font-variant-numeric: tabular-nums; flex: none; }
.x-chip .ic { width: 16px; height: 16px; color: var(--muted); }
.x-ph { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; }
.x-time { font-family: var(--font-display); font-weight: 650; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--strong); min-width: 4.2ch; }
.x-chip[data-warn="1"] .x-time { color: #fbbf24; }
.x-chip[data-warn="2"] .x-time { color: #ff7b7b; }
:root[data-theme="light"] .x-chip[data-warn="1"] .x-time { color: #f59e0b; }
:root[data-theme="light"] .x-chip[data-warn="2"] .x-time { color: #ef4444; }
.x-fin { height: 28px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 0.8rem; cursor: pointer; }
.x-fin:hover { color: var(--strong); border-color: var(--line-hi); }

.x-dlg .dlg-card { width: min(440px, 100%); }
.x-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.x-dlg .nm + .x-row { margin-top: 14px; }
.x-row label { font-weight: 550; }
.x-step { display: inline-flex; align-items: center; gap: 6px; }
.x-step .ib { width: 34px; height: 34px; font-size: 1.1rem; }
.x-step input { width: 4.2em; height: 36px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: rgba(var(--w), 0.06); color: inherit; font: inherit; outline: 0; -moz-appearance: textfield; appearance: textfield; }
.x-step input::-webkit-outer-spin-button, .x-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.x-step input:focus { border-color: var(--strong); box-shadow: 0 0 0 3px rgba(var(--w), 0.12); }
.x-unit { color: var(--muted); font-size: 0.86rem; }
.x-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.x-check input { width: 18px; height: 18px; accent-color: var(--strong); }
.x-sum { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.x-note { margin: 12px 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.x-note.warn { color: var(--strong); }
.x-dlg .dlg-acts { margin-top: 18px; }

.x-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 18px; padding: 12px 16px; border-radius: 16px; }
.x-banner p { flex: 1 1 220px; margin: 0; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.x-banner .btn { height: 36px; padding: 0 14px; }

.x-start { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--dim); font: inherit; font-size: 0.82rem; cursor: pointer; }
.x-start .ic { width: 15px; height: 15px; }
.x-start:hover { color: var(--strong); border-color: var(--line-hi); }

/* ---------- Marking scheme lock (timed exam) ---------- */
.v-lock { width: min(100%, 460px); margin-top: 8px; padding: 26px 22px; text-align: center; border: 1px dashed var(--line-hi); border-radius: 18px; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.v-lock strong { display: block; margin-bottom: 4px; color: var(--strong); font-family: var(--font-display); font-size: 1.05rem; font-weight: 620; }
html[data-exam-lock] #vDl, html[data-exam-lock] #vShare, html[data-exam-lock] .v-status a { display: none !important; }

/* ---------- Timed exam: history, scores, beep, phone fit ---------- */
.x-chip[data-phase="reading"] .x-ph { color: #60a5fa; }
.x-chip[data-phase="writing"] .x-ph { color: #4ade80; }
:root[data-theme="light"] .x-chip[data-phase="reading"] .x-ph { color: #3b82f6; }
:root[data-theme="light"] .x-chip[data-phase="writing"] .x-ph { color: #22c55e; }

.x-score { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 12px 0 2px; border-top: 1px solid var(--line); }
.x-score label { font-weight: 550; }
.x-in { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.x-score input { width: 4.4em; height: 36px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: rgba(var(--w), 0.06); color: inherit; font: inherit; outline: 0; -moz-appearance: textfield; appearance: textfield; }
.x-score input::-webkit-outer-spin-button, .x-score input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.x-score input:focus { border-color: var(--strong); box-shadow: 0 0 0 3px rgba(var(--w), 0.12); }
.x-score input[aria-invalid="true"] { border-color: #ff7b7b; }
.x-danger { color: #ff7b7b; }
:root[data-theme="light"] .x-danger { color: #ef4444; }

.hist-list { display: flex; flex-direction: column; gap: 12px; }
.hist { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px 21px; border-radius: 22px; }
.hist::after { content: ""; position: absolute; left: 22px; right: 22px; bottom: 0; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.hist .h-bar { position: absolute; z-index: 1; left: 22px; bottom: 0; height: 3px; width: calc((100% - 44px) * var(--p, 0)); border-radius: 3px; background: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.hist .h-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hist .tl { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.84rem; }
.hist .h-when { color: var(--dim); }
.hist .h-when::before { content: "\00b7"; margin-right: 8px; }
.hist h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em; line-height: 1.25; overflow-wrap: anywhere; }
.hist h3 a { color: inherit; text-decoration: none; }
.hist h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.hist .h-meta { margin: 0; color: var(--dim); font-size: 0.86rem; }
.hist .h-score { display: flex; align-items: center; gap: 14px; flex: none; }
.hist .h-pct { font-family: var(--font-display); font-weight: 650; font-size: 1.9rem; line-height: 1; letter-spacing: -0.04em; color: var(--accent); }
.hist .h-marks { color: var(--muted); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.hist .h-edit { height: 36px; padding: 0 14px; }
:root[data-theme="light"] .hist .h-pct { color: var(--strong); }
:root[data-theme="light"] .hist .h-bar { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
:root[data-theme="light"] .hist::after { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.h-tools { display: inline-flex; gap: 8px; margin-left: auto; }
.h-tools .btn { height: 36px; padding: 0 14px; }
.block-head .sub:not(:empty) + .h-tools { margin-left: 0; }

/* Phone fit: Saved and History become icon pills with a count badge, and the timer chip and toolbar tighten up */
@media (max-width: 560px) {
  #savedBtn, #histBtn { position: relative; width: 40px; padding: 0; justify-content: center; }
  #savedBtn .lbl, #histBtn .lbl { display: none; }
  #savedBtn .n, #histBtn .n { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 0.68rem; background: var(--strong); color: var(--paper); }
  #savedBtn[aria-pressed="true"] .n, #histBtn[aria-pressed="true"] .n { background: var(--paper); color: var(--strong); }
  .hist { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px 18px 20px; }
  .hist::after { left: 18px; right: 18px; }
  .hist .h-bar { left: 18px; width: calc((100% - 36px) * var(--p, 0)); }
  .hist .h-score { justify-content: space-between; }
  .block-head { flex-wrap: wrap; }
  .h-tools { width: 100%; justify-content: flex-end; }

  .v-bar { gap: 8px 6px; }
  .x-chip { height: 36px; padding: 0 4px 0 10px; gap: 6px; border-radius: 11px; }
  .x-ph { font-size: 0; width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }   /* phase shown as a coloured dot */
  .x-time { font-size: 1rem; }
  .x-fin { height: 26px; padding: 0 8px; }
}
@media (max-width: 760px) {
  html[data-exam-on] #vSave, html[data-exam-on] #vReport { display: none; }   /* room for the timer while an exam runs */
}

/* score box feedback */
.x-scorebox { margin-top: 14px; border-top: 1px solid var(--line); }
.x-scorebox .x-score { margin-top: 0; border-top: 0; }
.x-msg { display: block; min-height: 1.3em; padding-bottom: 2px; font-size: 0.84rem; line-height: 1.4; color: var(--muted); }
.x-msg.ok { color: #4ade80; }
.x-msg.bad { color: #ff7b7b; }
:root[data-theme="light"] .x-msg.ok { color: #22c55e; }
:root[data-theme="light"] .x-msg.bad { color: #ef4444; }

/* fixed total marks */
.x-total { font-weight: 600; color: var(--strong); font-variant-numeric: tabular-nums; }
.x-in .x-total { min-width: 2.2em; text-align: left; }
.x-lbl { font-weight: 550; }

/* Light mode: bright indicator colours, each on a soft tint of itself so they stay readable on white */
:root[data-theme="light"] .x-chip[data-warn="1"] { background: color-mix(in srgb, #f59e0b 16%, #fff); border-color: color-mix(in srgb, #f59e0b 45%, transparent); }
:root[data-theme="light"] .x-chip[data-warn="2"] { background: color-mix(in srgb, #ef4444 14%, #fff); border-color: color-mix(in srgb, #ef4444 45%, transparent); }
:root[data-theme="light"] .x-msg.ok { background: color-mix(in srgb, #22c55e 14%, #fff); border-radius: 8px; padding: 3px 8px; }
:root[data-theme="light"] .x-msg.bad { background: color-mix(in srgb, #ef4444 12%, #fff); border-radius: 8px; padding: 3px 8px; }
:root[data-theme="light"] .x-msg:empty { background: none; padding: 0; }
:root[data-theme="light"] .x-danger { border-color: color-mix(in srgb, #ef4444 45%, transparent); background: color-mix(in srgb, #ef4444 10%, #fff); }
@media (min-width: 561px) {
  :root[data-theme="light"] .x-chip .x-ph { padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, #fff); }
}

/* ---------- Accounts: Log in button, account menu, dialog ---------- */
.acct-btn { padding: 0 14px 0 6px; gap: 8px; }
.acct-btn:not(.on) { padding: 0 14px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; overflow: hidden; background: var(--strong); color: var(--paper); font-weight: 650; font-size: 0.8rem; line-height: 1; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 42px; height: 42px; font-size: 1.05rem; }
.acct-menu { position: absolute; z-index: 30; right: 0; top: calc(100% + 8px); width: min(310px, 100%); padding: 16px; border-radius: 22px; background: var(--glass-solid); border-color: var(--line-hi); box-shadow: var(--dlg-shadow); animation: pop 0.18s ease-out; display: grid; gap: 12px; }
.am-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.am-who > div { min-width: 0; display: grid; }
.am-who strong { font-family: var(--font-display); font-weight: 650; font-size: 1.05rem; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-who span:not(.avatar) { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-state { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.am-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.am-state.synced::before { background: #22c55e; box-shadow: 0 0 10px #22c55e88; }
.am-state.syncing::before { background: #f59e0b; }
.am-state.offline::before, .am-state.error::before { background: #ef4444; }
.am-note { color: var(--dim); font-size: 0.8rem; line-height: 1.5; }
.am-out { width: 100%; justify-content: center; }

.ac-dlg .dlg-card { width: min(410px, 100%); }
.ac-dlg .nm { margin-bottom: 16px; }
.ac-google { width: 100%; justify-content: center; gap: 10px; }
.ac-google .g-logo { fill: initial; stroke: none; width: 1.2em; height: 1.2em; }
.ac-or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--dim); font-size: 0.8rem; }
.ac-or::before, .ac-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ac-form { display: grid; gap: 10px; }
.ac-form input { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(var(--w), 0.06); color: inherit; font: inherit; outline: 0; transition: border-color 0.2s, box-shadow 0.2s; }
.ac-form input::placeholder { color: var(--dim); }
.ac-form input:focus { border-color: var(--strong); box-shadow: 0 0 0 3px rgba(var(--w), 0.12); }
.ac-pw { position: relative; }
.ac-pw input { padding-right: 64px; }
.ac-show { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 0.82rem; font-weight: 550; }
.ac-show:hover { color: var(--strong); background: var(--glass-hi); }
.ac-msg { min-height: 1.2em; font-size: 0.86rem; line-height: 1.4; color: #ff7b7b; }
.ac-msg:empty { min-height: 0; }
.ac-msg.ok { color: #22c55e; }
:root[data-theme="light"] .ac-msg { color: #dc2626; }
:root[data-theme="light"] .ac-msg.ok { color: #16a34a; }
.ac-submit { width: 100%; justify-content: center; height: 46px; }
.ac-submit[disabled] { opacity: 0.6; pointer-events: none; }
.ac-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin-top: 2px; font-size: 0.86rem; color: var(--muted); }
.ac-link { border: 0; background: none; padding: 4px 0; color: var(--muted); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.ac-link:hover, .ac-link.strong { color: var(--strong); }
.ac-link.strong { font-weight: 600; }
.ac-foot { margin-top: 14px; color: var(--dim); font-size: 0.78rem; text-align: center; }

/* ---------- Continue where you left off ---------- */
.cont { position: relative; padding-right: 16px; }
.cont .tl { padding-right: 34px; }
.cont-x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 9px; opacity: 0.55; }
.cont-x:hover, .cont-x:focus-visible { opacity: 1; }
.cont-bar { height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 25%, transparent); overflow: hidden; }
.cont-bar i { display: block; height: 100%; width: calc(100% * var(--p, 0)); border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }

@media (max-width: 560px) {
  .acct-btn, .acct-btn:not(.on) { width: 40px; padding: 0; justify-content: center; }
  .acct-btn .lbl { display: none; }
  .acct-btn.on .avatar { width: 30px; height: 30px; }
  .acct-menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}

/* Accounts: verification box, settings dialog */
.am-state.verify::before { background: #f59e0b; }
.am-verify { display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: rgba(var(--w), 0.05); border: 1px solid var(--line); }
.am-verify p { color: var(--muted); font-size: 0.84rem; line-height: 1.5; overflow-wrap: anywhere; }
.am-vbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.am-vbtns .btn { flex: 1 1 auto; height: 38px; padding: 0 12px; justify-content: center; font-size: 0.86rem; }
.am-set { width: 100%; justify-content: center; }
.as-sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.as-sec h4 { margin: 0 0 2px; font-family: var(--font-display); font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; }
.ac-dlg .dlg-card form.as-sec:first-of-type { margin-top: 14px; }
.as-note { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.ac-dlg .dlg-card { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* Landing pages: the page's own heading is the H1, and the helpful text under the library stays visible */
.hero h1.h1-landing { font-size: clamp(2rem, 5.2vw, 3.8rem); max-width: 24ch; line-height: 1.04; letter-spacing: -0.035em; }
.seo-copy { max-width: 78ch; }
.seo-copy h2 { font-family: var(--font-display); font-weight: 650; font-size: clamp(1.2rem, 2.6vw, 1.5rem); letter-spacing: -0.02em; color: var(--text); margin-bottom: 10px; }
.seo-copy h3 { margin: 20px 0 8px; font-family: var(--font-display); font-size: 1.05rem; color: var(--text); }
.seo-copy p { margin: 0 0 10px; line-height: 1.65; }
.seo-copy details { border-top: 1px solid var(--line); padding: 10px 0 2px; }
.seo-copy summary { cursor: pointer; font-weight: 600; color: var(--text); list-style: none; }
.seo-copy summary::-webkit-details-marker { display: none; }
.seo-copy details p { margin-top: 6px; }

/* ---------- Email link page (/auth/action/) ---------- */
.act-wrap { max-width: 520px; }
.act-wrap .act { margin-top: 26px; display: grid; justify-items: start; gap: 14px; padding: 26px; }
.act-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; border: 1px solid var(--line-hi); background: var(--glass-hi); }
.act-ic svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act-ic.ok { color: #4ade80; }
.act-ic.bad { color: #ff7b7b; }
.act-ic.key, .act-ic.wait { color: var(--strong); }
.act-p { color: var(--muted); line-height: 1.55; }
.act .ac-form { width: 100%; }
.act .ac-form .btn { width: 100%; justify-content: center; }
.act-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
html[data-theme="light"] .act-ic.ok { color: #16a34a; }
html[data-theme="light"] .act-ic.bad { color: #dc2626; }

/* the hidden attribute must win over display:grid on the account forms (hides Change password for Google users) */
.ac-dlg [hidden] { display: none !important; }
/* Reminder that a search or filter is on, shown once the result count has scrolled out of sight */
.filter-flag { position: fixed; z-index: 55; left: 16px; bottom: 20px; height: 44px; gap: 10px; cursor: pointer; display: inline-flex; align-items: center; }
.filter-flag[hidden] { display: none; }
.filter-flag b { font-weight: 650; color: var(--strong); }
.filter-flag span { text-decoration: underline; text-underline-offset: 3px; color: var(--strong); }
html.no-scroll .filter-flag { display: none; }
body:has(.consent:not(.out)) .filter-flag { display: none; }
@media (max-width: 640px) { .filter-flag { max-width: calc(100% - 96px); font-size: 0.85rem; } }

/* ---------- Hamburger menu (small screens) ---------- */
/* Wide screens: the wrapper disappears, so the top bar is laid out exactly as before */
.nav-links { display: contents; }
.nav-toggle, .nav-lbl { display: none; }
.nav-toggle .p-close { display: none; }
.nav-open .nav-toggle .p-open { display: none; }
.nav-open .nav-toggle .p-close { display: inline; }
.admin-pill { text-decoration: none; }

@media (max-width: 1000px) {
  .nav-toggle { display: inline-flex; width: 40px; height: 40px; border-radius: 999px; }
  .nav-toggle .ic { width: 20px; height: 20px; }
  .nav-links {
    display: none; position: absolute; z-index: 30; right: 0; width: min(340px, 100%); top: calc(100% + 8px);
    padding: 10px; border-radius: 22px; background: var(--glass-solid); border: 1px solid var(--line-hi);
    box-shadow: var(--dlg-shadow); animation: pop 0.18s ease-out; gap: 6px;
  }
  .nav-open .nav-links { display: grid; }
  /* every entry becomes a full-width row with its label showing */
  .nav-links .pill, .nav-links .ib, .nav-links #savedBtn, .nav-links #histBtn { width: 100%; height: 46px; padding: 0 16px; border-radius: 14px; justify-content: flex-start; font-size: 0.95rem; position: static; }
  .nav-links .nav-lbl { display: inline; font-weight: 550; font-size: 0.95rem; }
  .nav-links #savedBtn .lbl, .nav-links #histBtn .lbl { display: inline; }
  .nav-links #savedBtn .n, .nav-links #histBtn .n { position: static; margin-left: auto; min-width: 22px; height: 22px; font-size: 0.75rem; background: rgba(var(--w), 0.14); color: inherit; }
  .nav-links #savedBtn[aria-pressed="true"] .n, .nav-links #histBtn[aria-pressed="true"] .n { background: rgba(var(--wi), 0.14); color: inherit; }
  .nav-links .nav-about { padding: 0 16px; font-size: 0.95rem; }
  .nav-links .ic { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: reduce) { .nav-links { animation: none; } }
