/* Lyra design system — Bricolage Grotesque + Public Sans + IBM Plex Mono,
   indigo/amber on a cool neutral. Three-state theming (light / dark / system).
   Support for collapsible dark sidebar, dashboard cards, subject swatches, and two-column layouts. */
:root {
  --bg: #f5f5fb; --card: #ffffff; --surface-2: #f8fafc;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #4f46e5; --accent: #f59e0b;
  --ok: #10b981; --ok-wash: #ecfdf5; --warn: #f59e0b; --warn-wash: #fffbeb; --danger: #ef4444;
  --sidebar-bg: #0f172a; --sidebar-card: #1e293b; --sidebar-line: #334155; --sidebar-text: #f8fafc; --sidebar-muted: #94a3b8;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 10px 24px -12px rgba(15,23,42,.12);
  --display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  --brand-ink: color-mix(in srgb, var(--brand) 74%, #000);
  --brand-wash: color-mix(in srgb, var(--brand) 12%, var(--card));
  --on-brand: #ffffff;
  /* Scales (docs/DESIGN_SYSTEM.md §2) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --fs-xs: 0.74rem; --fs-sm: 0.82rem; --fs-md: 0.92rem; --fs-lg: 1.1rem; --fs-xl: 1.35rem; --fs-2xl: 1.7rem;
  --motion: 180ms ease;
  /* Subject colours: same subject, same colour, on every screen */
  --subj-maths: #4f46e5; --subj-science: #10b981; --subj-chemistry: #f59e0b; --subj-physics: #f59e0b;
  --subj-english: #0284c7; --subj-history: #e11d48; --subj-geography: #0d9488; --subj-other: #7c3aed;
}
@media (prefers-reduced-motion: reduce) { :root { --motion: 0ms; } .view { animation: none; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090d16; --card: #131b2e; --surface-2: #1e293b;
    --ink: #f8fafc; --muted: #94a3b8; --line: #1e293b;
    --ok: #34d399; --ok-wash: #064e3b; --warn: #fbbf24; --warn-wash: #451a03; --danger: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -16px rgba(0,0,0,.6);
    --brand-ink: color-mix(in srgb, var(--brand) 62%, #fff);
    --brand-wash: color-mix(in srgb, var(--brand) 24%, var(--card));
  }
}
:root[data-theme="dark"] {
  --bg: #090d16; --card: #131b2e; --surface-2: #1e293b;
  --ink: #f8fafc; --muted: #94a3b8; --line: #1e293b;
  --ok: #34d399; --ok-wash: #064e3b; --warn: #fbbf24; --warn-wash: #451a03; --danger: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -16px rgba(0,0,0,.6);
  --brand-ink: color-mix(in srgb, var(--brand) 62%, #fff);
  --brand-wash: color-mix(in srgb, var(--brand) 24%, var(--card));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
button { font-family: var(--body); cursor: pointer; }
input, textarea, select { font-family: var(--body); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mono, .tnum { font-variant-numeric: tabular-nums; }

/* Layout Shell */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; justify-content: space-between; padding: 20px 16px; border-right: 1px solid var(--sidebar-line); z-index: 30; transition: transform 0.3s ease; }
.sidebar-header { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.sidebar-brand { font-family: var(--display); font-size: 1.25rem; font-weight: 800; color: #ffffff; display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand span { color: var(--accent); }
.mode-badge { font-size: 0.68rem; font-weight: 700; background: rgba(79, 70, 229, 0.3); color: #818cf8; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; border: 1px solid rgba(129, 140, 248, 0.3); }

.sidebar-search { position: relative; }
.sidebar-search input { width: 100%; padding: 8px 12px 8px 32px; border-radius: var(--radius-sm); border: 1px solid var(--sidebar-line); background: var(--sidebar-card); color: var(--sidebar-text); font-size: 0.82rem; }
.sidebar-search input::placeholder { color: var(--sidebar-muted); }
.sidebar-search::before { content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; opacity: 0.7; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.navbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--sidebar-muted); font-size: 0.88rem; font-weight: 600; text-align: left; transition: all 0.2s ease; }
.navbtn:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
.navbtn.active { background: var(--brand); color: #ffffff; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4); }
.navbtn .nav-icon { font-size: 1.1rem; }

.sidebar-footer { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--sidebar-line); padding-top: 16px; }
.user-card { display: flex; align-items: center; justify-content: space-between; background: var(--sidebar-card); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--sidebar-line); }
.user-info { display: flex; align-items: center; gap: 10px; overflow: hidden; flex: 1; min-width: 0; }
.user-info > div { min-width: 0; }
/* The sign-out button inherits .navbtn's width:100%, which used to squeeze the name and role to a few letters. */
.user-card > .navbtn { width: auto; flex: 0 0 auto; }
.avatar { width: 34px; height: 34px; border-radius: 999px; background: var(--brand); color: #ffffff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.user-name { font-size: 0.82rem; font-weight: 700; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main Content Area */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-title h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-search { flex: 1; max-width: 420px; margin: 0 16px; position: relative; }
.header-search input { width: 100%; padding: 8px 12px 8px 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: var(--fs-sm); }
.header-search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; opacity: 0.7; }
.icon-toggle { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 1rem; display: grid; place-items: center; }
.header-user { display: flex; align-items: center; gap: 8px; }
.header-user .avatar { width: 32px; height: 32px; font-size: 0.8rem; }
.header-user .name { font-weight: 700; font-size: var(--fs-sm); }
.menu-toggle { display: none; background: transparent; border: none; font-size: 1.25rem; color: var(--ink); cursor: pointer; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.streak-pill { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--warn-wash); color: var(--warn); font-size: 0.82rem; font-weight: 700; border: 1px solid rgba(245, 158, 11, 0.2); }
.xp-pill { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--brand-wash); color: var(--brand); font-size: 0.82rem; font-weight: 700; }

.main-body { flex: 1; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* Grid Views */
.view { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px);} to {opacity:1;transform:none;} }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.hero { font-size: 24px; line-height: 1.2; margin: 0 0 8px; font-weight: 800; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }

/* Auth Layout */
.auth { max-width: 480px; margin: 40px auto; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: var(--fs-lg); margin-bottom: 14px; }
.auth-brand .spark { color: var(--accent); }
.auth .hero { font-size: 22px; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin: 4px 0 16px; max-width: 100%; overflow-x: auto; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; transition: background var(--motion), color var(--motion); }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--brand); color: var(--on-brand); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 700; font-size: 0.88rem; }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: default; }
.authform textarea { padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: 14px; }
.authform { display: flex; flex-direction: column; gap: 12px; }
.authform label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.authform input, .authform select { padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: 14px; }

