﻿/* =========================================================================
   ActuariesHub - actuarial exam study workspace
   Aesthetic: modern, operational. Slate surfaces, indigo actions, cool shadows.
   ========================================================================= */

:root {
  /* "ATLAS" — cool porcelain ground, crisp white cards, deep petrol action,
     brass signature spark. Premium, calm, focus-first. Token names are
     unchanged so the whole app re-skins from here; brass (--accent) is kept
     to decorative sparks, petrol (--primary) carries actions + emphasis text. */
  --bg:             #eceff0;  /* app background, cool porcelain */
  --bg-deep:        #e3e8e8;  /* gradient endpoint for ambient depth */
  --surface:        #ffffff;  /* cards, panels */
  --surface-raised: #ffffff;  /* modals/popovers (use shadow for elevation) */
  --surface-sunken: #eff3f2;  /* inset areas, code blocks, progress tracks */

  /* Text — deep cool petrol-ink */
  --text-strong: #0e1c1d;  /* headings, key text */
  --text:        #34454a;  /* body */
  --text-muted:  #65767a;  /* secondary, captions */
  --text-faint:  #98a6a8;  /* placeholders, disabled hints */

  /* Borders — hairlines */
  --border-subtle: #e2e8e7;
  --border-strong: #ccd6d4;

  /* Brand / actions — deep petrol action, deeper on hover. */
  --primary:       #0e5358;  /* petrol: main action + active state */
  --primary-hover: #0a4348;  /* deeper petrol on hover */
  --primary-weak:  #dcefee;  /* tint for selected/active backgrounds */
  --primary-grad:  linear-gradient(180deg, #13666c 0%, #0e5358 100%);
  --primary-grad-hover: linear-gradient(180deg, #157278 0%, #0c4a4f 100%);
  --on-primary:    #f4fbfa;

  --accent-sky:    #5bb7bd;  /* light petrol for highlights/illustration */

  --secondary:        #3d5a64;  /* slate-teal: nav / exam context (distinct from petrol) */
  --secondary-hover:  #2f4750;
  --secondary-weak:   #e4ecee;

  /* Status (use per the colour-use rules below) */
  --info:        #1f6f96;  --info-weak:    #e0eef6;
  --success:     #2c8a5b;  --success-hover:#236f49;  --success-weak: #e1f3ea;
  --warning:     #b9791a;  --warning-weak: #f7ecd6;
  --danger:      #bd4631;  --danger-hover: #9c3826;  --danger-weak:  #f8e6e1;

  /* Signature accent — brass. Used sparingly: focus ring, active marks, sparks. */
  --accent:        #bd8a3c;
  --accent-hover:  #a8762c;
  --accent-weak:   #f6ecd6;
  --accent-line:   #cf9c49;

  /* Focus — the brass ring is the signature focus state */
  --focus:      #bd8a3c;
  --focus-ring: 0 0 0 3px rgba(189, 138, 60, 0.34);

  /* Readiness chart colours (5 weighted components + track) */
  --chart-1: #0e5358;  /* coverage  */
  --chart-2: #bd8a3c;  /* recall    */
  --chart-3: #2c8a5b;  /* practice  */
  --chart-4: #1f6f96;  /* exam-style*/
  --chart-5: #6d5fb0;  /* recency   */
  --chart-track: #eaf0ef;

  /* Radius — crisp, precise; pill for chips/switches */
  --radius:      11px;
  --radius-sm:   8px;
  --radius-lg:   18px;   /* large containers / modals only */
  --radius-pill: 999px;

  /* Shadows: cool teal-tinted, layered for genuine depth */
  --shadow-sm: 0 1px 2px rgba(11, 40, 42, 0.06), 0 1px 1px rgba(11, 40, 42, 0.04);
  --shadow-md: 0 8px 22px -10px rgba(11, 40, 42, 0.16), 0 2px 6px -2px rgba(11, 40, 42, 0.08);
  --shadow-lg: 0 28px 56px -20px rgba(11, 40, 42, 0.26), 0 10px 22px -12px rgba(11, 40, 42, 0.14);

  /* Spacing scale */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-8: 48px;

  /* Type — Bricolage Grotesque (display) / Hanken Grotesk (UI) / JetBrains Mono (data). */
  --font-display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --maxw: 1180px;

  /* ---- Backward-compatible aliases: OLD name -> new token ---- */
  --paper:       var(--bg);
  --paper-2:     var(--surface-sunken);
  --card:        var(--surface);
  --ink:         var(--text-strong);
  --ink-soft:    var(--text);
  --ink-faint:   var(--text-muted);
  --line:        var(--border-subtle);
  --line-strong: var(--border-strong);
  --ochre:       var(--primary);
  --ochre-deep:  var(--primary-hover);
  --sage:        var(--success);
  --sage-deep:   var(--success-hover);
  --rust:        var(--danger);
  --accent-deep: var(--primary);
  --serif:       var(--font-display);
  --body:        var(--font-sans);
  --mono:        var(--font-mono);
}

* {
  box-sizing: border-box;
}

/* =========================================================================
   RESPONSIVE BREAKPOINT SCALE
   Media queries can't read CSS custom properties and this app has no build
   step, so breakpoints stay raw px — but they snap to ONE canonical scale.
   Use these five values and no others; pick the nearest when adding a query:
     860px  structural: nav -> sheet, workspace single-column, library drawer
     720px  tablet: PDF side panel, body-exam + paper layouts
     640px  large phone: study header + action-cluster stacking
     560px  phone: padding/stacking tweaks, 16px base font
     380px  small phone: final tightening
   ========================================================================= */

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

body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  /* Ambient depth: a fine grain over two soft tints (petrol + brass) on a
     porcelain-gradient ground. Grain tiles; glows stay put while content
     scrolls. Layered as backgrounds (not a ::before) so content is never
     covered and no stacking context is introduced. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"),
    radial-gradient(820px 540px at 8% -10%, rgba(20, 120, 128, 0.10), transparent 60%),
    radial-gradient(760px 520px at 102% 4%, rgba(189, 138, 60, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 160px 160px, auto, auto, auto;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.002em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Consistent, premium heading rhythm: tight tracking, strong weight. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-strong);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

/* ---------------- Brand ---------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-mark {
  height: 1.9rem;
  width: auto;
  display: block;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}
/* Brand acts as a home link in the persistent nav. */
.brand-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-strong);
}
/* Active destination in the persistent top nav. */
.btn-ghost.is-current {
  color: var(--primary);
  background: var(--primary-weak);
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.15rem;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, color 0.18s ease,
    border-color 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  color: var(--text);
  background: transparent;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.25);
}
.btn-primary {
  background: var(--primary-grad);
  color: var(--on-primary);
  border-color: rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18),
    0 6px 16px -8px rgba(30, 58, 138, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-grad-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2),
    0 12px 24px -10px rgba(29, 78, 216, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}
.btn-outline {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary-hover);
  color: var(--primary-hover);
  background: var(--primary-weak);
  transform: translateY(-1px);
}
.btn-ghost {
  color: var(--text);
  padding: 0.45rem 0.7rem;
}
.btn-ghost:hover {
  color: var(--text-strong);
  background: var(--surface-sunken);
}
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
  cursor: pointer;
}
.btn-link:hover {
  color: var(--primary-hover);
}
.btn-block {
  width: 100%;
}

/* ---------------- Fields ---------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.field > span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}
input,
textarea,
select {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}
input:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled) {
  border-color: var(--border-strong);
  background: #fcfdff;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-hover);
  box-shadow: var(--focus-ring);
}
/* Style native selects to match inputs, with a custom chevron. */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 2.25rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
.hint {
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ---------------- Notices / toasts ---------------- */
.notice {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
}
.notice.is-error {
  border-color: var(--danger);
  background: var(--danger-weak);
  color: var(--danger);
}
.notice.is-success {
  border-color: var(--success);
  background: var(--success-weak);
  color: var(--success-hover);
}

.toasts {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.toast {
  background: var(--text-strong);
  color: var(--on-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  max-width: 320px;
  animation: toast-in 0.25s ease;
}
.toast.is-error {
  background: var(--danger);
}
.toast.is-success {
  background: var(--success);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------------- Spinner ---------------- */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================================
   AUTH
   ========================================================================= */
.auth-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth-aside {
  position: relative;
  padding: clamp(2rem, 5vw, 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  border-right: 1px solid var(--border-subtle);
  /* A richer, deeper wash behind the value proposition. */
  background:
    radial-gradient(700px 480px at 0% 100%, rgba(56, 189, 248, 0.12), transparent 60%),
    radial-gradient(620px 420px at 20% 0%, rgba(30, 58, 138, 0.10), transparent 60%),
    linear-gradient(160deg, #f7fafe 0%, #eef3fb 100%);
  overflow: hidden;
}
.auth-headline {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: clamp(2.1rem, 3.8vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
  color: var(--text-strong);
}
.auth-headline em {
  font-style: normal;
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-hover) 55%, var(--accent-sky) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--primary);
}
.auth-blurb {
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--text);
  max-width: 38ch;
  margin: 0;
}
.auth-points {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.auth-points li {
  position: relative;
  padding-left: 1.6rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}
.auth-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-family: var(--font-sans);
  font-weight: 600;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem;
}
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--paper-2);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}
.tab.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   VERIFY
   ========================================================================= */
.verify-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.verify-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  text-align: center;
}
.verify-card .brand {
  margin-bottom: 1.5rem;
}
.verify-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  font-size: 1.05rem;
}
.verify-state .spinner {
  width: 28px;
  height: 28px;
}
.verify-icon {
  font-family: var(--font-sans);
  font-size: 2.5rem;
  line-height: 1;
}
.verify-icon.ok {
  color: var(--success-hover);
}
.verify-icon.bad {
  color: var(--danger);
}
.verify-continue,
#verify-continue {
  margin-top: 1.5rem;
}

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78));
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 6px 20px -16px rgba(15, 23, 42, 0.4);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.user-email {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.4rem;
}

