*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #000000;
  --bg-header: #6d5eb5;
  --surface:   #6d5eb5;
  --surface2:  #362879;
  --border:    rgba(255,255,255,.80);

  /* Golden amber — mantissa */
  --m:   #e8e800;
  --ml:  #ffff00;
  --mg:  rgba(255,255,0,.20);

  /* Pure green — exponent */
  --ex:  #00cc00;
  --exl: #00ff00;
  --exg: rgba(0,255,0,.16);

  /* Pure red — sign bits */
  --sg:  #cc0000;
  --sgl: #ff0000;
  --sgg: rgba(255,0,0,.14);

  --text:  #ffffff;
  --muted: #c0d0ff;
  --dim:   #8090d8;

  --r: 13px;
  --r-sm: 8px;
}

html { overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* overflow-x: clip does not create a scroll container, so position:fixed works
   correctly on iOS Safari (unlike overflow-x: hidden which breaks it) */
@supports (overflow: clip) { html { overflow-x: clip; } }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh; /* iOS 15.4+: tracks visual viewport, equals visualViewport.height */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* suppress iOS tap-and-hold link preview */
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* Prevent iOS double-tap zoom on all interactive elements */
button, input, a, [role="button"] { touch-action: manipulation; }

/* ── Header ─────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 32px;
  background: linear-gradient(135deg, #4a3d8f 0%, var(--bg-header) 50%, #8070c8 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,.60), 0 1px 0 rgba(255,255,255,.15);
}

.logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -.5px;
  color: #ffff00;
  text-decoration: none;
  background: #000;
  padding: 2px 12px 4px;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #fff, 0 0 14px rgba(255,255,0,.35);
  user-select: none;
  font-family: 'Courier New', 'Consolas', monospace;
}
.logo em { color: #ff0000; font-style: normal; }

.hdiv { width: 1px; height: 18px; background: var(--border); }

.breadcrumb-sep { font-size: 20px; color: var(--text); line-height: 1; }

.home-btn {
  margin-left: auto;
  display: flex; align-items: center;
  font-size: 14px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  background: #000;
  color: #fff; text-decoration: none;
  padding: 6px 14px;
  border-radius: 100px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.50);
  transition: box-shadow .15s;
  flex-shrink: 0;
}
.home-btn:hover {
  box-shadow: 0 0 0 2px rgba(255,255,255,1);
}

.hsub { font-size: 15px; color: var(--text); }

/* ── Scrollbars ──────────────────────────────── */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) rgba(255,255,255,.08); }
/* WebKit / Chromium */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.08); border-radius: 99px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.6); }
::-webkit-scrollbar-corner { background: transparent; }