/* Dashboard Home Cards */
.welcome-card { background: linear-gradient(135deg, var(--brand) 0%, #312e81 100%); color: #ffffff; border: none; padding: 28px; position: relative; overflow: hidden; margin-bottom: 24px; border-radius: var(--radius); }
.welcome-card h1 { color: #ffffff; font-size: 1.65rem; margin-bottom: 6px; }
.welcome-card p { color: rgba(255, 255, 255, 0.85); font-size: 0.95rem; margin-bottom: 20px; max-width: 600px; }
.welcome-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-box { background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px); padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,0.2); }
.stat-val { font-size: 1.4rem; font-weight: 800; font-family: var(--display); }
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; margin-top: 10px; }
.section-header h2 { font-size: 1.2rem; font-weight: 700; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 28px; }
.subject-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); transition: transform 0.2s ease, border-color 0.2s ease; }
.subject-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.subject-icon { font-size: 1.8rem; margin-bottom: 8px; }
.subject-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.subject-desc { font-size: 0.8rem; color: var(--muted); margin-bottom: 14px; }
.progress-bar-bg { width: 100%; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; }
.progress-bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.4s ease; }

/* 2-Column Practice Layout */
.grid-2col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 900px) {
  .header-search, .header-user .name { display: none; }
  .top-header { padding: 10px 14px; gap: 8px; }
  .header-actions { gap: 6px; }
  .streak-pill, .xp-pill { padding: 5px 9px; font-size: var(--fs-xs); }
  .streak-pill .pill-word, .xp-pill .pill-word { display: none; }
  .main-body { padding: 16px; }
  .card { padding: 16px; }
  .welcome-card { padding: 20px; }
  .welcome-card h1 { font-size: var(--fs-xl); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .grid-2col { grid-template-columns: 1fr; }
}

/* Chat Shell */
.chat-shell { display: flex; height: calc(100vh - 140px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.convos { width: 240px; background: var(--surface-2); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-main { flex: 1; display: flex; flex-direction: column; justify-content: space-between; background: var(--card); }
.messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.msg-bubble { max-width: 82%; padding: 12px 16px; border-radius: 14px; font-size: 0.9rem; line-height: 1.5; }
.msg-bubble.user { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 2px; }
.msg-bubble.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 2px; }

.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: var(--card); }
.chat-input textarea { flex: 1; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); resize: none; font-size: 0.9rem; }
/* Conversation history list (left rail) */
#convo-list li { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; cursor: pointer; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; transition: background .15s ease; }
#convo-list li:hover { background: color-mix(in srgb, var(--brand) 10%, var(--card)); }
#convo-list li.active { background: var(--brand); color: var(--on-brand); font-weight: 700; }
#convo-list li.convo-empty { cursor: default; color: var(--muted); }
#convo-list li.convo-empty:hover { background: transparent; }
/* Chat rows: title + hover/focus actions (archive / restore / delete). */
#convo-list li.convo-row { display: flex; align-items: center; gap: 6px; padding-right: 6px; }
#convo-list li.convo-row .convo-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#convo-list li.convo-row .convo-actions { display: none; flex: none; gap: 2px; }
#convo-list li.convo-row:hover .convo-actions, #convo-list li.convo-row:focus-within .convo-actions,
#convo-list li.convo-row.active .convo-actions { display: inline-flex; }
/* No hover on touch devices — keep the actions visible. */
@media (hover: none) { #convo-list li.convo-row .convo-actions { display: inline-flex; } }
.convo-act { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 3px 5px; border-radius: 6px; opacity: .8; }
.convo-act:hover, .convo-act:focus-visible { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); outline: none; }
.convo-act.danger:hover, .convo-act.danger:focus-visible { background: color-mix(in srgb, #dc2626 18%, transparent); color: #dc2626; }
#convo-list li.active .convo-act.danger:hover { color: var(--on-brand); }
#convo-list li.convo-toggle { margin-top: 4px; padding: 4px 12px; }
.linkish { border: 0; background: none; color: var(--brand); cursor: pointer; font: inherit; font-size: 0.8rem; font-weight: 600; padding: 0; }
.linkish:hover { text-decoration: underline; }
/* Message bubbles — the chat shell renders these but had no styles at all. */
.bubble { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 0.93rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-images { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.bubble-images img { max-width: 220px; max-height: 220px; border-radius: 10px; object-fit: cover; border: 1px solid rgba(255,255,255,.25); }
.bubble.thinking { align-self: flex-start; background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); font-style: italic; }
.bubble.thinking::after { content: "…"; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }


/* Upload Dropzone */
.drag-drop-zone { border: 2px dashed var(--brand); background: var(--brand-wash); border-radius: var(--radius); padding: 36px 20px; text-align: center; cursor: pointer; transition: background 0.2s ease; margin-top: 12px; }
.drag-drop-zone:hover { background: var(--surface-2); }
.drag-drop-zone.over { background: color-mix(in srgb, var(--brand) 22%, var(--card)); border-style: solid; }
.dd-icon { font-size: 2.4rem; margin-bottom: 6px; }
.dd-text { font-size: 0.95rem; }
.connector-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.connector-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.connector-btn:hover { border-color: var(--brand); }
.connector-btn.soon { opacity: .6; cursor: not-allowed; }
.connector-btn .soon-tag { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 2px 6px; border-radius: 999px; }
.kb-sources { display: flex; flex-direction: column; }
.kb-src { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.kb-src:first-child { border-top: 0; }
.kb-src .t { font-weight: 700; font-size: 0.9rem; }
.kb-src .m { color: var(--muted); font-size: 0.78rem; }
.kb-src .del { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 0.78rem; color: var(--danger); cursor: pointer; }

.dd-icon { font-size: 2.2rem; margin-bottom: 8px; }

/* Badges Grid */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.badge-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; text-align: center; background: var(--surface-2); opacity: 0.55; transition: all 0.2s ease; }
.badge-card.unlocked { opacity: 1; background: var(--card); border-color: var(--brand); box-shadow: var(--shadow); }
.badge-icon { font-size: 2.2rem; margin-bottom: 6px; }
.badge-title { font-size: 0.85rem; font-weight: 700; }
.badge-summary { color: var(--muted); font-size: 0.85rem; font-weight: 600; margin: 4px 0 0; }
.badge-status { font-size: 0.7rem; font-weight: 700; margin: 4px 0; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-status.earned { color: #059669; }
.badge-status.locked { color: var(--muted); }
/* Quiz runner: answer options + graded states. Selected = brand outline;
   after submit the correct option turns green and a wrong pick turns red. */
.quiz-q-card { padding: 14px 0; border-top: 1px solid var(--line); }
.quiz-q-card:first-child { border-top: 0; padding-top: 4px; }
.quiz-q-title { font-weight: 700; margin-bottom: 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.option-btn { display: block; width: 100%; text-align: left; padding: 10px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 0.92rem;
  cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.option-btn:hover:not(:disabled) { border-color: var(--brand); }
.option-btn.selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--surface-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); font-weight: 700; }
.option-btn:disabled { cursor: default; }
.option-btn.correct { border-color: #16a34a; background: color-mix(in srgb, #16a34a 18%, var(--surface-2)); color: #15803d; font-weight: 700; }
.option-btn.wrong { border-color: #dc2626; background: color-mix(in srgb, #dc2626 18%, var(--surface-2)); color: #b91c1c; font-weight: 700; text-decoration: line-through; }
.option-btn.correct::after { content: "  ✓ correct"; font-weight: 600; font-size: 0.8rem; }
.option-btn.wrong::after { content: "  ✗ your answer"; font-weight: 600; font-size: 0.8rem; }
:root[data-theme="dark"] .option-btn.correct, :root:not([data-theme="light"]) .option-btn.correct { color: #4ade80; }
:root[data-theme="dark"] .option-btn.wrong, :root:not([data-theme="light"]) .option-btn.wrong { color: #f87171; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .option-btn.correct { color: #15803d; } :root:not([data-theme="dark"]) .option-btn.wrong { color: #b91c1c; } }
.socratic-exp { margin-top: 10px; padding: 10px 14px; border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--brand) 8%, var(--surface-2)); font-size: 0.9rem; line-height: 1.5; }
/* Quiz history list */
.qh-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.qh-row:first-child { border-top: 0; }
.qh-row:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.qh-topic { font-weight: 700; font-size: 0.9rem; }
.qh-meta { color: var(--muted); font-size: 0.78rem; }
.qh-score { font-weight: 800; font-size: 0.95rem; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.qh-score.good { color: #15803d; background: color-mix(in srgb, #16a34a 16%, transparent); }
.qh-score.mid  { color: #b45309; background: color-mix(in srgb, #f59e0b 18%, transparent); }
.qh-score.low  { color: #b91c1c; background: color-mix(in srgb, #dc2626 16%, transparent); }
.qh-empty { color: var(--muted); font-size: 0.85rem; }
/* Quiz review overlay */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(9, 13, 22, 0.62); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px; animation: rise .18s ease both; }
.modal { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(780px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.15rem; }
.qr-meta { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.modal-x { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; width: 36px; height: 36px;
  font-size: 1.4rem; line-height: 1; cursor: pointer; flex-shrink: 0; }
.modal-x:hover { border-color: var(--brand); color: var(--brand); }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; }
.qr-score { display: inline-block; font-weight: 800; padding: 4px 12px; border-radius: 999px; margin-left: 8px; }


.badge-howto { font-size: 0.75rem; color: var(--muted); line-height: 1.35; margin-top: 4px; }

.primary { background: var(--brand); color: var(--on-brand); border: none; border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 700; font-size: 0.88rem; transition: background 0.2s ease; }
.primary:hover { background: var(--brand-ink); }
.primary.small { padding: 6px 12px; font-size: 0.8rem; }
.msg { min-height: 20px; margin: 8px 0 0; font-size: 0.85rem; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.appearance { position: relative; }
.popover { position: absolute; right: 0; bottom: calc(100% + 8px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; width: 240px; z-index: 40; }
.swatch { width: 22px; height: 22px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--ink); transform: scale(1.15); }

/* ---- Flash cards + pair matching ---- */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.mode-btn { border: 0; background: transparent; padding: 6px 14px; font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--ink); }
.mode-btn.on { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.fc-stage { perspective: 1200px; display: flex; justify-content: center; margin: 10px 0; }
.fc-card { position: relative; width: 100%; max-width: 560px; min-height: 220px; border: 0; background: transparent; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s ease; font: inherit; color: inherit; padding: 0; }
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px; text-align: center;
  font-size: 1.15rem; line-height: 1.45; }
.fc-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--brand) 10%, var(--card)); }
.fc-tag { position: absolute; top: 10px; left: 14px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fc-hint { position: absolute; bottom: 10px; font-size: 0.75rem; color: var(--muted); }
.fc-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.fc-btn { padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font: inherit; font-weight: 700; color: var(--ink); }
.fc-btn.know { border-color: #16a34a; color: #15803d; }
.fc-btn.miss { border-color: #d97706; color: #b45309; }
.fc-btn:hover { filter: brightness(1.05); }
.fc-summary { margin-top: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { min-height: 84px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font: inherit;
  font-size: 0.85rem; color: var(--ink); text-align: center; transition: transform .15s ease, background .15s ease; }
.tile.front { font-weight: 700; }
.tile.selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--surface-2)); transform: scale(1.03); }
.tile.matched { border-color: #16a34a; background: color-mix(in srgb, #16a34a 18%, var(--surface-2)); color: #15803d; cursor: default; }
.tile.wrong { border-color: #dc2626; background: color-mix(in srgb, #dc2626 18%, var(--surface-2)); animation: tile-shake .3s; }
@keyframes tile-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .fc-card { transition: none; } .tile.wrong { animation: none; } }
.qh-mode { font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 14%, var(--card)); color: var(--brand); font-weight: 700; margin-left: 4px; vertical-align: middle; }
.fc-review { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px 14px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start; font-size: 0.9rem; }
.fc-review:first-child { border-top: 0; }
.fc-review .k { color: #15803d; font-weight: 700; } .fc-review .m { color: #b45309; font-weight: 700; }

/* ---- Consent status (Admin Dashboard) ---- */
.consent-ok { color: #15803d; font-weight: 700; }
.consent-bad { color: #b45309; font-weight: 700; }
.consent-step { margin-top: 10px; padding: 12px; border-radius: 10px; border: 1px solid #d97706; background: color-mix(in srgb, #d97706 10%, var(--card)); }
.consent-step .primary.small { margin-top: 8px; }
#members-table .consent-confirm { margin-left: 6px; padding: 3px 8px; font-size: 0.75rem; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); cursor: pointer; font-weight: 700; }

/* Home: level, next badge and the one nudge that matters */
.level-strip { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(8px); }
.level-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.level-badge { font-family: var(--display); font-weight: 800; font-size: 1rem; }
.level-xp { font-size: 0.78rem; opacity: 0.9; }
.level-bar { height: 10px; border-radius: 999px; background: rgba(0,0,0,0.25); overflow: hidden; }
.level-fill { height: 100%; border-radius: 999px; background: #fbbf24; transition: width 0.6s ease; }
.level-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 0.82rem; }
.next-badge { opacity: 0.95; }
.home-nudge { font-weight: 700; }
.streak-pill.at-risk { border-color: var(--warn); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25); }

/* Admin dashboard: learner progress cards */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.learner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.learner-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.learner-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.learner-name { font-weight: 800; font-family: var(--display); font-size: 1.02rem; }
.learner-sub { color: var(--muted); font-size: 0.78rem; }
.learner-stats { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.78rem; }
.learner-stats span { padding: 3px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.learner-subject { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 0.82rem; align-items: center; }
.learner-subject .mini-bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.learner-subject .mini-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.flag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: var(--warn-wash); color: var(--warn); }
.flag.ok { background: var(--brand-wash); color: var(--brand); }
.learner-toggle { align-self: flex-start; font-size: 0.8rem; font-weight: 700; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--ink); cursor: pointer; }
.learner-detail { border-top: 1px solid var(--line); padding-top: 10px; font-size: 0.82rem; display: grid; gap: 10px; }
.learner-detail table { width: 100%; border-collapse: collapse; }
.learner-detail th, .learner-detail td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.learner-detail th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.4px; }

/* Workspace summary tiles on the admin dashboard */
.pool-summary { display: flex; gap: 12px; flex-wrap: wrap; }
.pool-summary .stat { flex: 1 1 160px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
.pool-summary .stat .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.pool-summary .stat .v { font-weight: 700; margin-top: 2px; }
.dash-grid > .card { min-width: 0; overflow-x: auto; }

@media (max-width: 900px) {
  .section-header { flex-wrap: wrap; gap: 8px; }
  .dash-grid { grid-template-columns: 1fr; }
  .learner-grid { grid-template-columns: 1fr; }
  .learner-head { flex-wrap: wrap; }
}

/* Assignments: learner list on Home, and the "Set work" card on the dashboard */
.assigned-list { display: grid; gap: 10px; }
.assigned-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.assigned-item .t { font-weight: 700; }
.assigned-item .s { color: var(--muted); font-size: 0.8rem; }
.assigned-item.done { opacity: 0.75; }
.due-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; background: var(--brand-wash); color: var(--brand); margin-left: 6px; }
.due-pill.overdue { background: var(--warn-wash); color: var(--warn); }
.due-pill.done { background: rgba(5, 150, 105, 0.12); color: #059669; }
.setwork-form .setwork-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 8px 0; font-weight: 500; font-size: 0.86rem; }
.check-list label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.setwork-list { display: grid; gap: 10px; }
.setwork-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); display: grid; gap: 6px; }
.setwork-item .head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.setwork-item .learners { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.78rem; }
.setwork-item .learners span { padding: 3px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.setwork-item .learners span.done { border-color: #059669; color: #059669; }
.linkbtn { background: transparent; border: none; color: var(--muted); font-size: 0.8rem; cursor: pointer; text-decoration: underline; padding: 2px 4px; }

/* Photo capture: which attach buttons show where */
.touch-only { display: none !important; }
@media (pointer: coarse) { .touch-only { display: grid !important; } .pointer-only { display: none !important; } }
.capture-overlay { position: fixed; inset: 0; background: rgba(5, 6, 12, 0.6); display: grid; place-items: center; z-index: 60; padding: 16px; }
.capture-box { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.capture-box h3 { margin: 0; }
.capture-qr { background: #fff; border-radius: 12px; padding: 12px; display: grid; place-items: center; }
.capture-qr svg { width: 220px; height: 220px; }

/* Today's challenge */
.challenge-card { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.challenge-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.challenge-body .t { font-weight: 700; }
.challenge-body .s { color: var(--muted); font-size: 0.82rem; }

/* Model routing panel */
.routing-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.routing-table th, .routing-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.routing-table th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.4px; }
.routing-wrap { overflow-x: auto; }
.routing-rec { display: grid; gap: 6px; margin-bottom: 12px; font-size: 0.84rem; }
.routing-rec .seg { font-weight: 700; }
.routing-policy { color: var(--muted); font-size: 0.78rem; margin-top: 10px; }

/* Account: two-factor */
.mfa-setup { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .mfa-setup { grid-template-columns: 240px 1fr; align-items: start; } }
.mfa-qr { background: #fff; border-radius: 12px; padding: 10px; display: grid; place-items: center; }
.mfa-qr svg { width: 220px; height: 220px; }
.mfa-secret { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.85rem; letter-spacing: 0.08em; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.recovery-codes { columns: 2; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.95rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 8px 0; }
.recovery-codes div { break-inside: avoid; padding: 2px 0; }
.mfa-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Home (Design 1) */
.today-learning { margin-top: 16px; }
.today-learning .row { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-sm); margin-bottom: 6px; }
.today-learning .row strong { font-family: var(--display); font-size: var(--fs-md); }
.home-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin: 20px 0; }
.mastery-rows { display: grid; gap: 4px; }
.mastery-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.mastery-row:first-child { border-top: 0; padding-top: 0; }
.mastery-row .tile { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; grid-row: span 2; background: color-mix(in srgb, var(--subj, var(--brand)) 16%, var(--card)); }
.mastery-row .name { font-weight: 700; font-size: var(--fs-md); }
.mastery-row .lvl { color: var(--muted); font-size: var(--fs-xs); }
.mastery-row .pct { font-family: var(--display); font-weight: 800; font-size: var(--fs-lg); grid-row: span 2; }
.mastery-row .bar { grid-column: 2 / 3; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.mastery-row .bar > div { height: 100%; border-radius: 999px; background: var(--subj, var(--brand)); transition: width 0.4s ease; }
.docs-drop { border: 2px dashed color-mix(in srgb, var(--brand) 50%, var(--line)); background: var(--brand-wash); border-radius: var(--radius-sm); padding: 18px; text-align: center; cursor: pointer; }
.docs-drop .dd-icon { font-size: 1.8rem; margin-bottom: 4px; }
.docs-list { margin-top: 12px; display: grid; gap: 8px; }
.docs-list .doc { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.docs-list .doc .k { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.8rem; flex: none; }
.docs-list .doc .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.docs-list .doc .m { color: var(--muted); font-size: var(--fs-xs); }
.practice-preview .tabs { margin: 0; }
.pp-list { display: grid; gap: 8px; margin-top: 12px; }
.pp-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.pp-item .t { font-weight: 700; font-size: var(--fs-md); }
.pp-item .s { color: var(--muted); font-size: var(--fs-xs); }
.pp-q { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.pp-q .q { font-weight: 700; margin-bottom: 8px; }
.pp-q .opts { display: grid; gap: 6px; }
.pp-q .opt { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.pp-q .opt b { width: 22px; height: 22px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.72rem; }

/* Phone overrides for rules declared above (later wins) */
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; gap: 16px; }
  .tabs { flex-wrap: wrap; border-radius: 16px; overflow: visible; }
  .practice-preview .section-header { gap: 10px; }
  .mastery-row { grid-template-columns: 36px 1fr auto; }
  .mastery-row .tile { width: 36px; height: 36px; }
}

/* ---- Design pass phase 2 ---- */
/* Sidebar: chat history, new chat, collapse to an icon rail */
.sidebar-brand { position: relative; }
.collapse-btn { background: transparent; border: 1px solid var(--sidebar-line); color: var(--sidebar-muted); border-radius: 8px; width: 28px; height: 28px; font-size: 0.9rem; line-height: 1; }
.collapse-btn:hover { color: #fff; border-color: var(--sidebar-muted); }
.sidebar-section { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.sidebar-section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--sidebar-muted); font-weight: 700; padding: 0 12px; }
.sidebar-chats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; max-height: 220px; }
.sidebar-chats li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--sidebar-text); font-size: var(--fs-sm); cursor: pointer; }
.sidebar-chats li:hover { background: rgba(255,255,255,0.08); }
.sidebar-chats li.active { background: rgba(255,255,255,0.12); }
.sidebar-chats .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-chats .d { color: var(--sidebar-muted); font-size: var(--fs-xs); flex: none; }
.sidebar-chat-empty { color: var(--sidebar-muted); cursor: default !important; font-size: var(--fs-xs) !important; }
.sidebar-new-chat { width: 100%; background: var(--sidebar-card); color: #fff; border-color: var(--sidebar-line); margin-top: 4px; }
.sidebar-new-chat:hover { border-color: var(--brand); color: #fff; }
@media (min-width: 901px) {
  body.rail .sidebar { width: 72px; padding: 20px 10px; }
  body.rail .sidebar-search, body.rail .mode-badge, body.rail .brand-word, body.rail .nav-label, body.rail .sidebar-section,
  body.rail .appearance, body.rail .user-info > div, body.rail .user-card > .navbtn { display: none !important; }
  body.rail .navbtn { justify-content: center; padding: 10px 0; }
  body.rail .sidebar-brand { justify-content: center; gap: 6px; flex-direction: column; }
  body.rail .collapse-btn { transform: rotate(180deg); }
  body.rail .user-card { justify-content: center; padding: 8px; }
}
@media (max-width: 900px) { .collapse-btn { display: none; } }

/* Practice: mockup 2 quiz runner */
.quiz-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--brand); font-weight: 800; margin-bottom: 4px; }
.quiz-counter { font-weight: 700; color: var(--muted); font-size: var(--fs-sm); padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.option-btn { display: flex; align-items: center; gap: 12px; }
.option-btn .letter { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: var(--fs-xs); flex: none; }
.option-btn.selected .letter { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.option-btn.correct .letter { background: #16a34a; color: #fff; border-color: #16a34a; }
.option-btn.wrong .letter { background: #dc2626; color: #fff; border-color: #dc2626; }
.option-btn .txt { flex: 1; }
.option-btn.wrong .txt { text-decoration: line-through; }
.option-btn.wrong { text-decoration: none; }
.option-btn .mark { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.option-btn.correct::after, .option-btn.wrong::after { content: none; }
.quiz-q-title { display: flex; gap: 10px; align-items: baseline; }
.quiz-q-title .qn { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; flex: none; }

/* Tables (admin) */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; }
.table tr:last-child td { border-bottom: 0; }
.card > h3 { margin-bottom: 10px; }

/* Loading, empty and error states */
.skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, var(--card)), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; margin: 6px 0; }
.skeleton.w60 { width: 60%; } .skeleton.w40 { width: 40%; } .skeleton.w80 { width: 80%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.empty-state { text-align: center; padding: 22px 12px; color: var(--muted); font-size: var(--fs-md); }
.empty-state .big { font-size: 2rem; margin-bottom: 6px; }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 4px; }
.error-state { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 8%, var(--card)); font-size: var(--fs-sm); flex-wrap: wrap; }

/* Chat: the waiting state for a slow turn */
.bubble.thinking { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.bubble.thinking::after { content: none; animation: none; }
.thinking-line { display: flex; align-items: center; gap: 8px; font-style: normal; }
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: pulse 1.2s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 0.2s; } .thinking-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
.thinking-bar { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.thinking-bar > div { height: 100%; width: 3%; background: var(--brand); transition: width 1s linear; }
.thinking-note { color: var(--muted); font-size: var(--fs-xs); font-style: normal; }

/* Home hero stats: three tiles share the row on a phone instead of stacking */
@media (max-width: 600px) {
  .welcome-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-box { padding: 10px 8px; text-align: center; min-width: 0; }
  .stat-val { font-size: 1.25rem; }
  .stat-label { font-size: 0.62rem; letter-spacing: 0.3px; }
}

/* ---- Design pass 3: Flash Cards, Badges, Documents on the system ---- */
/* Flash cards: buttons and review rows on tokens instead of fixed greens */
.fc-card { min-height: 240px; }
.fc-face { border-radius: var(--radius); box-shadow: var(--shadow); }
.fc-btn { border-radius: var(--radius-sm); font-size: var(--fs-md); }
.fc-btn.know { border-color: var(--ok); color: var(--ok); background: var(--ok-wash); }
.fc-btn.miss { border-color: var(--warn); color: var(--warn); background: var(--warn-wash); }
.fc-review .k { color: var(--ok); } .fc-review .m { color: var(--warn); }
.tile.matched { border-color: var(--ok); background: var(--ok-wash); color: var(--ok); }
.tile.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); }
.fc-summary { border-radius: var(--radius-sm); }
#view-cards .tabs { margin-top: 10px; }

/* Badges: header with the next badge, grid on tokens */
.badge-head { display: flex; justify-content: space-between; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; margin-bottom: var(--space-4); }
.badge-head h2 { margin: 0 0 4px; }
.badge-head .sub { margin: 0; max-width: 520px; }
.badge-next { flex: 0 1 300px; min-width: 240px; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.badge-next .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.badge-next .t { font-weight: 800; margin: 2px 0 8px; }
.badge-next .s { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.progress-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width var(--motion); }
.badge-summary { margin: 0 0 var(--space-3); }
.badge-card { opacity: 1; background: var(--surface-2); border-style: dashed; }
.badge-card .badge-icon { filter: grayscale(1); opacity: 0.5; }
.badge-card.unlocked { border-style: solid; background: var(--card); }
.badge-card.unlocked .badge-icon { filter: none; opacity: 1; }
.badge-status.earned { color: var(--ok); }
.badge-status.locked { color: var(--muted); }
@media (max-width: 600px) { .badge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .badge-card { padding: 12px 8px; } .badge-next { flex-basis: 100%; } }

/* Documents: the drop zone on the shared component, the list as a table */
#drag-drop-zone-full.docs-drop { padding: var(--space-8) var(--space-5); margin-top: var(--space-3); }
#drag-drop-zone-full.docs-drop:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#drag-drop-zone-full.docs-drop.over { background: color-mix(in srgb, var(--brand) 22%, var(--card)); border-style: solid; }
.kb-table .t { font-weight: 700; white-space: normal; min-width: 160px; }
.kb-table .del { background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 10px; font-size: var(--fs-xs); color: var(--danger); cursor: pointer; }
.kind-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.kind-pill.pdf { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.kind-pill.docx { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.kind-pill.image { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.kind-pill.link { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
#view-upload .section-header { margin-top: var(--space-6); }

/* Flash cards: writing the answer (docs/DESIGN_SYSTEM.md) */
.fc-answer { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); }
.fc-answer input { flex: 1 1 260px; min-width: 0; padding: 12px 14px; font-size: var(--fs-md); color: var(--ink);
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--radius-sm); }
.fc-answer input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.fc-answer input:disabled { opacity: 0.7; }
.fc-answer .primary { padding: 12px 20px; }
.fc-verdict { margin-top: var(--space-3); padding: 10px 14px; border-radius: var(--radius-sm); font-size: var(--fs-md);
  font-weight: 600; text-align: center; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.fc-verdict.ok { border-color: var(--ok); background: var(--ok-wash); color: var(--ok); }
.fc-verdict.warn { border-color: var(--warn); background: var(--warn-wash); color: var(--warn); }
.fc-verdict.miss { border-color: var(--warn); background: var(--warn-wash); color: var(--ink); }
@media (max-width: 600px) { .fc-answer .linkbtn { flex-basis: 100%; text-align: center; } }

/* ---- Mathematics and diagrams ----------------------------------------
   A tutor writes maths in LaTeX and shapes as a small spec; public/shared/
   mathText.js turns the first into native MathML and public/shared/figure.js
   turns the second into an SVG. Both inherit the page's ink, so one rule set
   serves light and dark. */
math { font-size: 1.06em; }
.math-block { display: block; margin: var(--space-3) 0; text-align: center; overflow-x: auto; overflow-y: hidden; }
.math-raw { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
.figure { display: block; width: 100%; max-width: 300px; height: auto; margin: var(--space-3) 0; color: var(--ink); }
.figure-wrap { display: flex; justify-content: center; }
.fig-shape { fill: color-mix(in srgb, var(--brand) 14%, transparent); stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.fig-face-2 { fill: color-mix(in srgb, var(--brand) 26%, transparent); }
.fig-face-3 { fill: color-mix(in srgb, var(--brand) 7%, transparent); }
.fig-line { stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.fig-hidden { stroke: currentColor; stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .42; fill: none; }
.fig-grid { stroke: var(--line); stroke-width: 1; }
.fig-dot { fill: var(--brand); }
.fig-label { fill: var(--ink); font-family: var(--body); font-size: 13px; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .figure { transition: color var(--motion); } }
.fc-figure { margin-top: var(--space-2); }
.fc-figure .figure { max-width: 190px; margin: 0 auto; }
.quiz-q-card .figure-wrap { margin-bottom: var(--space-2); }
.pp-q .figure { max-width: 150px; }

/* ---- School pitch landing page (public/landing.html) ----------------
   Every rule is scoped to body.landing. The pitch page reuses class names
   the app also uses (.nav, .navbtn, .topbar, .brand, .card), and the app
   styles those for a dark sidebar, so without the scope the two fight and
   the page loses. Scoping also means nothing here can reach the app. */
body.landing .topbar { display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
body.landing .brand { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; }
body.landing .brand::before { content: "✦"; color: var(--accent); }
body.landing .nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
body.landing .navbtn { background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 11px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; }
body.landing .navbtn:hover { background: var(--surface-2); color: var(--ink); }
body.landing .navbtn.active { background: var(--brand-wash); color: var(--brand-ink); }
body.landing .navbtn.ghost { color: var(--muted); }
body.landing .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
body.landing .tab.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
body.landing .authform { display: flex; flex-direction: column; gap: 12px; }
body.landing .authform label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
body.landing .authform input,
body.landing .authform select { padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: 14px; }
body.landing .primary { background: var(--brand); color: var(--on-brand); border: none; border-radius: var(--radius-sm); padding: 11px 16px; font-weight: 700; font-size: 14px; }
body.landing .primary:hover { background: var(--brand-ink); }
body.landing .primary.small { padding: 8px 12px; font-size: 13px; }
body.landing .primary:disabled { opacity: .5; cursor: default; }
body.landing .mastery-bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
body.landing .algebra .mastery-bar-fill { background: var(--algebra-color); }
body.landing .biology .mastery-bar-fill { background: var(--biology-color); }
body.landing .chemistry .mastery-bar-fill { background: var(--chem-color); }
body.landing .option-btn,
body.landing .opt-btn { display: flex; align-items: center; width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 0.88rem; font-weight: 600; text-align: left; cursor: pointer; transition: all 0.2s ease; }
body.landing .option-btn:hover,
body.landing .opt-btn:hover { border-color: #3b82f6; background: #eff6ff; }
body.landing .option-btn.selected,
body.landing .opt-btn.selected { border-color: #3b82f6; background: #dbeafe; color: #1e40af; font-weight: 700; }
body.landing .option-btn.selected .opt-badge,
body.landing .opt-btn.selected .opt-badge { background: #3b82f6; color: #ffffff; border-color: #3b82f6; }
body.landing .option-btn.correct,
body.landing .opt-btn.correct { border-color: var(--ok); background: var(--ok-wash); color: var(--ok); font-weight: 700; }
body.landing .option-btn.wrong,
body.landing .opt-btn.wrong { border-color: var(--danger); background: var(--danger-wash); color: var(--danger); }
body.landing .quiz-tab-btn.active { color: #2563eb; }
body.landing .quiz-tab-btn.active::after { content: ""; position: absolute; bottom: -14px; left: 0; right: 0; height: 3px; background: #2563eb; border-radius: 999px; }
body.landing .primary { background: var(--brand); color: var(--on-brand); border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; font-size: 0.88rem; transition: background 0.2s ease; }
body.landing .primary:hover { background: var(--brand-hover); }
body.landing .primary.small { padding: 6px 12px; font-size: 0.8rem; }
body.landing .msg { min-height: 20px; margin: 8px 0 0; font-size: 0.85rem; }
body.landing .msg.error { color: var(--danger); }
body.landing .msg.ok { color: var(--ok); }
body.landing /* Appearance picker (top bar) */
.appearance { position: relative; }
body.landing .icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-size: 15px; }
body.landing .icon-btn:hover { background: var(--brand-wash); }
body.landing .popover { position: absolute; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 14px; width: 240px; z-index: 40; }
body.landing .popover h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; font-family: var(--body); font-weight: 700; }
body.landing .theme-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
body.landing .theme-toggle button { flex: 1; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 8px; padding: 7px 0; font-size: 12px; font-weight: 600; }
body.landing .theme-toggle button.on { background: var(--brand-wash); color: var(--brand-ink); border-color: transparent; }
body.landing #convo-list li:hover,
body.landing #convo-list li.active { background: var(--card); color: var(--ink); border-color: var(--line); }
body.landing .badge { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
body.landing .badge.locked { opacity: .5; }
body.landing .badge.locked .emoji { filter: grayscale(1); }
body.landing .badge .emoji { font-size: 34px; }
body.landing .badge .title { font-weight: 700; font-size: 13px; margin-top: 6px; }
body.landing .badge .desc { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
body.landing .option-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s ease;
}
body.landing .option-btn:hover {
  border-color: var(--brand);
  background: var(--brand-wash);
}
body.landing .option-btn.selected {
  border-color: var(--brand);
  background: var(--brand-wash);
  color: var(--brand-ink);
  font-weight: 600;
}
body.landing .option-btn.correct {
  border-color: var(--ok);
  background: var(--ok-wash);
  color: var(--ok);
  font-weight: 700;
}
body.landing .option-btn.wrong {
  border-color: var(--danger);
  background: var(--warn-wash);
  color: var(--danger);
}
body.landing .mastery-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.landing .mastery-topic { font-weight: 700; font-size: 14px; color: var(--ink); }
body.landing .mastery-sub { font-size: 11.5px; color: var(--muted); }
body.landing .mastery-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
body.landing .mastery-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .4s ease;
}
body.landing .skip-link {
  position: absolute; top: -40px; left: 0;
  background: var(--brand); color: var(--on-brand);
  padding: 8px 16px; z-index: 100;
  font-weight: 700; border-radius: 0 0 8px 0;
  transition: top .2s ease;
}
body.landing .skip-link:focus { top: 0; }
body.landing /* Pitch Navigation & Topbar */
.pitch-badge {
  background: var(--brand-wash);
  color: var(--brand-ink);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
body.landing .landing-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px 80px;
}
body.landing /* Hero Section */
.hero-section {
  padding: 60px 0 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
body.landing .hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.12;
  font-weight: 800;
  color: var(--ink);
  max-width: 900px;
  letter-spacing: -0.03em;
}
body.landing .hero-sub {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 740px;
  line-height: 1.6;
  margin: 0;
}
body.landing .cta-group {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
}
body.landing .btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
body.landing .btn-secondary:hover {
  background: var(--card);
  border-color: var(--brand);
  color: var(--brand-ink);
}
body.landing /* Trust Badges Bar */
.trust-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 10px;
  width: 100%;
}
body.landing .trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
body.landing .trust-icon {
  font-size: 16px;
  color: var(--ok);
}
body.landing /* Educator Safety Grid */
.section-header {
  text-align: center;
  margin: 60px 0 30px;
}
body.landing .section-header h2 {
  font-size: 2.1rem;
  color: var(--ink);
  margin-bottom: 10px;
}
body.landing .section-header p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 640px;
  margin: 0 auto;
}
body.landing .safety-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 20px;
}
body.landing .safety-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .2s ease, border-color .2s ease;
}
body.landing .safety-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}
body.landing .safety-card .card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-wash);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}
body.landing .safety-card h3 {
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0;
}
body.landing .safety-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}
body.landing /* Interactive Product Showcase */
.showcase-container {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 24px;
}
body.landing .showcase-nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  overflow-x: auto;
}
body.landing .showcase-tab {
  padding: 14px 20px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
body.landing .showcase-tab:hover {
  color: var(--ink);
  background: var(--card);
}
body.landing .showcase-tab.active {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
  background: var(--card);
}
body.landing .showcase-panel {
  padding: 28px;
}
body.landing /* Simulator Demo Panel */
.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 768px) {
body.landing .sim-grid { grid-template-columns: 1fr; }
}
body.landing .sim-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.landing .sim-box h4 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
body.landing .sim-chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}
body.landing /* Pricing Tiers (£ GBP UK Schools) */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 30px;
}
body.landing .pricing-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
}
body.landing .pricing-card.featured {
  border: 2px solid var(--brand);
  box-shadow: 0 10px 30px -10px rgba(79, 70, 229, 0.25);
}
body.landing .pricing-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}
body.landing .pricing-card h3 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}
body.landing .pricing-sub {
  font-size: 13px;
  color: var(--muted);
  min-height: 38px;
  margin-bottom: 16px;
}
body.landing .price-tag {
  font-size: 2.4rem;
  font-weight: 800;
  font-family: var(--display);
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
}
body.landing .price-unit {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
body.landing .pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
body.landing .pricing-features li {
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
body.landing .pricing-features li::before {
  content: "✓";
  color: var(--ok);
  font-weight: 800;
}
body.landing /* Modal Dialog */
.pitch-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 24, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 20px;
}
body.landing .pitch-modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow);
  position: relative;
}
/* The app styles .navbtn for its dark sidebar, where a nav button fills the
   width. The pitch page's nav is a horizontal row and the rule it inherits
   never set a width, so the sidebar's width:100% leaked through and every
   link took its own line. */
body.landing .navbtn { width: auto; text-align: center; }
body.landing .nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
/* The top bar is sticky, so an in-page anchor scrolls its target to y=0 and
   the bar then sits on top of it: every shortcut landed the reader just under
   the heading they asked for. Measured at 63px on the London page and 99px on
   the schools page, whose bar wraps; the clearance covers the taller of the
   two with room to breathe. Barely noticeable before the links were only a
   decoration on a phone, and the whole point of the menu now. */
body.landing section[id] { scroll-margin-top: 112px; }

/* The section shortcuts, which public/nav-menu.js wraps in .nav-links and
   gives a toggle. Above the breakpoint they are simply a row in the bar and
   the toggle is not rendered at all. */
body.landing .nav-links { display: flex; align-items: center; gap: 4px; }
body.landing .nav-toggle { display: none; }

@media (max-width: 760px) {
  /* The pitch badge does not fit beside the sign-in button on a phone: nowrap
     pushed the page wider than the screen, and wrapping it made a five-line
     pill. The hero says the same thing, so it goes.

     The section links used to go with it. That is fine for a page you scroll
     and wrong for one you are sent, so they fold into a menu instead: on a
     phone the shortcuts are the only way to reach Safeguarding or The pilot
     without scrolling past everything in between. */
  body.landing .pitch-badge { display: none; }
  body.landing .topbar { gap: 8px; }

  body.landing .nav-toggle {
    display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
    background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
    color: var(--ink); font-size: 1.1rem; line-height: 1; cursor: pointer;
  }
  body.landing .nav-toggle[aria-expanded="true"] { background: var(--surface-2); border-color: var(--brand); }

  body.landing .nav-links { display: none; }
  body.landing .nav-links.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px;
    /* Anchored to the sticky bar rather than to the nav, so the panel spans
       the screen instead of the few pixels the toggle occupies. */
    position: absolute; top: 100%; left: 0; right: 0;
    padding: 8px; background: var(--card); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow); z-index: 21;
  }
  body.landing .nav-links.open .navbtn {
    width: 100%; text-align: left; padding: 11px 12px; font-size: 15px;
  }
}

/* ---- Australian schools pitch (public/schools.html) ------------------
   Reuses the pitch-page components scoped to body.landing. Two differences:
   this page's headings are sentences rather than labels, so the shared
   50/50 split wraps them badly, and a principal reads it top to bottom
   rather than scanning, so the measure is narrower. */
body.schools .section-header { align-items: baseline; gap: 28px; }
body.schools .section-header h2 { flex: 1 1 60%; min-width: 0; }
body.schools .section-header p { flex: 1 1 34%; margin: 0; color: var(--muted); font-size: 15px; }
body.schools .card p, body.schools .safety-card p { max-width: 62ch; }
@media (max-width: 860px) {
  /* Stacked, because a two-column header at this width leaves four words a line. */
  body.schools .section-header { display: block; }
  body.schools .section-header p { margin-top: 6px; }
}
/* Attribution beside a citation. CC BY requires the credit where the work is
   used, so it is part of the citation rather than a separate page only. */
.citation-credit { color: var(--muted); font-size: 0.92em; }
.citation-credit a { color: inherit; text-decoration: underline; }

/* ---- Filing a document, and choosing which documents ground a session ----
   A document nobody has filed is a document nobody can build a quiz from, so
   the subject/topic fields sit beside the drop zone rather than behind a
   dialog, and the table lets an adult correct the classifier in place. */
.doc-filing { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.doc-filing label { flex: 1 1 200px; display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.doc-filing select, .doc-filing input {
  width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 400;
}
.kb-table .file-subject, .kb-table .file-topic {
  max-width: 170px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-sm);
}
.kb-table .file-subject:hover, .kb-table .file-topic:hover,
.kb-table .file-subject:focus, .kb-table .file-topic:focus {
  border-color: var(--line); background: var(--surface-2); outline: none;
}
.kb-table .file-topic::placeholder { color: var(--muted); font-style: italic; }

.doc-picker { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 12px; margin: 0 0 14px; max-height: 220px; overflow-y: auto; }
.doc-pick { display: flex; align-items: baseline; gap: 8px; padding: 5px 2px; font-size: var(--fs-sm); cursor: pointer; }
.doc-pick input { flex: none; margin: 0; }
.doc-pick .t { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-pick .f { color: var(--muted); font-size: var(--fs-xs); margin-left: auto; flex: none; padding-left: 10px; }

/* "Grounded in …" — a claim of grounding is worth nothing without the list,
   so the learner sees which of their own documents the work came from. */
.grounded { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; font-size: var(--fs-xs); }
.grounded .g-head { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.grounded .g-doc {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--ok-wash); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  color: var(--ink); font-weight: 600;
}
.grounded .g-doc .g-filing { color: var(--muted); font-weight: 400; }

/* Learning context: which packs and documents a child's tutor may draw on. */
.ctx-h { margin: 18px 0 2px; font-size: var(--fs-md); font-weight: 700; }
.ctx-list { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px 12px; max-height: 200px; overflow-y: auto; }
.ctx-pick { display: flex; align-items: baseline; gap: 8px; padding: 5px 2px; font-size: var(--fs-sm); cursor: pointer; }
.ctx-pick input { flex: none; margin: 0; }
.ctx-pick .t { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-pick .f { color: var(--muted); font-size: var(--fs-xs); margin-left: auto; flex: none; padding-left: 10px; }
#ctx-card select { width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: inherit; }
#ctx-card > div > label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }

/* ---- Upload progress: a scholar walking the document across ----
   Two phases, because only one of them is knowable. The transfer has a real
   percentage (XHR reports it; fetch cannot report upload progress at all).
   What happens next — extract, chunk, embed, encrypt — has no progress signal
   at all, and for a long document it is the slow part. Showing a percentage
   there would be a fiction, so the scholar simply keeps walking. */
.upload-progress { margin: 14px 0 4px; }
.scholar-track { position: relative; height: 30px; }
.scholar {
  position: absolute; left: 0; bottom: 0; font-size: 1.35rem; line-height: 1;
  transition: left 0.35s ease-out; transform-origin: 50% 100%;
}
.upload-progress.busy .scholar { animation: scholar-step 0.55s ease-in-out infinite alternate; }
/* Nothing to measure: pace the length of the bar instead of faking a number. */
.upload-progress.indeterminate .scholar { transition: none; animation: scholar-stroll 3.4s ease-in-out infinite alternate, scholar-step 0.55s ease-in-out infinite alternate; }
@keyframes scholar-step { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-3px) rotate(4deg); } }
@keyframes scholar-stroll { from { left: 0; } to { left: calc(100% - 26px); } }

.scholar-bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.scholar-fill { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width 0.35s ease-out; }
.upload-progress.indeterminate .scholar-fill {
  width: 40%; background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: scholar-sweep 3.4s ease-in-out infinite;
}
@keyframes scholar-sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.scholar-phase { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .upload-progress .scholar, .upload-progress .scholar-fill { animation: none !important; transition: none; }
  .upload-progress.indeterminate .scholar-fill { width: 100%; background: var(--brand); opacity: 0.45; }
}

/* ---- Pilot console (operator) ----
   Plain on purpose. Five numbers and a bar per day do not justify a charting
   library that then has to be kept alive across upgrades forever. */
.op-totals { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.op-stat { flex: 1 1 130px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.op-stat .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.op-stat .v { font-size: 1.5rem; font-weight: 800; margin-top: 2px; }

.op-daily { display: flex; align-items: flex-end; gap: 2px; height: 68px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.op-bar { flex: 1 1 auto; min-width: 3px; background: var(--brand); border-radius: 2px 2px 0 0; opacity: 0.75; }
.op-bar:hover { opacity: 1; }
.op-models { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: var(--fs-sm); }

.op-enq.done { opacity: 0.55; }

.op-minted { margin: 0 0 16px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--ok-wash); border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line)); }
.op-code-value { font-family: var(--mono, ui-monospace, monospace); font-size: 1.5rem; font-weight: 800;
  letter-spacing: 0.06em; user-select: all; color: var(--ink); }
.op-minted .primary { margin-top: 10px; }

@media (max-width: 600px) {
  .op-stat { flex: 1 1 100%; }
}

/* The invitation the operator is about to send, ready to paste. */
.op-invite { width: 100%; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); resize: vertical; }

/* ---- Chat on a phone -------------------------------------------------
   .chat-shell is a flex row with a fixed 240px conversation column. On a
   390px screen that leaves about 100px for the conversation itself: the
   learner's own bubble ran off the right edge and the Send button was
   clipped off the screen entirely. Measuring document scrollWidth missed it,
   because .chat-shell has overflow:hidden — the page did not scroll, it
   just cut the app off.

   The column goes, rather than stacking: the chat history is already in the
   main sidebar drawer under "Chat history", so keeping a second copy here
   costs a quarter of a phone screen to say the same thing twice. */
@media (max-width: 900px) {
  .chat-shell {
    /* Fill the screen below the header rather than guessing 140px of chrome,
       and use dvh so the iOS URL bar collapsing does not hide the composer. */
    height: calc(100dvh - 132px); min-height: 0; border-radius: var(--radius-sm);
  }
  .chat-shell .convos { display: none; }
  .chat-main { min-width: 0; }              /* or flex children refuse to shrink */
  .messages { padding: 14px 12px; gap: 10px; }
  .bubble { max-width: 88%; }               /* 78% of a narrow screen is a column of single words */

  .chat-input { padding: 10px; gap: 6px; flex-wrap: nowrap; }
  .chat-input textarea { min-width: 0; font-size: 16px; }  /* 16px: anything smaller makes iOS zoom on focus */
  .chat-input .icon-btn { flex: none; width: 34px; }
  .chat-input button.primary { flex: none; padding: 10px 14px; }
}