/* ---- Hamburger toggle (mobile only) ---- */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: var(--text-strong);
}
.nav-toggle-box {
  position: relative;
  width: 20px;
  height: 14px;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.22s ease, opacity 0.18s ease, top 0.22s ease;
}
.nav-toggle-bar {
  top: 6px;
}
.nav-toggle-bar::before {
  top: -6px;
}
.nav-toggle-bar::after {
  top: 6px;
}
/* X when open */
.topbar.is-open .nav-toggle-bar {
  background: transparent;
}
.topbar.is-open .nav-toggle-bar::before {
  top: 0;
  transform: rotate(45deg);
}
.topbar.is-open .nav-toggle-bar::after {
  top: 0;
  transform: rotate(-45deg);
}

/* ---- Mobile / tablet-portrait nav: collapse into a dropdown sheet ---- */
@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }
  .topbar-right {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: clamp(0.75rem, 4vw, 2rem);
    left: clamp(0.75rem, 4vw, 2rem);
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    /* collapsed */
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 40;
  }
  .topbar.is-open .topbar-right {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
  .topbar-right .btn-ghost {
    width: 100%;
    justify-content: flex-start;
    padding: 0.7rem 0.85rem;
    font-size: 1rem;
    border-radius: var(--radius-sm);
  }
  .topbar-right .user-email {
    order: -1;
    display: block;
    margin: 0.15rem 0.85rem 0.35rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8rem;
  }
  .topbar-right #topbar-avatar {
    display: none;
  }
}
.banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  background: var(--warning-weak);
  border-bottom: 1px solid var(--warning);
  padding: 0.6rem 1rem;
  font-size: 0.92rem;
  color: var(--warning);
}

.workspace {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.panel-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* ---- Upload / dropzone ---- */
.upload {
  margin-bottom: 1.25rem;
}
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 1.3rem 1rem;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: border-color 0.18s ease, background 0.18s ease;
  color: var(--ink-soft);
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--primary);
  background: var(--primary-weak);
}
.dropzone-icon {
  font-size: 1.6rem;
  color: var(--accent);
  line-height: 1;
}
.dropzone-text {
  font-size: 0.9rem;
}
.dropzone-text u {
  color: var(--accent-deep);
}
.dropzone-name {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  word-break: break-all;
}

/* ---- Document list ---- */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.doc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  background: var(--paper);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.doc-item:hover {
  border-color: var(--line-strong);
  transform: translateX(2px);
}
.doc-item.is-active {
  border-color: #bfe2e2;
  background: var(--primary-weak);
  /* Brass left rail marks the active document (inset = no layout shift). */
  box-shadow: inset 3px 0 0 var(--accent);
}
/* Left column (title + meta); min-width:0 lets the title ellipsis kick in. */
.doc-item-main {
  flex: 1 1 auto;
  min-width: 0;
}
.doc-item-title {
  font-weight: 500;
  font-size: 0.95rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Per-document rename / delete; muted until the row is hovered or focused. */
.doc-item-actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 0.1rem;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.doc-item:hover .doc-item-actions,
.doc-item:focus-within .doc-item-actions {
  opacity: 1;
}
.doc-item-act {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1;
  color: var(--text-muted);
}
.doc-item-act:hover {
  background: var(--surface-sunken);
  color: var(--text-strong);
}
.doc-item-act-danger:hover {
  color: var(--danger);
  background: var(--danger-weak);
}
.doc-rename-input {
  width: 100%;
  font-size: 0.95rem;
  padding: 0.3rem 0.5rem;
}
.doc-item-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}
.empty-note {
  font-size: 0.9rem;
  color: var(--ink-faint);
  font-style: italic;
}

/* ---- Study panel ---- */
.study-empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(2.5rem, 6vw, 4.5rem) 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.study-empty-mark {
  height: 3.5rem;
  width: auto;
  opacity: 0.55;
}
.study-empty h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  margin: 0;
}
.study-empty p {
  color: var(--ink-faint);
  margin: 0;
}

.study-active {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.study-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.study-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin: 0 0 0.2rem;
}
.study-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.7vw, 1.95rem);
  line-height: 1.12;
  margin: 0;
  overflow-wrap: anywhere;
}
.study-status {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-align: right;
  white-space: nowrap;
}
.subject-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--secondary-weak);
  color: var(--secondary-hover);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--success-weak);
  color: var(--success-hover);
  font-family: var(--font-sans);
  font-size: 0.78rem;
}
/* While a background processing run is in flight. */
.status-pill-working {
  background: var(--info-weak);
  color: var(--info);
}

.process-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.process-hint {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.paper-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

/* Official syllabus panel: the tagged paper's objective outline, openable from
   the paper row and visible alongside every study tab. */
.syllabus-panel {
  margin-top: 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
}
.syllabus-panel-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 0.6rem;
}
.syllabus-panel-bar .syllabus-panel-head,
.syllabus-panel-bar .syllabus-empty {
  margin: 0;
}
.syllabus-panel-head {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.6rem;
}
.syllabus-objectives {
  margin: 0;
  padding-left: 1.3rem;
  display: grid;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
  max-height: 16rem;
  overflow-y: auto;
}
.syllabus-panel-foot {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.syllabus-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.syllabus-panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
/* Examinable sub-objectives nested under each objective. */
.syllabus-subs {
  list-style: none;
  margin: 0.3rem 0 0.45rem;
  padding-left: 0.9rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.syllabus-sub-code {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-right: 0.25rem;
}

/* Grouped breakdowns: leaf rows under their objective heading. */
.obj-groups,
.coverage-groups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}
.obj-group-head,
.coverage-group-head {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  margin: 0 0 0.35rem;
}
.paper-label {
  font-size: 0.85rem;
  color: var(--ink-faint);
}
.paper-current {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.paper-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.4rem;
}
.paper-picker .input {
  width: auto;
  min-width: 12rem;
}
.doc-paper-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--secondary-hover);
}

/* Per-paper syllabus status + upload (Bodies -> examinations). */
.body-exam-syllabus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}
.syllabus-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
}
.syllabus-tag.is-approved {
  background: var(--success-weak);
  color: var(--success-hover);
}
.syllabus-tag.is-pending {
  background: var(--warning-weak);
  color: var(--warning);
}
.syllabus-tag.is-none {
  color: var(--ink-faint);
}

/* Admin: nav badge + modal tabs. */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}
.admin-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
}
.admin-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
}
.admin-tab.is-active {
  color: var(--secondary);
  border-bottom-color: var(--secondary);
}

.page-scope {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.page-scope-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.page-scope-input {
  width: min(18rem, 100%);
}
.page-scope-clear {
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
}
.page-scope-state {
  font-size: 0.85rem;
  color: var(--ink-faint);
}
.page-scope-state.is-invalid {
  color: var(--danger);
}

/* ---- Ask ---- */
.ask-input-wrap {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.ask-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.ask-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  padding: 0.4rem 0.5rem;
  font-size: 1.05rem;
  line-height: 1.5;
}
.ask-input:focus {
  outline: none;
  box-shadow: none;
}
.ask-input-wrap .btn {
  align-self: stretch;
}
.ask-hint {
  margin: 0.55rem 0 0;
  font-size: 0.86rem;
  font-style: italic;
  color: var(--ink-faint);
}

/* ---- Answer ---- */
.answer-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.answer-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.4rem 1.6rem;
  animation: rise 0.3s ease;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.answer-q {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 0.6rem;
}
.answer-body {
  font-size: 1.08rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--ink);
}
.answer-body.is-fallback {
  font-style: italic;
  color: var(--ink-soft);
}
.answer-sources {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line-strong);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--sage-deep);
}
.answer-sources .label {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 0.4rem;
}
.answer-loading {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink-soft);
  font-style: italic;
  padding: 0.5rem;
}

/* =========================================================================
   MODAL
   ========================================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  animation: rise 0.25s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.modal-head h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.modal-close:hover {
  color: var(--ink);
}
.modal-lede {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.25rem;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }
  .auth-aside {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 2rem;
  }
  .auth-points {
    display: none;
  }
  /* .workspace single-column is handled by the 860px study block below. */
}
@media (max-width: 560px) {
  body {
    font-size: 16px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .user-email {
    display: none;
  }
  .ask-input-wrap {
    flex-direction: column;
    align-items: stretch;
  }
}

[hidden] {
  display: none !important;
}

/* =========================================================================
   STUDY MODE SWITCH + FLASHCARDS
   ========================================================================= */
.mode-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.3rem;
  margin: 0.25rem 0 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}
