/* StudyQuest parent section (SQ-039 redesign).
   Design tokens first; every colour below comes from them, so dark mode only swaps the tokens. */
:root {
  --font: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bg: #F5F6F8; --surface: #FFFFFF; --surface-2: #F8FAFC; --sunken: #F1F5F9;
  --ink: #0F172A; --ink-2: #334155; --muted: #64748B; --line: #E5E7EB; --line-2: #F1F5F9; --field: #CBD5E1;
  --accent: #4338CA; --accent-hover: #3730A3; --accent-ink: #FFFFFF; --accent-soft: #EEF2FF; --accent-text: #3730A3;
  --good: #166534; --good-soft: #DCFCE7; --good-solid: #16A34A;
  --warn: #92400E; --warn-soft: #FEF3C7; --warn-solid: #F59E0B; --warn-line: #FDE68A; --warn-bg: #FFFBEB;
  --bad: #991B1B; --bad-soft: #FEE2E2; --bad-solid: #DC2626; --bad-text: #B42318; --bad-line: #FECACA; --bad-bg: #FEF2F2;
  --radius: 14px; --radius-sm: 10px; --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08); --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08); --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.28);
  --focus: 0 0 0 3px rgba(67, 56, 202, 0.35);
  --side-w: 244px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1020; --surface: #121829; --surface-2: #161D31; --sunken: #1B2338;
    --ink: #E5E7EB; --ink-2: #CBD5E1; --muted: #94A3B8; --line: #253047; --line-2: #1C2539; --field: #3A465E;
    --accent: #6366F1; --accent-hover: #818CF8; --accent-soft: #1E1B4B; --accent-text: #C7D2FE;
    --good: #86EFAC; --good-soft: #0B2E1B; --good-solid: #22C55E;
    --warn: #FCD34D; --warn-soft: #3A2A05; --warn-solid: #F59E0B; --warn-line: #5C4307; --warn-bg: #2A1F06;
    --bad: #FCA5A5; --bad-soft: #3B0D12; --bad-solid: #EF4444; --bad-text: #F87171; --bad-line: #5B1B22; --bad-bg: #2A0E13;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
    --focus: 0 0 0 3px rgba(129, 140, 248, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); font-weight: 500; font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.12rem; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 800; }
h4 { font-size: 0.95rem; font-weight: 700; margin-top: 14px; }
p { margin: 0.35em 0; }
a { color: var(--accent-text); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.error { color: var(--bad-text); font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
code { background: var(--sunken); border-radius: 6px; padding: 1px 7px; font-size: 0.9em; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { display: inline-block; flex: none; vertical-align: middle; }

/* ---------- controls ---------- */
.btn, button.btn {
  font: inherit; font-weight: 700; font-size: 0.95rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--field); }
.btn.secondary:hover { background: var(--sunken); }
.btn.ghost { background: transparent; color: var(--accent-text); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--surface); color: var(--bad-text); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad-solid); color: #fff; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.86rem; }
.btn.icon { width: 44px; padding: 0; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--field);
  border-radius: var(--radius-sm); min-height: 44px; padding: 0 12px; width: 100%;
}
textarea { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.4; }
select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 0.9rem; }
.field .hint { font-weight: 500; color: var(--muted); font-size: 0.82rem; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 36px; cursor: pointer; }