/* ── Main layout ─────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 48px;
}

h1 { font-size: 24px; font-weight: 700; margin-bottom: 16px; }

.intro {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 32px;
}
.intro strong { color: var(--text); }

/* ── Controls ─────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #000000;
  border: none;
  box-shadow: 0 0 0 1.5px var(--border);
  border-radius: 100px;
  padding: 7px 14px;
  transform: translateZ(0);
}

.chip-m { box-shadow: 0 0 0 1.5px rgba(255,255,0,.50); }
.chip-e { box-shadow: 0 0 0 1.5px rgba(0,255,0,.45); }

.chip-lbl  { font-size: 15px; font-weight: 500; }
.chip-lbl-m { color: var(--ml); }
.chip-lbl-e { color: var(--exl); }
.chip-lbl-u { color: var(--muted); }

.step {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.70);
  background: #000;
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  transition: background .12s;
}
.step:hover  { background: #222; }
.step:active { background: #333; }
.chip-m .step { box-shadow: 0 0 0 2px rgba(255,255,0,.50); }
.chip-e .step { box-shadow: 0 0 0 2px rgba(0,255,0,.45); }

.step-val {
  font-size: 19px; font-weight: 700;
  min-width: 24px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.reset-btn {
  background: none; border: none; padding: 0;
  color: var(--muted); font-size: 15px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  transition: color .12s;
}
.reset-btn:hover { color: var(--text); }

/* ── Cards ─────────────────────────────────────── */
.card {
  background: linear-gradient(135deg, #2e2468 0%, var(--surface2) 50%, #4a3d8f 100%);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}

.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}

.badge {
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 100px;
}
.badge-m { background: #000000; color: var(--ml); box-shadow: 0 0 0 2px var(--ml), 0 0 8px rgba(255,255,0,.45); }
.badge-e { background: #000000; color: var(--exl); box-shadow: 0 0 0 2px var(--exl), 0 0 8px rgba(0,255,0,.40); }
.badge-r { background: #000000; color: #ffffff; box-shadow: 0 0 0 2px rgba(255,255,255,.70), 0 0 8px rgba(255,255,255,.25); }
.badge-o { background: #000000; color: #ff8c00; box-shadow: 0 0 0 2px #ff8c00, 0 0 8px rgba(255,140,0,.45); }
.negate-btn {
  background: transparent;
  color: var(--ml);
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: color .12s;
}
.negate-btn:hover { color: #fff6a8; }
.negate-btn:active { color: #d7c800; }
.negate-steps {
  margin-top: 12px;
  padding-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
}
.negate-step {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Consolas', monospace;
  font-size: 19px;
  flex-wrap: wrap;
  justify-content: flex-start;
  text-align: left;
}
.ns-lbl { color: var(--muted); width: 100px; text-align: right; font-size: 17px; flex-shrink: 0; }
.ns-bits {
  color: var(--muted);
  background: var(--bg);
  border-radius: 5px;
  padding: 5px 8px;
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(255,255,255,.16);
}
.ns-eq { color: var(--muted); }
.ns-val { color: var(--ml); }
.ns-note { color: var(--muted); font-size: 17px; }
.ns-tick { color: #39ff7a; }
.ns-warn { color: #ff5555; font-size: 17px; }

.card-sub { font-size: 14px; color: var(--muted); }

/* ── Bit grid ─────────────────────────────────── */
.grid-wrap { overflow-x: auto; max-width: 100%; display: flex; justify-content: center; }

.labelled-grid-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.labelled-grid-row .row-badge {
  position: static;
  margin-top: 0;
  align-self: flex-start;
}
.labelled-grid-row .grid-wrap { width: 100%; }
.labelled-grid-row .row-main { width: 100%; text-align: center; }

.result-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.result-badge-row .norm { margin-top: 0; }

.bit-grid {
  display: inline-flex;
  gap: 5px;
  align-items: flex-start;
  padding-bottom: 4px;
}

.bit-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; flex-shrink: 0;
  width: var(--box-size, 56px);
}

.bit-wt {
  font-size: var(--wt-fs, 17px); color: var(--text);
  font-family: 'Consolas', monospace;
  min-height: 20px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; white-space: nowrap;
}
.bit-wt sup {
  font-size: 12px;
  vertical-align: top;
  line-height: 0;
  position: relative;
  top: -6px;
}

.bit-box {
  width: var(--box-size, 56px); height: var(--box-size, 56px);
  border-radius: var(--r-sm);
  border: 2px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--box-fs, 26px); font-weight: 700;
  font-family: 'Consolas', 'Courier New', monospace;
  cursor: pointer;
  user-select: none;
  transition: transform .08s ease, border-color .08s, background .08s, color .08s;
}
.bit-box:hover  { transform: scale(1.09); }
.bit-box:active { transform: scale(0.95); }
.bit-box:focus-visible {
  outline: 2px solid var(--ml);
  outline-offset: 2px;
}

/* mantissa sign — red border, white digit */
.ms0, .ms1 { border-color: #ff0000; background: #000000; color: #ffffff; }
/* mantissa regular — yellow border, white digit */
.mb0, .mb1 { border-color: #ffff00; background: #000000; color: #ffffff; }
/* exponent sign — red border, white digit */
.es0, .es1 { border-color: #ff0000; background: #000000; color: #ffffff; }
/* exponent regular — green border, white digit */
.eb0, .eb1 { border-color: #00ff00; background: #000000; color: #ffffff; }

.bit-idx {
  font-size: 9px; color: var(--dim);
  font-family: monospace;
}

/* ── Result card ──────────────────────────────── */
.result-card {
  background: linear-gradient(135deg, #2e2468 0%, var(--surface2) 50%, #4a3d8f 100%);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  margin-top: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}

.res-lbl {
  font-size: 13px; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--muted);
  font-weight: 600; margin-bottom: 8px;
}

.res-big {
  font-size: 62px; font-weight: 800;
  font-family: 'Consolas', monospace;
  line-height: 1; color: var(--ml);
  margin-bottom: 10px;
  letter-spacing: -1px;
  word-break: break-all;
  text-align: center;
}

.res-block {
  background: transparent;
  border-radius: var(--r-sm);
  padding: 0;
  margin-bottom: 0;
}
.card .res-block { margin-bottom: 0; }

.res-eq {
  font-size: 32px; color: var(--muted);
  font-family: 'Consolas', monospace;
  margin-bottom: 0;
  text-align: center;
}
.res-eq-row {
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.norm-area {
  position: static;
  transform: none;
}
.res-eq .vm { color: var(--ml); }
.res-eq .ve { color: var(--exl); }

/* breakdown */
.bk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 500px) { .bk-grid { grid-template-columns: 1fr; } }

@media (max-width: 680px) {
  main { padding: 24px 12px 60px; }
  .home-btn { font-size: 14px; padding: 4px 10px; letter-spacing: 1px; }
}

.bk-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 16px;
}
.bk-lbl {
  font-size: 12px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--dim);
  font-weight: 600; margin-bottom: 6px;
}
.bk-val {
  font-size: 24px; font-weight: 700;
  font-family: 'Consolas', monospace;
  margin-bottom: 5px;
}
.bk-val-m { color: var(--ml); }
.bk-val-e { color: var(--exl); }
.bk-formula {
  font-size: 14px; color: var(--muted);
  font-family: 'Consolas', monospace;
  line-height: 1.65;
}

/* normalized badge */
.norm {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 18px; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 100px;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.norm-y { background: #000000; color: #00ff00; box-shadow: 0 0 0 2px rgba(255,255,255,.70); }
.norm-n { background: #000000; color: #ff4444; box-shadow: 0 0 0 2px rgba(255,255,255,.70); }
.norm-z { background: #000000; color: #c0d0ff; box-shadow: 0 0 0 2px rgba(255,255,255,.70); }

/* ── Mode tabs ───────────────────────────────── */
.mode-tabs {
  display: flex;
  margin-bottom: 28px;
  border-bottom: 2px solid rgba(255,255,255,.15);
}
.mode-tab {
  padding: 10px 26px;
  font-size: 14px; font-weight: 700;
  background: none; border: none;
  border-bottom: 3px solid transparent;
  color: var(--dim); cursor: pointer;
  margin-bottom: -2px;
  letter-spacing: .5px;
  transition: color .15s, border-color .15s;
}
.mode-tab:hover:not(.active) { color: var(--text); }
.mode-tab.active { color: var(--ml); border-bottom-color: var(--ml); }

/* ── Quiz layout ─────────────────────────────── */
.quiz-topbar {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px;
}
.qtype-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qtype-btn {
  padding: 6px 16px;
  font-size: 14px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 100px;
  background: rgba(255,255,255,.04);
  color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.qtype-btn:hover { background: rgba(255,255,255,.09); color: var(--text); }
.qt-short { display: none; }
@media (max-width: 540px) {
  .qt-long  { display: none; }
  .qt-short { display: inline; }
}

.qtype-btn.active {
  background: rgba(232,232,0,.13);
  border-color: rgba(232,232,0,.60);
  color: var(--ml);
  box-shadow: 0 0 8px rgba(255,255,0,.30);
}
.quiz-score-area { display: flex; align-items: center; gap: 14px; }
.quiz-score-txt { font-size: 17px; font-weight: 700; font-family: 'Consolas', monospace; }
.quiz-q-card { margin-bottom: 10px; }
.quiz-q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; justify-content: space-between; }
.quiz-q-num {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px; color: #fff; font-weight: 700;
  background: #000;
  padding: 3px 10px; border-radius: 100px;
  box-shadow: 0 0 0 2px #fff;
}
.quiz-q-text { font-size: 22px; color: var(--text); line-height: 1.6; margin-bottom: 4px; }
.quiz-denary-target {
  font-size: 66px; font-weight: 800;
  font-family: 'Consolas', monospace;
  color: var(--ml); line-height: 1;
  margin: 12px 0 8px;
  letter-spacing: -1px; word-break: break-all;
  text-align: center;
}
.quiz-format-hint {
  font-size: 14px; color: var(--dim); margin-bottom: 0;
  font-family: 'Consolas', monospace;
}
.q-answer-lbl {
  display: inline-block;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px; color: #fff;
  font-weight: 700; margin-bottom: 12px;
  background: #000;
  padding: 3px 10px; border-radius: 100px;
  box-shadow: 0 0 0 2px #fff;
}
.q-denary-input {
  display: block; width: 100%;
  background: #000;
  border: 2px solid rgba(255,255,255,.20);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 34px; font-weight: 700;
  font-family: 'Consolas', monospace;
  padding: 12px 16px;
  outline: none;
  transition: border-color .15s;
}
.q-denary-input:focus { border-color: var(--ml); }
.q-denary-input:disabled { opacity: .55; }
.bit-box.static { cursor: default; pointer-events: none; }
.bit-box.static:hover { transform: none; }
.q-feedback {
  padding: 14px 18px;
  border-radius: var(--r-sm);
  font-size: 13px; line-height: 1.75;
  font-family: 'Consolas', monospace;
  margin-top: 12px;
}
.q-feedback-correct {
  background: rgba(0,255,0,.08); border: 1px solid rgba(0,255,0,.40); color: #00ff00;
}
.q-feedback-wrong {
  background: rgba(255,0,0,.08); border: 1px solid rgba(255,0,0,.40); color: #ff5555;
}
.quiz-actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.btn {
  padding: 9px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface2);
  color: var(--text); font-size: 15px; font-weight: 700;
  cursor: pointer; letter-spacing: .3px;
  transition: background .12s;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: 5px 14px; font-size: 14px; }
.btn-submit {
  background: rgba(232,232,0,.13);
  border-color: rgba(232,232,0,.50); color: var(--ml);
  box-shadow: 0 0 10px rgba(255,255,0,.20);
}
.btn-submit:hover { background: rgba(232,232,0,.22); box-shadow: 0 0 14px rgba(255,255,0,.35); }
.btn-submit:disabled { opacity: .4; cursor: default; }
.btn-submit:disabled:hover { background: rgba(232,232,0,.13); }
.btn-next {
  background: rgba(0,204,0,.10);
  border-color: rgba(0,204,0,.40); color: var(--exl);
  box-shadow: 0 0 10px rgba(0,255,0,.15);
}
.btn-next:hover { background: rgba(0,204,0,.20); box-shadow: 0 0 14px rgba(0,255,0,.28); }

/* ── Feedback modal ────────────────────────────── */
/* Native <dialog> via showModal() — uses browser top layer, no fixed
   positioning or z-index needed. ::backdrop is the dimmed overlay. */
/* Lock background scroll while the dialog is open. :has() is supported
   iOS Safari 16.4+. overflow:hidden on top-layer elements does not
   interfere with the dialog's own internal scroll. */
html.modal-open, body.modal-open,
html:has(#q-modal[open]),
html:has(#bq-modal[open]),
html:has(#save-dialog[open]),
body:has(#q-modal[open]),
body:has(#bq-modal[open]),
body:has(#save-dialog[open]) { overflow: hidden; }
#q-modal, #bq-modal, #save-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
}
/* Only style layout when open — display:flex here would override the
   browser's display:none for the closed state */
#q-modal[open], #bq-modal[open], #save-dialog[open] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 24px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
#q-modal::backdrop, #bq-modal::backdrop, #save-dialog::backdrop {
  background: rgba(0,0,0,.72);
}
.modal {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px 28px 22px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-feedback {
  font-size: 15px; line-height: 1.75;
  font-family: 'Consolas', monospace;
  margin-bottom: 22px;
}
.modal-feedback-correct { color: #00ff00; }
.modal-feedback-wrong   { color: #fff; }
.modal-feedback-wrong .fb-wrong { color: #ff5555; }
.modal-footer {
  display: flex; justify-content: flex-end;
}

/* ── Error inputs (inexact questions) ────────── */
.err-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px;
}
@media (max-width: 500px) { .err-grid { grid-template-columns: 1fr; } }
.q-err-notice {
  display: none;
}
.q-err-lbl {
  display: inline-block;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px; color: #fff; font-weight: 700; margin-bottom: 10px;
  background: #000;
  padding: 3px 10px; border-radius: 100px;
  box-shadow: 0 0 0 2px #fff;
}
.q-err-input { font-size: 26px; }

/* ── Site footer ─────────────────────────────── */
.site-credit {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: nowrap;
  margin: 40px 0 0; padding-top: 20px;
  border-top: 2px solid rgba(255,255,255,.15);
  color: var(--text); font-size: 16px;
  font-family: system-ui, -apple-system, sans-serif;
  text-align: center;
}
@media (max-width: 680px) {
  .site-credit { flex-direction: column; gap: 4px; }
}
.site-credit a { color: var(--text); text-decoration: underline; }
.site-credit a:hover { color: var(--ml); }

/* ══════════════════════════════════════════════════════
   HOME PAGE — Topic picker
══════════════════════════════════════════════════════ */
.home-section { margin-bottom: 44px; }

.home-section-lbl {
  font-size: 13px; text-transform: uppercase;
  letter-spacing: 2px; color: var(--dim);
  font-weight: 700; margin-bottom: 14px;
}

.home-intro { margin-bottom: 36px; }
.home-intro-title { font-size: 38px; font-weight: 900; color: var(--text); margin: 0 0 10px; line-height: 1.1; }
.home-intro-sub { font-size: 20px; color: var(--text); margin: 0; line-height: 1.6; }

/* ── Worksheet generator banner ─────────────────── */
.ws-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #31206f 0%, #45308f 50%, #5b43aa 100%);
  box-shadow: 0 0 0 1px var(--border), 0 4px 16px rgba(0,0,0,.40);
  border-radius: var(--r);
  padding: 18px 24px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 12px;
  transition: background .15s, transform .12s, box-shadow .12s;
}
.ws-banner:hover {
  background: linear-gradient(135deg, #3a2780 0%, #523aa1 50%, #6a50bc 100%);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(0,0,0,.55);
}
.ws-banner-text { flex: 1; min-width: 0; }
.ws-banner-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.ws-banner-desc {
  font-size: 13px;
  color: rgba(255,255,255,.75);
  line-height: 1.5;
}
.ws-banner-cta {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.topic-card {
  display: block;
  position: relative;
  background: linear-gradient(135deg, #2e2468 0%, var(--surface2) 50%, #4a3d8f 100%);
  box-shadow: 0 0 0 1px var(--border), 0 4px 16px rgba(0,0,0,.40);
  border-radius: var(--r);
  padding: 20px 20px 18px;
  text-decoration: none;
  color: var(--text);
  transition: background .15s, transform .12s, box-shadow .12s;
}
.topic-card:not(.topic-card-soon):hover {
  background: linear-gradient(135deg, #3a2e80 0%, #4a3a9a 50%, #5a4da8 100%);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(0,0,0,.55);
}
.topic-card-soon { opacity: .42; cursor: default; }

.topic-status {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-bottom: 10px; display: block;
}
.topic-status-ready { color: var(--ml); }
.topic-status-soon  { color: var(--dim); }

.topic-title {
  font-size: 20px; font-weight: 700;
  margin-bottom: 7px; line-height: 1.3;
}
.topic-desc {
  font-size: 13px; color: var(--muted);
  line-height: 1.6;
}

/* ── Level chips on topic cards ─────────────────── */
.level-chips {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  min-height: 20px;
}
.level-chip {
  font-size: 9px; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 100px;
  line-height: 1.6;
}
.level-chip-gcse {
  background: #000;
  color: var(--ml);
  box-shadow: 0 0 0 1.5px var(--ml);
}
.level-chip-a {
  background: #000;
  color: var(--exl);
  box-shadow: 0 0 0 1.5px var(--exl);
  margin-left: auto;
}