.mode-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  padding: 0.45rem 1.05rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.mode-btn:hover {
  color: var(--text-strong);
  background: var(--surface-sunken);
}
.mode-btn.is-active {
  background: var(--primary);
  color: var(--on-primary);
}
/* The brass spark: a short underline marking the active study mode. */
.mode-btn.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.42rem;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.cards-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 2.1rem 0.55rem 0.75rem;
}
.select:focus-visible {
  outline: 2px solid var(--focus);
  box-shadow: var(--focus-ring);
}
.cards-hint {
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.cards-stage {
  margin-top: 0.5rem;
}
.card-progress {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-bottom: 0.6rem;
}
.flashcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem 1.75rem;
  min-height: 8rem;
}
.flashcard-q {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.flashcard-a {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.flashcard-a-body {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}
.flashcard-src {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--accent-deep);
}

.card-actions {
  margin-top: 1.1rem;
}
.rate-prompt {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.86rem;
  margin-bottom: 0.6rem;
}
.rate-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.rate-btn {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.7rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.rate-btn:hover:not(:disabled) {
  background: var(--paper-2);
}
.rate-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.rate-again:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}
.rate-easy:hover:not(:disabled) {
  border-color: var(--success);
  color: var(--success-hover);
}

.cards-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
}
.cards-empty-mark {
  font-family: var(--font-sans);
  font-size: 2.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.cards-empty-logo {
  display: block;
  height: 3rem;
  width: auto;
  opacity: 0.5;
  margin: 0 auto 0.6rem;
}
.cards-empty .muted {
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* =========================================================================
   LESSONS MODE (layered content + multiple-choice questions)
   ========================================================================= */

/* Progress rail across the top of a lesson session. */
.lesson-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
.lesson-progress-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.lesson-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Free navigation between lessons (jump around without finishing). */
.lesson-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.lesson-nav-arrow {
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.lesson-nav-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.lesson-nav-select {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
}

/* The lesson card - its layered content. */
.lesson {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(1.4rem, 4vw, 2.1rem);
  animation: rise 0.3s ease;
}
.lesson-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.lesson-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: clamp(1.4rem, 3.4vw, 1.9rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
}
.lesson-summary {
  font-size: 1.12rem;
  line-height: 1.72;
  color: var(--ink);
  white-space: pre-wrap;
}
/* Drop cap on the summary - a quiet flourish that signals "read me first". */
.lesson-summary p:first-of-type::first-letter {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 3.1rem;
  line-height: 0.8;
  float: left;
  margin: 0.35rem 0.5rem 0 0;
  color: var(--primary);
}

/* Expandable "go deeper" detail. */
.lesson-deeper {
  margin-top: 1.25rem;
  border-top: 1px dashed var(--line-strong);
  padding-top: 0.5rem;
}
.lesson-deeper > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--accent-deep);
  padding: 0.5rem 0;
  user-select: none;
}
.lesson-deeper > summary::-webkit-details-marker {
  display: none;
}
.lesson-deeper > summary::before {
  content: "›";
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}
.lesson-deeper[open] > summary::before {
  transform: rotate(90deg);
}
.lesson-detail {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  padding: 0.4rem 0 0.6rem;
  animation: rise 0.25s ease;
}

.lesson-begin {
  margin-top: 1.5rem;
}
/* Flow content steps: Back + Test myself on the left, the forward action pushed
   to the right. Wraps tidily on narrow screens. */
.lesson-begin.flow-step-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.flow-step-actions .flow-next {
  margin-left: auto;
}

/* Flow delivery (P18 phase 1): one-idea-per-screen lesson player. Reuses the
   .lesson / .mcq cards; these are just the few extras the stream view needs. */
.flow-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.flow-toggle-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.flow-toggle-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}
.flow-body {
  font-size: 1.12rem;
  line-height: 1.72;
  color: var(--ink);
}
.flow-hook-q {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0.4rem 0 0;
}
.flow-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* "Chat about this" - floating chat icon + slide-in contextual sidechat. */
.study-body {
  position: relative;
}
/* The "chat about this" trigger sits at the top-right of the study content and
   blends in -- a quiet icon button, not a floating circle. It opens the same
   slide-in panel. Hidden until there is something to chat about (see JS). */
.cabout-fab {
  /* Pinned to the viewport's top-right (just under the sticky top nav) so it's
     always reachable while reading a long section, not only at the top. */
  position: fixed;
  top: 4.75rem;
  right: 1.1rem;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--primary);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm, var(--shadow-md));
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.cabout-fab:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.cabout-fab.is-open {
  opacity: 0;
  pointer-events: none;
}
/* Docked chat: on the 2-column desktop layout, squeeze the app to the left so the
   drawer sits BESIDE the content instead of covering the forward button + header
   actions. Below 861px the panel is near full-width, so it stays a plain overlay
   (nothing useful to dock beside). The transition matches the drawer slide-in. */
body {
  transition: padding-right 0.22s ease;
}
@media (min-width: 861px) {
  body.cabout-docked {
    padding-right: min(420px, 92vw);
  }
}
.cabout-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 61;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--bg, var(--card));
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg, var(--shadow-md));
  animation: cabout-in 0.22s ease;
}
@keyframes cabout-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}
.cabout-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1.1rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.cabout-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
}
.cabout-ctx {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent-deep);
}
.cabout-scope {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}
.cabout-scope-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.cabout-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.cabout-empty {
  margin: auto 0;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-faint);
}
.cabout-msg {
  max-width: 92%;
}
.cabout-msg.is-user {
  align-self: flex-end;
}
.cabout-msg.is-bot {
  align-self: flex-start;
}
/* A quiet note when an answer was found by widening past the on-screen section. */
.cabout-widened {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-bottom: 0.25rem;
}
.cabout-bubble {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
}
.cabout-msg.is-user .cabout-bubble {
  background: var(--primary);
  color: #fff;
}
.cabout-msg.is-bot .cabout-bubble {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
}
.cabout-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem 0;
}
.cabout-chip {
  font-size: 0.76rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.cabout-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.cabout-input {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.7rem 1.1rem 0.3rem;
}
.cabout-input textarea {
  flex: 1;
  resize: none;
  max-height: 6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.92rem;
  background: var(--card);
  color: var(--ink);
}
.cabout-send {
  flex: 0 0 auto;
}
.cabout-clear {
  align-self: center;
  margin: 0 0 0.5rem;
  font-size: 0.76rem;
}
@media (max-width: 640px) {
  .cabout-panel {
    width: 100vw;
    top: auto;
    height: 82vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
  }
}

/* One question at a time, for single-pointed focus. */
.mcq {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(1.3rem, 4vw, 1.9rem);
  animation: rise 0.28s ease;
}
.mcq-count {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin: 0 0 0.6rem;
}
.mcq-stem {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(1.15rem, 3.2vw, 1.4rem);
  line-height: 1.4;
  margin: 0 0 1.25rem;
}
.mcq-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.mcq-option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 1.02rem;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  min-height: 52px; /* comfortable thumb target on mobile */
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.1s ease,
    box-shadow 0.16s ease;
}
.mcq-option:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.mcq-option:disabled {
  cursor: default;
}
.mcq-option .key {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  transition: inherit;
}
.mcq-option .opt-text {
  flex: 1;
}
.mcq-option .mark {
  flex: none;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.18s ease;
}
/* Graded states. */
.mcq-option.is-correct {
  border-color: var(--success);
  background: var(--success-weak);
  animation: pop 0.3s ease;
}
.mcq-option.is-correct .key {
  border-color: var(--success);
  background: var(--success);
  color: var(--on-primary);
}
.mcq-option.is-correct .mark {
  opacity: 1;
  color: var(--success-hover);
}
.mcq-option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-weak);
  animation: shake 0.34s ease;
}
.mcq-option.is-wrong .key {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-primary);
}
.mcq-option.is-wrong .mark {
  opacity: 1;
  color: var(--danger);
}
.mcq-option.is-dimmed {
  opacity: 0.55;
}

/* Feedback shown after answering. */
.mcq-feedback {
  margin-top: 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--paper-2);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  animation: rise 0.25s ease;
}
.mcq-feedback.is-correct {
  border-left-color: var(--success);
}
.mcq-feedback.is-wrong {
  border-left-color: var(--danger);
}
.mcq-feedback-head {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}
.mcq-feedback.is-correct .mcq-feedback-head {
  color: var(--success-hover);
}
.mcq-feedback.is-wrong .mcq-feedback-head {
  color: var(--danger);
}
.mcq-feedback-body {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.mcq-feedback-src {
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent-deep);
}
.mcq-next {
  margin-top: 1.3rem;
}
.mcq-requeue {
  margin: 0.9rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* End-of-lesson score reveal. */
.lesson-result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(2rem, 6vw, 3rem) 1.5rem;
  text-align: center;
  animation: rise 0.35s ease;
}
.result-ring {
  width: 132px;
  height: 132px;
  margin: 0 auto 1.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--card) 79%, transparent 80% 100%),
    conic-gradient(var(--accent) var(--pct, 0%), var(--line) 0);
  animation: ring-in 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.result-ring.pass {
  background:
    radial-gradient(closest-side, var(--card) 79%, transparent 80% 100%),
    conic-gradient(var(--sage) var(--pct, 0%), var(--line) 0);
}
.result-score {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 2.2rem;
  line-height: 1;
}
.result-score small {
  font-size: 1rem;
  color: var(--ink-faint);
}
.result-headline {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0 0 0.35rem;
}
.result-next {
  color: var(--ink-soft);
  font-size: 0.98rem;
  margin: 0 0 1.6rem;
}
.result-next strong {
  color: var(--accent-deep);
}
.result-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  30%,
  70% {
    transform: translateX(4px);
  }
  50% {
    transform: translateX(-5px);
  }
}
@keyframes ring-in {
  from {
    transform: scale(0.85) rotate(-12deg);
    opacity: 0;
  }
}