/* segmented control */
.seg { display: inline-flex; background: var(--sunken); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 700; font-size: 0.9rem; min-height: 38px; border: 0; background: transparent; border-radius: var(--radius-xs); padding: 0 14px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
/* toggle switch */
.toggle { width: 48px; height: 28px; border-radius: 99px; background: var(--field); border: 0; position: relative; cursor: pointer; flex: none; padding: 0; transition: background 0.15s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: left 0.15s; }
.toggle[aria-checked=true] { background: var(--accent); }
.toggle[aria-checked=true]::after { left: 23px; }
/* stepper */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--field); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); height: 44px; flex: none; }
.stepper button { width: 44px; border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.stepper button:hover { background: var(--sunken); }
.stepper input { width: 60px; border: 0; border-radius: 0; text-align: center; font-weight: 800; padding: 0; min-height: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 99px; font-size: 0.78rem; font-weight: 700; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h .end { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1180px) { .split, .grid2 { grid-template-columns: minmax(0, 1fr); } }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
details.help { color: var(--muted); font-size: 0.86rem; }
details.help summary { cursor: pointer; font-weight: 700; color: var(--accent-text); display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
details.help[open] summary { margin-bottom: 4px; }
details summary { cursor: pointer; }
.note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 14px; }
.note.info { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.note.bad { background: var(--bad-bg); border-color: var(--bad-line); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-variant-numeric: tabular-nums; }
tr:last-child > td { border-bottom: 0; }
td.correct, li.correct { color: var(--good); font-weight: 800; }
table.units .urow { cursor: pointer; }
table.units .urow:hover > td { background: var(--surface-2); }
table.units th.grp { background: var(--surface-2); color: var(--muted); }
.udetail > td { background: var(--surface-2); padding: 6px 12px 12px; }
.udetail table td { border-bottom-color: var(--line); }
.bar { display: inline-block; height: 8px; width: 100%; min-width: 70px; max-width: 180px; border-radius: 99px; background: var(--sunken); overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- sign in and first setup ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; }
.auth-aside { background: #1E1B4B; color: #fff; padding: 52px 48px; display: flex; flex-direction: column; gap: 28px; }
.auth-aside .lead { font-size: 2rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; margin-top: 48px; }
.auth-aside .point { display: flex; gap: 12px; color: #C7D2FE; }
.auth-aside .point b { color: #fff; display: block; }
.auth-aside .pi { width: 38px; height: 38px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.12); display: flex; align-items: center; justify-content: center; flex: none; }
.auth-aside .foot { margin-top: auto; font-size: 0.84rem; color: #A5B4FC; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { font-size: 1.75rem; }
.auth-box .sub { color: var(--muted); margin: 6px 0 22px; }
.auth-box .btn { width: 100%; min-height: 50px; }
.pw { position: relative; display: flex; }
.pw input { padding-right: 76px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 34px; border: 0; background: var(--sunken); color: var(--ink-2); border-radius: var(--radius-xs); font: inherit; font-size: 0.82rem; font-weight: 700; padding: 0 10px; cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.auth-aside .logo { background: #6366F1; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { padding: 24px; gap: 12px; }
  .auth-aside .lead { font-size: 1.3rem; margin-top: 8px; }
  .auth-aside .point, .auth-aside .foot { display: none; }
}

/* ---------- shell: sidebar, rail, drawer ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; z-index: 30; }
.side .brand { padding: 2px 10px 16px; }
.side .tagline { margin-left: auto; }
.side .sec { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; font-weight: 800; }
.side .brand + .sec { padding-top: 2px; }
.nav { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 600; text-decoration: none; position: relative; }
.nav:hover { background: var(--sunken); text-decoration: none; }
.nav[aria-current=page] { background: var(--accent-soft); color: var(--accent-text); }
.nav .badge { margin-left: auto; background: var(--warn-soft); color: var(--warn); font-size: 0.74rem; border-radius: 99px; padding: 1px 8px; font-weight: 800; }
.nav .badge.n { background: var(--sunken); color: var(--ink-2); }
.side .spacer { flex: 1; min-height: 12px; }
.side .who { border-top: 1px solid var(--line); margin-top: 8px; padding: 14px 6px 0; display: flex; align-items: center; gap: 10px; }
.side .who .t { flex: 1; min-width: 0; }
.side .who .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .titles { min-width: 0; flex: 1 1 220px; }
.topbar .titles .muted { font-size: 0.88rem; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topbar .menu-btn { display: none; }
.page { padding: 24px 28px 56px; width: 100%; max-width: 1280px; }
.scrim { display: none; }

@media (min-width: 701px) and (max-width: 1100px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: 16px 10px; align-items: center; }
  .side .brand { padding: 0 0 14px; }
  .side .brand .name, .side .tagline, .side .sec, .nav .lbl, .side .who .t { display: none; }
  .side .sec + .nav, .side .nav.first-of-sec { margin-top: 10px; }
  .nav { width: 54px; height: 50px; justify-content: center; padding: 0; }
  .nav .badge { position: absolute; top: 4px; right: 2px; margin: 0; font-size: 0.68rem; padding: 0 5px; }
  .side .who { flex-direction: column; padding: 12px 0 0; border-top: 0; }
}
@media (max-width: 700px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-102%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s; z-index: 50; }
  .shell.menu-open .side { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 40; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; min-height: 60px; position: static; }
  .page { padding: 16px 16px 48px; }
  .grid2, .split { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.25rem; }
  .card { padding: 16px; }
}

/* ---------- overview ---------- */
.attn { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.attn a { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500; }
.attn a:hover { border-color: var(--accent); }
.attn .ib { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex: none; }
.attn .ib.warn { background: var(--warn-soft); color: var(--warn); }
.attn .ib.info { background: var(--accent-soft); color: var(--accent-text); }
.attn .ib.bad { background: var(--bad-soft); color: var(--bad); }
.attn .ib.good { background: var(--good-soft); color: var(--good); }
.attn b { display: block; }
.attn .go { margin-left: auto; color: var(--accent-text); font-weight: 700; }
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
@media (max-width: 700px) { .kids { grid-template-columns: minmax(0, 1fr); } }
.kid { display: flex; flex-direction: column; gap: 16px; }
.kid-h { display: flex; align-items: center; gap: 12px; }
.kid-h .end { margin-left: auto; }
.kid .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 480px) { .kid .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi b small { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.kpi span { font-size: 0.82rem; color: var(--muted); }
.kpi.alert b { color: var(--bad-text); }
.kpis.boxed .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpis.boxed .kpi.alert { background: var(--bad-bg); border-color: var(--bad-line); }
.rbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--sunken); gap: 2px; }
.rbar i { display: block; height: 100%; }
.c-good { background: var(--good-solid); } .c-warn { background: var(--warn-solid); } .c-bad { background: var(--bad-solid); } .c-none { background: var(--field); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; }
/* Progress › Exam readiness: one collapsible block per exam, with summary figures in its header. */
.rd-exam { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 12px; background: var(--surface); }
.rd-exam > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: grid; gap: 10px; border-radius: var(--radius-sm); }
.rd-exam > summary::-webkit-details-marker { display: none; }
.rd-exam > summary:hover { background: var(--surface-2); }
.rd-exam[open] > summary { border-bottom: 1px solid var(--line-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rd-exam > .table-wrap { padding: 4px 16px 14px; }
.rd-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rd-top h3 { margin: 0; }
.rd-chev { display: inline-flex; color: var(--muted); transform: rotate(180deg); transition: transform .15s; }
.rd-exam[open] .rd-chev { transform: rotate(-90deg); }
.rd-figs { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.86rem; color: var(--muted); }
.rd-figs b { color: var(--ink); font-size: 0.95rem; margin-right: 2px; }
.rd-figs .warnline, .rd-figs .warnline b { color: var(--warn); }
.rd-figs .error, .rd-figs .error b { color: var(--bad-text); }
.tl { list-style: none; margin: 0; padding: 0; }
.tl > li { border-top: 1px solid var(--line-2); padding: 10px 0; }
.tl > li:first-child { border-top: 0; }
.tl .h { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl details { margin-top: 4px; }
.tl details summary { color: var(--accent-text); font-weight: 700; font-size: 0.84rem; }
.tl .how { display: grid; gap: 4px; margin-top: 6px; font-size: 0.88rem; }

/* ---------- progress ---------- */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.subj { font: inherit; text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.subj:hover { border-color: var(--accent); }
.subj[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.subj b { font-size: 1rem; }
.subj .bar { max-width: none; }
.subj span { font-size: 0.82rem; color: var(--muted); }
.subj .open { color: var(--bad-text); font-weight: 700; }
.struggle { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 10px; }
.study { background: var(--warn-bg); border-radius: var(--radius-xs); padding: 8px 12px; margin: 8px 0; font-size: 0.9rem; }
.evid td.correct { color: var(--good); }
.evid td.error { color: var(--bad-text); }

/* ---------- questions ---------- */
.qtabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: -24px -28px 16px; padding: 0 28px; background: var(--surface); }
.qtabs button { font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; min-height: 50px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
.qtabs button[aria-selected=true] { color: var(--accent-text); border-bottom-color: var(--accent); }
@media (max-width: 700px) { .qtabs { margin: -16px -16px 14px; padding: 0 8px; } }
.filters { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(200px, 1.4fr); gap: 10px; margin-bottom: 12px; }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr; } }
.search { position: relative; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.bulkbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.ld { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 480px; overflow: hidden; }
.ld-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 250px); min-height: 480px; }
.ld-detail { padding: 20px 24px; min-width: 0; }
.ld .ld-back { display: none; }
.qi { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 12px 16px; cursor: pointer; }
.qi:hover { background: var(--surface-2); }
.qi[aria-current=true] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.qi .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qi .m { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.qi.done { opacity: 0.65; }
.qmeta { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.qprompt { font-size: 1.15rem; font-weight: 700; margin: 6px 0 14px; white-space: pre-wrap; }
.opts { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.opts li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.opts li .k { width: 28px; height: 28px; border-radius: 50%; background: var(--sunken); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; flex: none; }
.opts li.correct { border-color: var(--good-solid); background: var(--good-soft); color: var(--ink); font-weight: 600; }
.opts li.correct .k { background: var(--good-solid); color: #fff; }
.opts li .end { margin-left: auto; }
.passage { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px; white-space: pre-wrap; }
.passage summary { font-weight: 700; }
.qsvg { display: flex; justify-content: center; margin: 8px 0 14px; padding: 10px; background: #fff; border-radius: var(--radius-sm);
  --brand: #2F6FDE; --ink: #161B26; --card: #FFFFFF; --line: #E1E5EC; --bad: #A8182B; --warn-soft: #FFF3D6; color: #161B26; }
.qsvg svg { max-width: 100%; height: auto; max-height: 260px; }
.sample { border-top: 1px solid var(--line-2); padding-top: 12px; margin-top: 12px; }
.qactions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line-2); padding-top: 14px; margin-top: 14px; }
@media (max-width: 900px) {
  .ld { grid-template-columns: minmax(0, 1fr); }
  .ld-list { border-right: 0; max-height: none; min-height: 0; }
  .ld .ld-detail { display: none; }
  .ld.show-detail .ld-list { display: none; }
  .ld.show-detail .ld-detail { display: block; }
  .ld .ld-back { display: inline-flex; margin-bottom: 10px; }
}

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 92px; }
.subnav a { min-height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 600; border: 1px solid transparent; }
.subnav a:hover { background: var(--sunken); text-decoration: none; }
.subnav a[aria-current=page] { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
@media (max-width: 1100px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .subnav { position: static; flex-direction: row; overflow-x: auto; }
  .subnav a { white-space: nowrap; }
}
.sec-h { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-h .end { margin-left: auto; }
.setting-card { padding: 0; overflow: hidden; }
.setting-card .head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; }
.setting { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.setting .t { flex: 1; min-width: 0; }
.setting .t b { display: block; font-weight: 700; }
.setting .t span { display: block; font-size: 0.84rem; color: var(--muted); }
.setting .warnline { color: var(--warn); font-weight: 700; }
@media (max-width: 560px) { .setting { flex-wrap: wrap; } }
.danger-zone { border-color: var(--bad-line); }

/* ---------- connector chat examples ---------- */
.chat-examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 12px 0 6px; }
.chat-ex { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.chat-tag { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bubble { padding: 9px 12px; border-radius: 14px; line-height: 1.4; font-weight: 600; font-size: 0.92rem; max-width: 92%; }
.bubble.you { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; font-weight: 500; }
.steps { margin: 6px 0 4px; padding-left: 1.3em; }
.steps li { margin: 4px 0; }
.copyrows { display: grid; gap: 8px; margin: 4px 0 16px; }
.copyrow { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.copyrow code { font-size: .95rem; padding: 8px 12px; word-break: break-all; min-width: 0; }
.connect-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }
.connect-opt { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.connect-opt h4 { margin: 0; font-size: 1.05rem; }
.connect-opt p { margin: 0; }
.connect-opt .copyrow { grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
.connect-opt .copyrow > span { display: none; }
.connect-opt details.help { width: 100%; }
@media (max-width: 700px) { .copyrow { grid-template-columns: minmax(0, 1fr) auto; } .copyrow > span { grid-column: 1 / -1; } }
.copybox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copybox code { font-size: 1rem; padding: 8px 12px; word-break: break-all; }

/* messages */
.tpls { display: flex; gap: 8px; flex-wrap: wrap; }
.tpls button { font: inherit; font-size: 0.86rem; font-weight: 600; border: 1px solid var(--field); background: var(--surface); color: var(--ink); border-radius: 99px; min-height: 36px; padding: 0 14px; cursor: pointer; }
.tpls button:hover { border-color: var(--accent); }

/* ---------- dialogs and toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; animation: fade 0.12s ease; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; max-width: 480px; width: 100%; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; animation: pop 0.14s ease; }
.modal h2 { font-size: 1.2rem; }
.modal .body { color: var(--ink-2); }
.modal .btns { justify-content: flex-end; margin-top: 4px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 120; pointer-events: none; }
.toast { background: #0F172A; color: #fff; border-radius: 12px; padding: 12px 16px; font-weight: 700; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow-lg); animation: pop 0.16s ease; max-width: min(420px, calc(100vw - 40px)); }
.toast.bad { background: var(--bad-solid); }
@media (prefers-color-scheme: dark) { .toast { background: #F8FAFC; color: #0F172A; } }
@keyframes pop { from { transform: translateY(6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.loading { color: var(--muted); padding: 32px 0; text-align: center; }
/* SQ-048: readiness, one row per section (status, reason, next step; a bar of its questions and one line of figures). */
.rd-list { list-style: none; margin: 0; padding: 4px 16px 10px; }
.rd-sec { display: grid; gap: 8px 24px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.rd-sec:first-child { border-top: 0; }
.rd-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-why { margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-2); }
.rd-next { margin: 4px 0 0; padding: 0; list-style: none; font-size: 0.86rem; font-weight: 600; color: var(--accent-text); }
.rd-next li::before { content: "→ "; }
.rd-side { display: grid; gap: 6px; align-content: start; }
.rbar.sm { height: 8px; }
.rd-nums { font-size: 0.8rem; color: var(--muted); }
.rd-nums .error { color: var(--bad-text); font-weight: 700; }
.pill.quiet { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
@media (min-width: 760px) { .rd-sec { grid-template-columns: minmax(0, 1fr) 260px; } .rd-side { padding-top: 4px; } }

/* SQ-055: parent section quick wins. The children come first, each with one status sentence; red only for "act now". */
.status-line { margin: 0; font-size: 1.02rem; font-weight: 700; line-height: 1.35; color: var(--ink); }
.status-line.bad { color: var(--bad-text); }
.status-line.warn { color: var(--warn); }
.status-line.good { color: var(--good); }
.cap { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.kid > div > .cap { display: block; margin-bottom: 4px; }
.c-accent { background: var(--accent); }
.tl .h { align-items: center; }
.tl-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 0.75rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tl .tl-sub { margin-left: 32px; }
.kid-acts { margin-top: auto; align-items: center; }
.kid-acts .end, .link-go.end { margin-left: auto; }
.link-go { font-weight: 800; white-space: nowrap; }
.owner-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--sunken); color: var(--ink-2); font-size: 0.9rem; }
.owner-line .ico { color: var(--muted); flex: none; }
.kpis.boxed .kpi.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.kpi.warn b { color: var(--warn); }
.kpi .kbar { margin-top: 6px; max-width: none; }
.warnline { color: var(--warn); font-weight: 700; }
.subj .open { color: var(--warn); }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 700; cursor: pointer; }
.linkbtn[aria-pressed=true] { text-decoration: underline; }
.tl .kind { font-weight: 700; color: var(--ink-2); }
.tl .kind.warn { color: var(--warn); }
.tl .kind.info { color: var(--accent-text); }
@media (max-width: 600px) { .topbar .hide-phone { display: none; } }

/* SQ-056: trends. Practice days are shaded green by amount against the child's own goal; a missed day is grey, never red. */
.d0 { background: var(--sunken); color: var(--muted); }
.d1 { background: color-mix(in srgb, var(--good-solid) 25%, var(--sunken)); color: var(--good); }
.d2 { background: color-mix(in srgb, var(--good-solid) 55%, var(--sunken)); color: var(--good); }
.d3 { background: var(--good-solid); color: #fff; }
.wstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.wstrip .wd { display: grid; justify-items: center; gap: 3px; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.wstrip b { width: 100%; max-width: 40px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.74rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.wstrip b.d2 { color: var(--ink); }
.wstrip b.now { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.heat { display: grid; grid-template-columns: auto repeat(7, minmax(0, 1fr)); gap: 5px; align-items: center; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.heat > span:not(:first-child) { text-align: center; }
.heat b { display: block; aspect-ratio: 1; max-height: 34px; border-radius: 6px; }
.heat > span:nth-child(9n+10), .heat > span:nth-child(9) { padding-right: 6px; white-space: nowrap; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .end { margin-left: auto; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ch-g { stroke: var(--line); stroke-width: 1; }
.chart .ch-t { fill: var(--muted); font-size: 10px; font-weight: 700; font-family: var(--font); }
.chart .ch-v { fill: var(--ink); font-size: 12px; font-weight: 800; font-family: var(--font); }
.lchart { max-width: 460px; margin: 8px 0; }

/* SQ-057: drill-down pages (child, subject, section). Lists of links instead of wide tables, so they fit a phone. */
.kdot { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; flex: none; }
.slist { list-style: none; margin: 0; padding: 0; }
.slist > li { border-top: 1px solid var(--line-2); }
.slist > li:first-child { border-top: 0; }
.slist > li.grp { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); padding: 14px 0 4px; border-top: 0; }
.slist a { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto 12px; gap: 6px 14px; align-items: center; padding: 11px 4px; color: var(--ink); font-weight: 500; text-decoration: none; border-radius: 8px; }
.slist a:hover { background: var(--surface-2); }
.slist a:focus-visible { box-shadow: var(--focus); outline: none; }
.slist .sl-n, .slist .sl-f, .slist .sl-c { display: grid; gap: 2px; min-width: 0; }
.slist .sl-c .bar { max-width: 140px; }
.slist .chev { color: var(--muted); font-weight: 800; }
.card .slist a { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto 12px; }
.card .slist a:has(.sl-f) { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto 12px; }
@media (max-width: 760px) {
  .slist a, .card .slist a, .card .slist a:has(.sl-f) { grid-template-columns: minmax(0, 1fr) auto 12px; }
  .slist .sl-f, .slist .sl-c { grid-column: 1; }
  .slist .pill { grid-row: 1; grid-column: 2; }
  .slist .chev { grid-row: 1; grid-column: 3; }
}
.kpis.boxed.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
details.card.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card.fold > summary::-webkit-details-marker { display: none; }
details.card.fold > summary::before { content: '›'; font-weight: 800; color: var(--muted); transition: transform 0.15s; }
details.card.fold[open] > summary::before { transform: rotate(90deg); }
details.card.fold[open] > summary { margin-bottom: 10px; }
table.qrows td { vertical-align: top; padding: 10px 8px; border-top: 1px solid var(--line-2); }
.topbar .titles .muted a { font-weight: 700; }
.rd-more { list-style: none; padding: 10px 0 0; }
.rd-more > details > summary { cursor: pointer; color: var(--accent-text); font-weight: 700; font-size: 0.9rem; }
.rd-more > details[open] > summary { margin-bottom: 6px; }
details.more > summary { cursor: pointer; color: var(--accent-text); font-weight: 700; font-size: 0.9rem; padding: 8px 0; }