/* Respect users who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  .mcq-option.is-correct,
  .mcq-option.is-wrong,
  .result-ring {
    animation: none;
  }
  .lesson-progress-fill {
    transition: none;
  }
}

/* The three-way mode switch can wrap on narrow screens. */
.mode-switch {
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  .lesson-summary p:first-of-type::first-letter {
    font-size: 2.6rem;
  }
  .result-actions .btn {
    width: 100%;
  }
}

/* =========================================================================
   RICH CONTENT (markdown-lite + KaTeX) - structured for retention
   ========================================================================= */
.rich p {
  margin: 0 0 0.7rem;
  line-height: 1.7;
}
.rich p:last-child {
  margin-bottom: 0;
}
.rich ul {
  margin: 0.45rem 0 0.95rem;
  padding-left: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.rich ul:last-child {
  margin-bottom: 0;
}
.rich li {
  line-height: 1.55;
  padding-left: 0.2rem;
}
.rich li::marker {
  color: var(--accent);
  font-weight: 700;
}
.rich .md-h {
  font-family: var(--font-sans);
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--text-strong);
  margin: 1.1rem 0 0.45rem;
}
.rich .md-h:first-child {
  margin-top: 0;
}
.rich strong {
  font-weight: 600;
  color: var(--ink);
}
/* Key terms in bullets pop, so the eye lands on what to remember. */
.rich li strong {
  color: var(--ochre-deep);
}
.rich .katex {
  font-size: 1.04em;
}

/* "Rebuild from scratch" - quiet until hovered (it's destructive). */
.btn-rebuild {
  color: var(--ink-faint);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
}
.btn-rebuild:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-weak);
}

/* =========================================================================
   DRILLS MODE (applied scenario mini-cases)
   ========================================================================= */
.drill {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sage);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(1.4rem, 4vw, 2rem);
  animation: rise 0.3s ease;
}
.drill-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sage-deep);
  margin: 0 0 0.6rem;
  font-weight: 600;
}
.drill-scenario {
  font-family: var(--font-sans);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}
.drill-jot {
  width: 100%;
  margin-top: 1.2rem;
  resize: vertical;
  min-height: 5rem;
  line-height: 1.6;
}
.drill-jot-label {
  display: block;
  margin-top: 1.3rem;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 600;
}
.drill-model {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--line-strong);
  animation: rise 0.25s ease;
}
.drill-model-head {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage-deep);
  margin: 0 0 0.5rem;
}
.drill-model-body {
  font-size: 1.04rem;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.drill-src {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--accent-deep);
}

/* Processed-document indicator in the library list. */
.doc-item-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--sage);
  vertical-align: middle;
}

/* =========================================================================
   FOCUS SESSION - ADHD-friendly study scaffolding
   Short timed blocks, movement breaks, distraction-free mode, positive tally.
   ========================================================================= */
.focus-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1.4rem;
  padding: 0.7rem 1rem;
  /* A dark "instrument panel" — the one place the app goes dark, so the focus
     timer reads as a distinct, calming mode. */
  background: linear-gradient(180deg, #0e3a3e 0%, #0b2e31 100%);
  color: #dff1f0;
  border: 1px solid #0b2e31;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
/* ---- The focus bar runs on a dark ground: re-tune its children ---- */
.focus-bar .focus-time {
  color: #ffffff;
}
.focus-bar .focus-phase {
  color: var(--accent-line);
  border-color: rgba(255, 255, 255, 0.22);
}
.focus-bar .focus-phase.is-break {
  color: #cfe9ea;
  border-color: rgba(255, 255, 255, 0.32);
}
.focus-bar .focus-meta,
.focus-bar .focus-next,
.focus-bar .focus-tally {
  color: #a9cfcd;
}
.focus-bar .btn-outline {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: #eafaf8;
  box-shadow: none;
}
.focus-bar .btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  color: #ffffff;
}
.focus-bar .btn-ghost {
  color: #a9cfcd;
}
.focus-bar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.focus-bar .select {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #eafaf8;
}
.focus-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.focus-meta {
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.86rem;
}
.focus-phase {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--success-hover);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.focus-phase.is-break {
  color: var(--secondary-hover);
  border-color: var(--secondary);
}
.focus-time {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 3.6ch;
}
.focus-btn {
  padding: 0.4rem 1rem;
}
.focus-icon-btn {
  padding: 0.4rem 0.6rem;
  font-size: 1.05rem;
  line-height: 1;
}
.focus-length {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}
.focus-next {
  font-style: italic;
  color: var(--ink-faint);
}
.focus-next:empty {
  display: none;
}
.focus-tally {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--sage-deep);
}
.focus-tally:empty {
  display: none;
}
.focus-distraction {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}
.focus-distraction input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* Distraction-free: collapse the library and chrome so one task fills the view. */
body.is-distraction-free .library {
  display: none;
}
body.is-distraction-free .workspace {
  grid-template-columns: 1fr;
}
body.is-distraction-free .study {
  max-width: 760px;
  margin: 0 auto;
}

/* ---------------- Movement break overlay ---------------- */
.break-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(16, 24, 40, 0.55);
  backdrop-filter: blur(3px);
}
.break-overlay[hidden] {
  display: none;
}
.break-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 2.4rem 2rem;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.break-mark {
  font-size: 2.6rem;
  line-height: 1;
  animation: breath 3s ease-in-out infinite;
}
.break-card h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  margin: 0.8rem 0 0.4rem;
}
.break-tip {
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
}
.break-time {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--sage-deep);
  margin-bottom: 1.4rem;
}
.break-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}
@keyframes breath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .break-mark { animation: none; }
}

/* =========================================================================
   QUIZ MODE - weak-area report
   ========================================================================= */
.quiz-idle {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}
.quiz-idle .cards-empty-mark {
  font-family: var(--font-sans);
  font-size: 2.2rem;
  color: var(--primary);
}
.quiz-idle p {
  margin: 0.4rem 0;
}
.weak-areas {
  margin-top: 1.6rem;
  text-align: left;
}
.weak-head {
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 0.7rem;
}
.weak-empty {
  margin-top: 1.4rem;
  font-style: italic;
}
.weak-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.weak-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1.4fr) 2fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.weak-topic {
  font-weight: 500;
  font-size: 0.95rem;
}
.weak-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}
.weak-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--success);
}
.weak-row.is-weak .weak-bar-fill {
  background: var(--danger);
}
.weak-row.is-mid .weak-bar-fill {
  background: var(--warning);
}
.weak-row.is-strong .weak-bar-fill {
  background: var(--success);
}
.weak-score {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.weak-score small {
  color: var(--ink-faint);
}

/* Ask: hint + clear-answers row */
.ask-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ask-clear {
  flex: none;
  font-size: 0.85rem;
}

/* Question hint - hidden until requested, never the answer */
.mcq-hint {
  margin: 0.2rem 0 1rem;
}
.hint-toggle {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  color: var(--primary);
}
.hint-body {
  margin-top: 0.6rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--info-weak);
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Ask across multiple documents */
.ask-docs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.ask-docs:empty {
  display: none;
}
.ask-docs-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-right: 0.2rem;
}
.ask-doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.88rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.ask-doc-chip input {
  accent-color: var(--accent);
  cursor: pointer;
}
.ask-doc-chip:has(input:checked) {
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* =========================================================================
   EXAM-READINESS: written marking, timed mock, readiness + coverage
   ========================================================================= */

/* A small pill that marks AI feedback as provisional, never an exam grade. */
.formative-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warning);
  background: var(--warning-weak);
  border: 1px solid var(--warning);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.6rem;
}
/* Reproducible marking: the self-consistency passes agreed (higher trust). */
.formative-badge.is-reliable {
  color: var(--success);
  background: var(--success-weak);
  border-color: var(--success);
}
/* Deterministic (server-checked) marking, in contrast to formative AI marking. */
.exact-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--success);
  background: var(--success-weak, var(--surface-sunken));
  border: 1px solid var(--success);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.6rem;
  cursor: help;
}

/* ---- Calc mode (numeric parts) ---- */
.calc-parts {
  list-style: decimal inside;
  margin: 0.8rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.calc-part {
  border: 1px solid var(--border, #dde3ec);
  border-radius: var(--radius-lg);
  padding: 0.7rem 0.85rem;
}
.calc-part-text {
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
}
.calc-part-input {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.calc-answer {
  flex: 0 1 220px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
}
.calc-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.calc-marks {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.calc-working {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ---- Written mode ---- */
.written-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}
.written-question {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}
.written-answer {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  resize: vertical;
  min-height: 9rem;
}
.written-answer:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  box-shadow: var(--focus-ring);
}
.written-result {
  position: relative;
  text-align: center;
}
.result-feedback {
  color: var(--ink-soft);
  margin: 0.8rem auto 0.4rem;
  max-width: 38rem;
}
.mark-points-head {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-strong);
  margin: 1.4rem 0 0.6rem;
  text-align: left;
}
.mark-points {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  text-align: left;
}
.mark-point {
  display: flex;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.mark-point-icon {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}
.mark-point.is-awarded .mark-point-icon {
  color: var(--success-hover);
  background: var(--success-weak);
}
.mark-point.is-missed .mark-point-icon {
  color: var(--warning);
  background: var(--warning-weak);
}
.mark-point-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.mark-point-meta {
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.mark-point-evidence {
  font-size: 0.82rem;
  color: var(--ink-faint);
  font-style: italic;
}
/* The authored rubric for a point, revealed after marking (what earns it / the
   common miss). Set off from the verdict so it reads as study guidance. */
.mark-point-rubric {
  display: block;
  margin-top: 0.3rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.mark-point-rubric em {
  font-style: normal;
  font-weight: 600;
  color: var(--ink-faint);
}
.model-answer {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem;
  margin-bottom: 1rem;
}
.model-answer summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--primary);
  padding: 0.4rem 0;
}
.model-answer-body {
  padding: 0.4rem 0 0.8rem;
}

/* ---- Mock mode ---- */
.mock-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.mock-clock {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
}
.mock-clock.is-low {
  color: var(--warning);
}
.mock-bar-meta {
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.mock-q {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}
.mock-q-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}
.mock-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.mock-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  padding: 0.7rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.mock-option:hover {
  border-color: var(--primary);
}
.mock-option.is-chosen {
  border-color: var(--primary);
  background: var(--primary-weak);
}
.mock-option .key {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.mock-breakdown {
  list-style: none;
  margin: 1rem auto;
  padding: 0;
  max-width: 24rem;
  text-align: left;
}
.mock-breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

/* ---- Readiness mode ---- */
.readiness {
  position: relative;
}
.readiness-top {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.readiness-summary {
  flex: 1 1 16rem;
}
.readiness-confidence {
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-transform: capitalize;
}
.readiness-explanation {
  color: var(--ink-soft);
  margin: 0.4rem 0;
}
.readiness-next {
  margin-top: 0.6rem;
  font-size: 0.95rem;
}
.readiness-next-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.readiness-cap {
  font-size: 0.85rem;
  color: var(--warning);
  background: var(--warning-weak);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  margin: 1rem 0 0;
}
.readiness-comps {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.4rem;
}
.readiness-comp-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.readiness-comp-track {
  height: 7px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
}
.readiness-comp-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

/* ---- Coverage (inside readiness) ---- */
.coverage-area {
  margin-top: 1.6rem;
}
.coverage-head {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.6rem;
}
.coverage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.coverage-obj {
  display: flex;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.coverage-icon {
  flex: none;
  width: 1.4rem;
  text-align: center;
  font-weight: 600;
}
.coverage-obj.is-covered .coverage-icon {
  color: var(--success-hover);
}
.coverage-obj.is-gap .coverage-icon {
  color: var(--warning);
}
.coverage-obj.is-gap .coverage-obj-title {
  color: var(--text);
}
.coverage-obj-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.coverage-obj-meta {
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.coverage-none {
  padding: 0.8rem 0;
}

/* ---- Readiness: per-objective breakdown ---- */
.readiness-objectives {
  margin-top: 1.6rem;
}
.readiness-objectives-head {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.6rem;
}
.obj-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.obj-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.obj-score {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
}
.obj-score.ok {
  color: var(--success-hover);
  background: var(--success-weak);
}
.obj-score.gap {
  color: var(--warning);
  background: var(--warning-weak);
}
.obj-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.obj-title {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.obj-meta {
  font-size: 0.8rem;
  color: var(--ink-faint);
}
.obj-bar {
  display: block;
  height: 5px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.obj-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.obj-bar-fill.ok {
  background: var(--success);
}
.obj-bar-fill.gap {
  background: var(--warning);
}

/* ---- Ask: grounded chat ---- */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: 58vh;
  overflow-y: auto;
  padding: 0.4rem 0.2rem;
  margin-bottom: 1rem;
}
.chat-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 2.5rem 1rem;
}
.chat-msg {
  display: flex;
}
.chat-msg.is-user {
  justify-content: flex-end;
}
.chat-msg.is-assistant {
  justify-content: flex-start;
}
.chat-bubble {
  max-width: 88%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.is-user .chat-bubble {
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.is-assistant .chat-bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.chat-msg .answer-sources {
  margin-top: 0.6rem;
}

.chat-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.chat-history-select {
  flex: 1;
  min-width: 0;
  max-width: 22rem;
}

/* =========================================================================
   ACCOUNTS: password toggles, forgot/reset, settings sections, danger zone,
   admin users table
   ========================================================================= */

/* ---- Password show/hide ---- */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.pw-wrap input {
  flex: 1;
  width: 100%;
  padding-right: 4rem; /* room for the toggle */
}
.pw-toggle {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}
.pw-toggle:hover {
  background: var(--primary-weak);
}

/* ---- Auth: forgot / reset ---- */
.auth-forgot {
  display: block;
  margin: 0.9rem auto 0;
  font-size: 0.88rem;
  font-weight: 500;
}
.auth-form-lede {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.1rem;
}
.reset-headline {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 1.4rem 0 1.2rem;
}
#view-reset .auth-form {
  text-align: left;
}

/* ---- Settings: sections ---- */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.1rem;
}
.settings-section-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.settings-section-lede {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

/* ---- Account page ---- */
.account-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: transparent;
}
.account-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}
.account-page-head {
  margin-bottom: 1.75rem;
}
/* Page head with a trailing action (e.g. Post a job). */
.account-page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
/* In-page back link (now that the global nav replaces per-page back buttons). */
.account-back {
  display: inline-block;
  margin-bottom: 0.6rem;
  padding-left: 0;
}
.account-page-head h1 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem;
}
.account-page-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}
/* On the full page the body scrolls; drop the modal's inner scroll. */
.account-shell .settings-body {
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}

/* ---- Avatar (profile photo) ---- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid var(--border-subtle);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}
.avatar-lg {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
}
.avatar-edit {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.avatar-edit-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.avatar-edit-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Examinations editor ---- */
.exam-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.exam-add .field {
  margin: 0;
  flex: 1 1 12rem;
}
.exam-add .exam-add-count {
  flex: 0 0 7rem;
}
.exam-rows {
  list-style: none;
  margin: 0 0 0.8rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.exam-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.exam-row-name {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text-strong);
}
a.exam-row-name {
  color: var(--primary);
  text-decoration: none;
}
a.exam-row-name:hover {
  text-decoration: underline;
}
.exam-add-hint {
  margin: -0.4rem 0 0.8rem;
  font-size: 0.85rem;
}
.exam-add-hint a {
  color: var(--primary);
  text-decoration: none;
}
.exam-add-hint a:hover {
  text-decoration: underline;
}
.exam-row-count {
  flex: 0 0 5rem;
}
.exam-empty {
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin: 0 0 0.8rem;
}

/* ---- Actuarial bodies (browse + view) ---- */
.account-page-wide {
  max-width: 1000px;
}
.bodies-grid {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}
.bodies-region-title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.7rem;
}
.bodies-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.8rem;
}
.body-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.body-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.body-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.body-card-abbr {
  font-weight: 600;
  color: var(--text-strong);
}
.body-card-name {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.3;
}
.body-card-meta {
  font-size: 0.78rem;
  color: var(--ink-faint);
}
.body-badge {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.body-badge-associate {
  background: var(--info-weak);
  color: var(--info);
}
.body-badge-actuary {
  background: var(--success-weak);
  color: var(--success);
}
.body-website-link {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
}
.body-website-link:hover {
  text-decoration: underline;
}
.body-exams {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.body-exam {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.body-exam-label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}
.body-exam-check {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}
.body-exam-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 auto;
}
.body-exam-code {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 0.9rem;
}
.body-exam-title {
  font-size: 0.88rem;
  color: var(--text);
}
.body-exam-desc {
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.35;
}
.body-exam-level {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Pathway (Associate / Fellow) + tracking ---- */
.body-next-sitting {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text);
}
.body-next-sitting-note {
  color: var(--ink-faint);
}
.pathway {
  margin-bottom: 1.4rem;
}
.pathway-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.pathway-title {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}
.pathway-progress {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.pathway-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.pathway-bar > span {
  display: block;
  height: 100%;
  background: var(--success);
  transition: width 0.2s ease;
}
.body-exams-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.body-exam.is-next {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-weak);
}
.body-exam-next {
  margin-left: 0.5rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--on-primary);
  background: var(--primary);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  vertical-align: middle;
}
.body-exam-quant {
  align-self: flex-start;
  margin-top: 0.1rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warning);
  background: var(--warning-weak);
  border: 1px solid var(--warning);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  cursor: help;
}
.body-exam-track {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 0.85rem 0.7rem 2.4rem;
}
.body-exam-interest,
.body-exam-sitting {
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
}

/* ---- Danger zone ---- */
.danger-zone {
  border: 1px solid #f3c4c4;
  border-radius: var(--radius-lg);
  background: var(--danger-weak);
  box-shadow: none;
}
.danger-zone .settings-section-title {
  color: var(--danger);
}
.danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.btn-danger {
  background: var(--danger);
  color: var(--on-primary);
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}
.btn-danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
}
.btn-danger-outline:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-weak);
}

/* ---- Admin: users table ---- */
.modal-card-wide {
  width: min(820px, 100%);
}

/* How-to-use guide modal: the study loop, the eight tabs, the extras. */
.guide-body {
  max-height: min(70vh, 40rem);
  overflow-y: auto;
  display: grid;
  gap: 1.25rem;
  padding-right: 0.25rem;
}
.guide-section h3 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.6rem;
}
.guide-steps {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.55;
}
.guide-tabs {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}
.guide-tabs > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem;
}
.guide-tabs dt {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.93rem;
}
.guide-tabs dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.55;
}
.guide-tips {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.55;
}
@media (max-width: 640px) {
  .guide-tabs > div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
.admin-stage {
  margin-top: 0.5rem;
  min-height: 6rem;
}
.admin-empty {
  padding: 1.5rem 0;
  text-align: center;
  font-style: italic;
}

/* Managed AI-key card (admin "AI key" tab). */
.admin-key-card {
  max-width: 34rem;
}
.admin-key-title {
  margin: 0 0 var(--space-2);
  font-size: 1.1rem;
}
.admin-key-lede {
  margin: 0 0 var(--space-3);
  font-size: 0.85rem;
  line-height: 1.5;
}
.admin-key-status {
  margin: 0 0 var(--space-3);
}
.admin-key-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.admin-table-wrap {
  max-height: 62vh;
  overflow: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.admin-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line-strong);
}
.admin-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-email {
  font-weight: 500;
  word-break: break-all;
}
.admin-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.admin-tags {
  white-space: nowrap;
}
.admin-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-faint);
  margin-right: 0.25rem;
}
.admin-tag.is-active {
  color: var(--success-hover);
  background: var(--success-weak);
  border-color: var(--success);
}
.admin-tag.is-suspended {
  color: var(--danger);
  background: var(--danger-weak);
  border-color: var(--danger);
}
.admin-tag.is-ok {
  color: var(--success-hover);
  border-color: var(--success);
}
.admin-tag.is-admin {
  color: var(--secondary-hover);
  background: var(--secondary-weak);
  border-color: var(--secondary);
}
.admin-actions {
  white-space: nowrap;
  text-align: right;
}
.admin-act {
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
}
.admin-danger:hover {
  color: var(--danger);
  background: var(--danger-weak);
}
.admin-self {
  font-size: 0.82rem;
  font-style: italic;
}

@media (max-width: 560px) {
  .admin-table {
    font-size: 0.85rem;
  }
  .admin-date {
    display: none;
  }
}

/* =========================================================================
   JOB BOARD
   ========================================================================= */
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.jobs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.jobs-filters {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.jobs-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.jobs-filter-rule {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 0.25rem 0;
}

.jobs-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  min-height: 1.4rem;
}
.jobs-count {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.job-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.job-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.job-title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-strong);
}
.job-company {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.job-salary {
  flex: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--success-hover);
  white-space: nowrap;
}

.job-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.7rem 0;
}
.job-tag {
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.job-tag-area {
  background: var(--primary-weak);
  color: var(--primary-hover);
}
.job-tag-qual {
  background: var(--success-weak);
  color: var(--success-hover);
}
.job-tag-remote {
  background: var(--warning-weak);
  color: var(--warning);
}
.job-tag-closed {
  background: var(--danger-weak);
  color: var(--danger);
}

.job-desc {
  margin: 0.3rem 0 0.9rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.job-owner-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}
.job-danger {
  color: var(--danger);
}

/* Post / edit modal */
.job-ai {
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.1rem;
}
.job-ai-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.job-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.job-form-wide {
  grid-column: 1 / -1;
}
.job-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

@media (max-width: 860px) {
  .jobs-layout {
    grid-template-columns: 1fr;
  }
  .jobs-filters {
    position: static;
  }
}
@media (max-width: 560px) {
  .job-form-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
   RESPONSIVE LAYER (consolidated): keep all content inside every viewport.
   Targets 1440 / 1024 / 768 / 360 widths. Mobile rules come last so they win.
   ========================================================================= */

/* ---- Global overflow guards (all widths) ---- */
img,
svg,
canvas {
  max-width: 100%;
}
/* Without min-width:0 a grid/flex child refuses to shrink below its content,
   which pushes the whole page wider than the screen on phones. */
.workspace > *,
.jobs-layout > *,
.readiness-top > * {
  min-width: 0;
}
/* Long unbroken strings (emails, document and exam names, URLs) must wrap. */
.user-email,
.doc-name,
.admin-email,
.job-title,
.study-title {
  overflow-wrap: anywhere;
}
/* Display math can be wider than a phone; let it scroll on its own axis. */
.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
/* Tall dialogs scroll inside the viewport instead of overflowing it. */
.modal-card {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

/* ---- Tablet portrait and below: stack workspace, swipe the mode tabs ---- */
@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  /* The study modes (lessons, drills, written, ask, cards, quiz, mock,
     readiness) overflow a phone width, so make the strip swipeable. */
  .mode-switch {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .mode-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* ---- Phone ---- */
@media (max-width: 560px) {
  .topbar {
    padding: 0.7rem 1rem;
  }
  .banner {
    flex-wrap: wrap;
    text-align: center;
  }
  .auth-card,
  .verify-card,
  .modal-card {
    padding: 1.25rem;
  }
  /* Weak-area rows: objective / bar / score stack vertically. */
  .weak-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .cards-toolbar .select {
    width: 100%;
  }
}

/* ---- Small phone (360px and below) ---- */
@media (max-width: 380px) {
  .rate-row {
    grid-template-columns: 1fr 1fr;
  }
  .mode-btn {
    padding: 0.45rem 0.8rem;
  }
  .result-ring {
    width: 112px;
    height: 112px;
  }
}

/* =========================================================================
   MORTALITY TABLES
   ========================================================================= */
.mortality-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mortality-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.mortality-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.mortality-toggle {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text-strong);
}

.mortality-caret {
  color: var(--text-muted);
  font-size: 0.85em;
}

.mortality-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.mortality-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.mortality-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.mort-danger {
  color: var(--danger);
}

.mortality-desc {
  margin: var(--space-2) 0 0;
  color: var(--text);
  font-size: 0.9rem;
}

.mortality-rates {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-3);
}

.mortality-rates-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-2);
}

.mortality-rates-scroll {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.mortality-rate-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.mortality-rate-table th,
.mortality-rate-table td {
  padding: 6px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
}

.mortality-rate-table th:first-child,
.mortality-rate-table td:first-child {
  text-align: left;
}

.mortality-rate-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  color: var(--text-strong);
  font-family: var(--font-sans);
  z-index: 1;
}

.mortality-rate-table tbody tr:nth-child(even) {
  background: var(--surface-sunken);
}

/* =========================================================================
   PDF VIEWER
   ========================================================================= */
.study-head-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* A clickable page reference (in lessons, drills, written, sources, etc.). */
.page-ref {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.page-ref:hover {
  color: var(--primary-hover);
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(3px);
}
.pdf-dialog {
  position: relative;
  width: min(1100px, 100%);
  height: min(92vh, 100%);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.pdf-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.pdf-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.pdf-iconbtn {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.25rem 0.55rem;
}
.pdf-pageind {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
}
.pdf-pageind input {
  width: 3.2rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  text-align: right;
}
.pdf-bar-title {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.pdf-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
  background: var(--surface-sunken);
}
.pdf-canvas-wrap canvas {
  box-shadow: var(--shadow-lg);
  background: #fff;
  max-width: 100%;
  height: auto;
}
.pdf-side {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  padding: 1rem;
}
.pdf-side-sec {
  margin-bottom: 1.25rem;
}
.pdf-side-sec h4 {
  margin: 0 0 0.5rem;
  font-weight: 600;
}
.pdf-side-hint {
  font-size: 0.82rem;
  color: var(--ink-soft, #667085);
  margin: 0 0 0.6rem;
}
.pdf-radio {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.pdf-sel-input,
.pdf-note-input {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
}
.pdf-side-actions {
  display: flex;
  justify-content: flex-end;
}
.pdf-sel-state {
  font-size: 0.8rem;
  color: var(--accent-deep);
  margin: 0.5rem 0 0;
}
.pdf-notes-list {
  margin-bottom: 0.5rem;
}
.pdf-notes-empty {
  font-size: 0.85rem;
  color: var(--ink-soft, #667085);
}
.pdf-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--surface-sunken);
}
.pdf-note-body {
  white-space: pre-wrap;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}
.pdf-note-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}
.pdf-note-actions .btn {
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
}
@media (max-width: 720px) {
  .pdf-side {
    width: 240px;
  }
}

/* ===================== Past papers (P5) ===================== */
.paper-new {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.paper-new .input {
  flex: 1 1 160px;
  min-width: 140px;
}
.paper-new .paper-new-variant {
  flex: 0 1 130px;
}
.papers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.paper-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-4);
}
.paper-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.paper-card-title {
  margin: 0;
  font-size: 1rem;
  color: var(--text-strong);
}
.paper-card-meta {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.paper-parts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.paper-part {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.paper-part.is-missing {
  background: transparent;
  border: 1px dashed var(--line-strong);
}
/* An optional, not-yet-added part (the mark scheme) is softer than a missing
   required one: lighter dashed border so it doesn't read as an unmet need. */
.paper-part.is-optional {
  background: transparent;
  border: 1px dashed var(--line);
}
.paper-part-kind {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-strong);
  flex: 0 0 130px;
}
.paper-part-name {
  flex: 1 1 140px;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.paper-part-status {
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.paper-part-status.is-ready {
  background: var(--success-weak);
  color: var(--success-hover);
}
.paper-part-status.is-pending {
  background: var(--info-weak);
  color: var(--info);
}
.paper-part-status.is-none,
.paper-part-status.is-optional {
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.paper-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.paper-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.cards-loading {
  display: flex;
  justify-content: center;
  padding: var(--space-8) 0;
}
@media (max-width: 720px) {
  .paper-part-kind {
    flex-basis: 100%;
  }
}

/* =========================================================================
   EXAM READINESS ROLLUP (body view: per-paper panel) + MOCK TREND
   ========================================================================= */
.body-exam-date {
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm, 6px);
  background: var(--surface);
  color: inherit;
}
.body-exam-readiness-btn {
  font-size: 0.82rem;
  padding: 0.25rem 0.7rem;
}
.body-exam-readiness-panel {
  margin: 0 0.85rem 0.8rem 2.4rem;
}
.body-exam-readiness-panel .readiness {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  padding: var(--space-4);
}
.exam-readiness-empty {
  font-weight: 600;
  margin: 0 0 var(--space-1);
}
/* The rollup line mixes a code + a count ("SP4 across 3 documents"); the
   document-grain capitalize rule would title-case every word of it. */
.exam-readiness .readiness-confidence {
  text-transform: none;
}

/* Pacing strip: the study-plan math against the target date. */
.exam-pacing {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.exam-pacing-when {
  margin: 0 0 var(--space-2);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.exam-pacing-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
.pacing-stat {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pacing-stat strong {
  font-size: 1.05rem;
  color: var(--text, #0f172a);
}
.pacing-stat.is-gap strong {
  color: var(--danger);
}
.exam-pacing-hint {
  margin-top: var(--space-3);
  font-size: 0.85rem;
}

/* Mock score trend (oldest first; the latest row is emphasised). */
.mock-trend-slot {
  width: 100%;
}
.mock-trend {
  margin-top: var(--space-4);
  text-align: left;
}
.mock-trend-head {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 var(--space-2);
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.trend-delta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}
.trend-delta.up {
  color: var(--success-hover);
}
.trend-delta.down {
  color: var(--danger);
}
.trend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}
.trend-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm, 6px);
}
.trend-row.is-latest {
  background: var(--surface-sunken);
  color: inherit;
  font-weight: 600;
}
.trend-when {
  white-space: nowrap;
}
.trend-bar {
  display: block;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.trend-row.is-latest .trend-bar {
  background: var(--surface);
}
.trend-bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--danger);
  transition: width 0.4s ease;
}
.trend-bar-fill.ok {
  background: var(--success);
}
.trend-score {
  white-space: nowrap;
}
/* ---- Tablet portrait and below ---- */
@media (max-width: 720px) {
  /* The track row loses the checkbox indent and its controls share the width
     instead of jutting past the screen edge. */
  .body-exam-track {
    padding-left: 0.85rem;
  }
  .body-exam-interest,
  .body-exam-sitting,
  .body-exam-date {
    flex: 1 1 9rem;
    min-width: 0;
  }
  .body-exam-readiness-btn {
    flex: 1 1 100%;
  }
  .body-exam-readiness-panel {
    margin-left: 0.85rem;
    margin-right: 0.85rem;
  }
  .trend-row {
    grid-template-columns: 5rem 1fr auto;
  }
}

/* ---- Phone ---- */
@media (max-width: 560px) {
  .body-exam-readiness-panel .readiness {
    padding: var(--space-3);
  }
  /* Centre the ring above the summary instead of squeezing beside it. */
  .body-exam-readiness-panel .readiness-top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .body-exam-readiness-panel .result-ring {
    align-self: center;
  }
  /* Four pacing stats read as a tidy 2x2 instead of a ragged wrap. */
  .exam-pacing-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  /* Trend rows: date and score share the top line; the bar runs full-width
     beneath them. */
  .trend-row {
    grid-template-columns: 1fr auto;
    row-gap: 2px;
    padding: 4px 6px;
  }
  .trend-when,
  .trend-score {
    grid-row: 1;
  }
  .trend-bar {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

/* ---- Small phone ---- */
@media (max-width: 380px) {
  .exam-pacing-stats {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  .pacing-stat strong {
    font-size: 1rem;
  }
}

/* =========================================================================
   LESSON TEACHING BLOCKS - the lesson rendered as a teacher writes it.
   Shared by the typed-block page (.lb-*) and the markdown fallback's styled
   conventions (.lesson-block-*): same visual language either way.
   ========================================================================= */
.lesson-body {
  margin-top: var(--space-3);
}
.lesson-blocks {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.lb {
  min-width: 0;
}
.lb-kicker {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary, #1d4ed8);
  margin: 0 0 0.3rem;
}
.lb-label {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}
/* The problem a concept answers - set like a pull-quote so the question lands. */
.lb-hook {
  font-style: italic;
  color: var(--ink-soft, #334155);
  border-left: 3px solid var(--primary, #1d4ed8);
  padding: 0.35rem 0 0.35rem 0.85rem;
  margin: var(--space-2) 0 0;
  font-size: 1.02rem;
}
/* The formal bit: definition/formula set apart on a calm tinted ground. */
.lb-formula {
  background: var(--info-weak, #eef4fd);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}
/* Worked example: a distinct boxed ground so the eye finds it instantly. */
.lb-example,
.lesson-block-example {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--success, #16a34a);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}
/* In the exam: what you must be able to DO with the topic. */
.lb-exam_note,
.lesson-block-exam {
  background: var(--warning-weak, #fdf6e7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}
/* The trap: one-line warning chip-paragraph. */
.lb-watchout,
.lesson-watchout {
  background: var(--danger-weak);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm, 6px);
  padding: 0.5rem 0.8rem;
  margin: 0;
  font-size: 0.92rem;
}
.lb-watchout::before,
.lesson-watchout::before {
  content: "⚠ ";
}
/* Side-by-side comparison table. */
.lb-table-scroll {
  overflow-x: auto;
}
.lb-compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.lb-compare th,
.lb-compare td {
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
.lb-compare th {
  background: var(--surface-sunken);
  font-weight: 600;
}
/* Inline quick check: framed so it reads as a beat of the page, not a quiz. */
.lb-check {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
}
.lb-check .mcq-stem {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}
/* Recall close: produce, don't re-read, before finishing. */
.lb-recall {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
}
.lb-recall-lede {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.4rem;
}
.lb-recall ul {
  margin: 0;
  padding-left: 1.2rem;
}
.lesson-finish-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 var(--space-2);
}
@media (max-width: 560px) {
  .lb-formula,
  .lb-example,
  .lb-exam_note,
  .lb-check,
  .lesson-block-example,
  .lesson-block-exam {
    padding: var(--space-3);
  }
}

/* Foot navigator: previous/next lesson chevrons at the bottom of the page
   view, where the reader actually is after a long lesson. Big tap targets. */
.lesson-foot-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
.lesson-foot-arrow {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.35rem 1.1rem;
  border-radius: var(--radius-pill);
}
.lesson-foot-arrow:disabled {
  opacity: 0.35;
}
.lesson-foot-pos {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Quick checks can be hidden while reading. The hide is CSS-only (blocks stay
   in the DOM), so answers already given survive toggling back on. */
.lesson-page.checks-hidden .lb-check {
  display: none;
}
.lesson-check-tools {
  display: flex;
  justify-content: flex-end;
  margin: var(--space-2) 0 0;
}
.check-toggle-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}

/* Section extras: drill the section a check just covered. Each extra question
   stacks under its check, visually subordinate to it (dashed inset). */
.lb-extra {
  margin-top: var(--space-3);
  border-top: 1px dashed var(--border-strong);
  padding-top: var(--space-3);
}
.lb-extra-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.45rem;
}
.lb-check-more {
  margin-top: var(--space-2);
}
.check-more-btn {
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}

/* In practice: where a working actuary actually applies the concept. */
.lb-in_practice {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary, #1d4ed8);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

/* Generation banner: what is being built and under which page scope, with a
   graceful Stop. Sticky so it stays visible while scrolling any tab. */
.generation-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.55rem 0.9rem;
  margin-bottom: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--info-weak, #eef4fd);
  font-size: 0.88rem;
}
.generation-banner-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.generation-stop {
  flex: none;
  font-size: 0.82rem;
  padding: 0.25rem 0.8rem;
}
@media (max-width: 560px) {
  .generation-banner-text {
    white-space: normal;
  }
}

/* =========================================================================
   MOBILE RESPONSIVENESS HARDENING  (2026-06-13)
   ------------------------------------------------------------------------
   A 390px phone-width audit found two real horizontal-overflow sources that
   made the whole app pan sideways and the study header render on top of
   itself on EVERY study tab:

   1. .study-head pinned the title and the action cluster (How to use /
      View PDF / Delete / status pill) in ONE non-wrapping row. At phone
      width the title was crushed to a few characters and the status pill
      spilled ~75px past the screen edge.
   2. .field is a flex child (e.g. the account exam-body <select>) with the
      default min-width:auto, so a long option could not shrink and pushed
      the account view past the viewport.

   App-wide breakpoints:
     860px  nav collapses to a sheet; workspace becomes single-column
     640px  side-by-side header/action clusters stack
   ========================================================================= */

/* min-width:auto is the classic source of horizontal overflow: a flex child
   refuses to shrink below its content's intrinsic width, so a long <select>
   option or an unbreakable token blows past a phone viewport. Let the study
   header's title column and field wrappers shrink. */
.study-head > div,
.field {
  min-width: 0;
}

/* Belt-and-braces: with the real overflow removed by the rules here, clip any
   stray sub-pixel spill so one future regression can't make the whole page
   scroll sideways. A safety net, not the fix. */
html,
body {
  overflow-x: clip;
}

/* ---- Phone (<= 640px): relayout the study header ----
   Title on its own line; the action cluster wraps onto a tidy row beneath it
   instead of fighting the title for horizontal space and overflowing. */
@media (max-width: 640px) {
  .study-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .study-head-right {
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
  }
  /* The status pill ("Ready" / "Processing…") flows with the action row and
     reads left-aligned, never pinned hard-right off the screen edge. */
  .study-status {
    text-align: left;
    white-space: normal;
  }
}

/* ---- Library as an off-canvas drawer on phones ----
   Inline, the library (upload + doc list) stacked above the study content, so
   on a phone you scrolled past all of it to reach what you were studying. On
   <=860px it becomes a slide-in drawer opened from a "Documents" button at the
   top of the study column; the backdrop, close button, and selecting a
   document all dismiss it. The drawer chrome below is hidden on desktop, where
   the library is simply the static left-hand column. */
.library-toggle,
.library-close,
.library-backdrop {
  display: none;
}
.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

@media (max-width: 860px) {
  /* The opener lives at the top of the study column. */
  .library-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-strong);
    cursor: pointer;
  }
  .library-toggle-icon {
    font-size: 1rem;
    line-height: 1;
    color: var(--primary);
  }

  /* The drawer: fixed, off-canvas left, slides in on body.library-open. It
     docks BELOW the sticky app bar (whose height is measured into --topbar-h):
     .app-shell is a z-index:2 stacking context, so the drawer can't paint over
     the z-30 topbar from inside it — docking below keeps its header visible. */
  .library {
    position: fixed;
    inset: var(--topbar-h, 64px) auto 0 0;
    width: min(86vw, 340px);
    max-width: none;
    margin: 0;
    z-index: 60;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    border-right: 1px solid var(--border-subtle);
  }
  .library .panel {
    min-height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  body.library-open .library {
    transform: translateX(0);
  }
  .library-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--text-strong);
    font-size: 1rem;
    cursor: pointer;
  }

  /* Backdrop + scroll-lock while the drawer is open. */
  .library-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h, 64px) 0 0 0;
    z-index: 55;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.library-open .library-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.library-open {
    overflow: hidden;
  }
}

/* The drawer is a transient overlay, not part of the page flow: never let it
   leave a phantom scroll or block taps when motion is reduced. */
@media (prefers-reduced-motion: reduce) {
  .library {
    transition: none;
  }
}

/* ---- Tab strip: make the horizontal scroll read as a deliberate swipe ----
   The mode strip already scrolls at <=860px; snap each tab and hide the
   scrollbar so it looks like a control, not a clipped row. JS keeps the
   active tab centred (see flashcards.js setMode). */
@media (max-width: 860px) {
  .mode-switch {
    scroll-snap-type: x proximity;
    scroll-padding-inline: 0.5rem;
    scrollbar-width: none;
  }
  .mode-switch::-webkit-scrollbar {
    display: none;
  }
  .mode-btn {
    scroll-snap-align: start;
  }
}

/* ============ PREP (Body→Paper→Materials→Generate) ============
   A guided flow page (#view-prep) reusing the account-page shell, settings
   sections, and body-exam rows. New classes below cover the picker row, the
   materials list rows (which share .body-exam), the kind selects, the
   confirm/exclude toggles, and the generate grid. Atlas tokens only. */

/* ---- Picker + add-material rows: flex line, wrap, bottom-aligned ---- */
.prep-picker-row,
.prep-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
}
/* The picker/add rows sit inside .field wrappers (which carry a bottom
   margin); cancel it so the row stays tight and items align on one line. */
.prep-picker-row .field,
.prep-add .field {
  margin-bottom: 0;
  flex: 1 1 12rem;
  min-width: 0;
}
.prep-add-hint {
  flex-basis: 100%;
  margin: var(--space-1) 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Searchable add-document picker ----
   The search input + filtered results list + chosen-doc line live in a
   relative column so the results can sit directly under the input. */
.prep-add-picker {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 16rem;
  min-width: 0;
}
.prep-add-picker .field {
  margin-bottom: 0;
}
/* Results: a bordered, scrollable list overlaying the flow under the input. */
.prep-add-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.prep-add-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-subtle);
}
.prep-add-result:last-child {
  border-bottom: 0;
}
.prep-add-result:hover,
.prep-add-result.is-active {
  background: var(--surface-sunken);
}
/* A muted, non-interactive tag note ("· tagged SP4") after the title. */
.prep-add-result-note {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}
/* The "No matches" placeholder li reads as muted, non-clickable text. */
.prep-add-result.is-empty {
  cursor: default;
  color: var(--text-muted);
}
.prep-add-result.is-empty:hover {
  background: transparent;
}
/* The chosen-document confirmation line under the picker. */
.prep-add-selected {
  margin: var(--space-2) 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Upload-a-new-PDF row: file input + button on one wrapping line ---- */
.prep-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.prep-upload-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Syllabus-upload mode: a sitting picker + a public-document notice. No `display`
   here so the [hidden] attribute governs visibility (JS toggles it). */
.prep-syllabus-fields {
  margin-top: var(--space-3);
}
.prep-syllabus-fields .field {
  max-width: 18rem;
  margin-bottom: var(--space-2);
}

/* ---- Generate grid: four equal-ish action buttons that wrap ---- */
.prep-generate-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.prep-gen-btn {
  flex: 1 1 12rem;
  min-width: 11rem;
  justify-content: center;
}

/* ---- Material rows (share .body-exam for the card chrome) ---- */
.prep-material {
  padding: var(--space-3) var(--space-4);
}
.prep-material.is-syllabus,
.prep-material.is-reference {
  background: var(--surface-sunken);
  border-style: dashed;
}

/* Head: title/meta on the left, status badge pinned right. */
.prep-material-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.prep-material-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.prep-material-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-strong);
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.prep-material-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* Controls row: kind select + relevance/keep/exclude/remove buttons. */
.prep-material-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.prep-kind-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.prep-kind-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.prep-kind-select {
  padding: 0.3rem 1.9rem 0.3rem 0.6rem;
  font-size: 0.84rem;
  background-position: right 0.55rem center;
  border-radius: var(--radius-sm);
}

/* Confirm / exclude act as a paired toggle; the active one reads as selected. */
.prep-confirm.is-active {
  background: var(--primary-weak);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.prep-reject.is-active {
  background: var(--danger-weak);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}

/* AI reasoning line under a checked material. */
.prep-material-reason {
  margin: var(--space-2) 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* ---- Phones: stack the picker/add lines into a column ---- */
@media (max-width: 640px) {
  .prep-picker-row,
  .prep-add {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .prep-picker-row .field,
  .prep-add .field {
    flex: 1 1 auto;
  }
  /* The searchable picker becomes a full-width stacked block too. */
  .prep-add-picker {
    flex: 1 1 auto;
  }
  .prep-gen-btn {
    flex-basis: 100%;
  }
}
@media (max-width: 560px) {
  .prep-material-head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .prep-material-controls {
    width: 100%;
  }
  /* Let the relevance/keep/exclude/remove buttons fill the row evenly when
     they wrap, rather than clustering tight on the left. */
  .prep-material-controls .btn {
    flex: 1 1 auto;
  }
}

/* =========================================================================
   WALLET — AI credit balance, M-Pesa top-up, and recent usage.
   Reuses .settings-section / .notice / .field / .btn; styles only the
   wallet-specific bits with existing Atlas tokens.
   ========================================================================= */
.wallet-balance-amount {
  display: block;
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary);
}

/* Trial / free-credit line: a brass-tinted pill that reads as a perk. */
.wallet-trial {
  display: inline-block;
  margin: var(--space-2) 0 0;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--accent-weak);
  border: 1px solid var(--accent-line);
  color: var(--text-strong);
  font-size: 0.85rem;
  font-weight: 600;
}

.wallet-platform {
  margin: var(--space-2) 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Quick-amount buttons sit in a tidy wrapping row above the manual fields. */
.wallet-quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* Top-up controls: amount + phone fields share a row with the submit button,
   aligned to the bottom so the button lines up with the inputs. */
.wallet-topup {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}
.wallet-topup .field {
  margin-bottom: 0;
  flex: 1 1 180px;
}

/* Recent usage: a plain list of rows, value right-aligned. */
.wallet-usage {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wallet-usage-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.wallet-usage-feature {
  font-weight: 600;
  color: var(--text-strong);
}
.wallet-usage-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.wallet-usage-cost {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
}

/* Phones: stack the top-up row into a column so fields and button fill width. */
@media (max-width: 640px) {
  .wallet-topup {
    flex-direction: column;
    align-items: stretch;
  }
  .wallet-topup .field {
    flex: 1 1 auto;
  }
  .wallet-topup .btn {
    width: 100%;
  }
}

/* Curated mastery panel (prep progress) — dials over the whole syllabus */
.mastery-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.25rem 0 0.6rem;
}
.mastery-stat {
  flex: 1 1 5rem;
  min-width: 5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 10px;
  text-align: center;
  background: var(--surface, #fff);
}
.mastery-stat--lead {
  border-color: var(--primary);
  background: var(--primary-weak);
}
.mastery-stat-val {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.mastery-stat--lead .mastery-stat-val {
  color: var(--primary);
}
.mastery-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.mastery-sub {
  color: var(--ink-faint);
  font-size: 0.8rem;
  margin: 0 0 0.85rem;
}
.mastery-section {
  margin: 0 0 0.85rem;
}
.mastery-section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.mastery-section-score {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.mastery-bar {
  display: block;
  height: 6px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.3rem 0 0.45rem;
}
.mastery-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}
.mastery-bar-fill.is-low {
  background: var(--danger);
}
.mastery-bar-fill.is-mid {
  background: var(--warning);
}
.mastery-bar-fill.is-high {
  background: var(--success);
}
.mastery-items {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mastery-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.mastery-item-title {
  overflow-wrap: anywhere;
}
.mastery-item-stage {
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Auto-map review (AI-proposed coverage rows awaiting accept) */
.automap-head {
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin: 0.25rem 0 0.4rem;
}
.automap-rows {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 18rem;
  overflow-y: auto;
}
.automap-row label {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}
