/* PathQ — phone-first. Same palette as the RadsExam site (styles.css). */
:root {
  --plane: #f9f9f7; --surface: #fcfcfb; --surface-2: #f2f1ed;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #77756f;
  --line: #e1e0d9; --line-strong: #c3c2b7;
  --accent: #2a78d6; --accent-ink: #fff; --accent-soft: rgba(42,120,214,0.10);
  --good: #0a7d0a; --good-soft: rgba(12,163,12,0.12);
  --bad: #c2312f; --bad-soft: rgba(208,59,59,0.11);
  --warn: #9a6400; --warn-soft: rgba(250,178,25,0.18);
  --radius: 12px; --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(11,11,11,0.05), 0 8px 24px rgba(11,11,11,0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs: 17px;
  --tabbar: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #fff; --ink-2: #c3c2b7; --muted: #9a9890;
    --line: #2c2c2a; --line-strong: #3d3d3a;
    --accent: #4a92ea; --accent-soft: rgba(57,135,229,0.18);
    --good: #4cc94c; --good-soft: rgba(76,201,76,0.15);
    --bad: #ff6b66; --bad-soft: rgba(255,107,102,0.14);
    --warn: #f5b93a; --warn-soft: rgba(245,185,58,0.16);
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 28px rgba(0,0,0,0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #fff; --ink-2: #c3c2b7; --muted: #9a9890;
  --line: #2c2c2a; --line-strong: #3d3d3a;
  --accent: #4a92ea; --accent-soft: rgba(57,135,229,0.18);
  --good: #4cc94c; --good-soft: rgba(76,201,76,0.15);
  --bad: #ff6b66; --bad-soft: rgba(255,107,102,0.14);
  --warn: #f5b93a; --warn-soft: rgba(245,185,58,0.16);
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 28px rgba(0,0,0,0.5);
  color-scheme: dark;
}
:root[data-size="s"] { --fs: 15px; }
:root[data-size="l"] { --fs: 19px; }
:root[data-size="xl"] { --fs: 21px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 400 var(--fs)/1.55 var(--font);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── top bar + bottom tabs */
.pq-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(0.55rem + env(safe-area-inset-top)) 1rem 0.55rem;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.pq-brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.pq-brand b { color: var(--accent); }
.pq-logo { width: 26px; height: 26px; border-radius: 7px; display: block; }
.pq-gear { display: grid; place-items: center; width: 40px; height: 40px; margin: -6px -8px -6px 0; border-radius: 50%; color: var(--muted); text-decoration: none; font-size: 1.2rem; }
.pq-gear:active { background: var(--surface-2); }
.pq-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.pq-tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 550;
}
.pq-tabs a .ico { width: 23px; height: 23px; }
.pq-tabs a.on .ico { stroke-width: 2.2; }
.pq-tabs a.on { color: var(--accent); }
body.in-quiz .pq-tabs { display: none; }
body.in-quiz { padding-bottom: env(safe-area-inset-bottom); }

.pq-main { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 1.5rem; outline: none; }
.pq-loading { color: var(--muted); text-align: center; margin-top: 30vh; }
h1 { font-size: 1.35rem; letter-spacing: -0.02em; margin: 0.2rem 0 0.9rem; }
h2 { font-size: 1.02rem; margin: 1.4rem 0 0.6rem; letter-spacing: -0.01em; }
.fine { font-size: 0.82rem; color: var(--muted); margin: 0.2rem 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem; }

/* ── buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0.6rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  min-height: 40px; padding: 0.4rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 0.88rem; font-weight: 550;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ── home */
.quick5 {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%;
  min-height: 92px; padding: 1.1rem 1.25rem; border-radius: var(--radius-lg); border: 0;
  background: linear-gradient(135deg, var(--accent), #5c63d8); color: #fff; text-align: left;
  box-shadow: var(--shadow);
}
.quick5 strong { display: block; font-size: 1.3rem; letter-spacing: -0.02em; }
.quick5 span { font-size: 0.85rem; opacity: 0.92; }
.quick5 .due { font-size: 2rem; font-weight: 700; line-height: 1; text-align: right; }
.quick5 .due small { display: block; font-size: 0.7rem; font-weight: 600; opacity: 0.85; }
.continue { margin-top: 0.75rem; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.tile {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem; min-height: 72px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.tile .txt { display: flex; flex-direction: column; gap: 0.15rem; line-height: 1.25; }
.tile .nm { font-size: 0.86rem; font-weight: 600; }
.tile .sub { font-size: 0.74rem; color: var(--muted); }
.ring { --p: 0; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring-c, var(--accent)) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring::before { content: attr(data-label); width: 32px; height: 32px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 0.66rem; font-weight: 700; color: var(--ink-2); }

/* ── question */
.q-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.q-head .x { min-width: 44px; min-height: 44px; border: 0; background: none; font-size: 1.2rem; color: var(--muted); }
.q-progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.q-progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.q-count { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.7rem; }
.tag { font-size: 0.7rem; font-weight: 650; letter-spacing: 0.02em; padding: 0.15rem 0.5rem; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.tag.draft { background: var(--warn-soft); color: var(--warn); }
.q-stem { font-size: 1.04em; line-height: 1.6; margin: 0 0 1rem; white-space: pre-line; }
.opts { display: flex; flex-direction: column; gap: 0.55rem; }
.opt {
  display: grid; grid-template-columns: 1.8rem 1fr auto; align-items: center; gap: 0.4rem;
  min-height: 52px; width: 100%; padding: 0.6rem 0.85rem; text-align: left;
  border-radius: var(--radius); border: 1.5px solid var(--line-strong); background: var(--surface);
}
.opt .k { font-weight: 700; color: var(--muted); }
.opt .mark { font-weight: 800; font-size: 1.05rem; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .mark { color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .mark { color: var(--bad); }
.opt:disabled { cursor: default; }
.conf { margin: 1rem 0 0.3rem; }
.conf .lbl { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.q-actions { position: sticky; bottom: 0; padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--plane) 75%, transparent); display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.q-actions .btn { flex: 1; }
.q-tools { display: flex; gap: 0.4rem; }
.q-tools .btn { flex: 0 0 auto; min-width: 48px; padding: 0.5rem 0.7rem; font-size: 0.85rem; }
.q-tools .btn[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }

/* ── explanation (fixed template, §4.3) */
.expl { margin-top: 1rem; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.expl .verdict { font-weight: 700; font-size: 1.02em; margin: 0 0 0.6rem; }
.expl .verdict.ok { color: var(--good); }
.expl .verdict.no { color: var(--bad); }
.expl section { padding: 0.7rem 0; border-top: 1px solid var(--line); }
.expl h3 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.35rem; }
.expl p, .expl ul { margin: 0; }
.expl ul { padding-left: 1.1rem; }
.expl li { margin: 0.2rem 0; }
.expl .wrongs li { list-style: none; margin-left: -1.1rem; }
.expl .wrongs b { display: inline-block; min-width: 1.4rem; }
.expl .pearl { background: var(--accent-soft); border-radius: var(--radius); padding: 0.7rem 0.85rem; border-top: 0; margin-top: 0.4rem; }
.expl .my-note { white-space: pre-wrap; }

/* ── lists, stats, settings */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.85rem 1rem; min-height: 56px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); width: 100%; text-align: left; }
.row .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 6px; }
.bar.weak i { background: var(--bad); }
.stat-row { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.stat-row .top { display: flex; justify-content: space-between; font-size: 0.88rem; margin-bottom: 0.35rem; gap: 0.5rem; }
.stat-row .top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem; }
.kpi .v { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi .l { font-size: 0.72rem; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { min-height: 40px; padding: 0.3rem 0.85rem; border: 0; border-radius: 9px; background: transparent; font-weight: 550; font-size: 0.86rem; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.score-big { font-size: 2.6rem; font-weight: 750; letter-spacing: -0.03em; margin: 0; }

/* ── sheets, toast */
.pq-sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.45); display: flex; align-items: flex-end; justify-content: center; }
.pq-sheet { width: min(640px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.pq-sheet h2 { margin-top: 0; }
.pq-sheet textarea { width: 100%; min-height: 120px; padding: 0.7rem; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--plane); resize: vertical; }
.pq-sheet .acts { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.pq-sheet .acts .btn { flex: 1; }
.pq-toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--plane); padding: 0.55rem 1rem; border-radius: 999px; font-size: 0.86rem; opacity: 0;
  transition: opacity .18s, transform .18s; pointer-events: none; z-index: 60; max-width: calc(100% - 2rem); }
.pq-toast.show { opacity: 1; transform: translateX(-50%); }

/* tablet / desktop: question | explanation side by side */
@media (min-width: 980px) {
  .pq-main.wide { max-width: 1180px; }
  .q-layout.revealed { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
  .q-layout.revealed .expl { margin-top: 0; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── study mode ─────────────────────────────────────────────────── */
.field { width: 100%; min-height: 48px; padding: 0.6rem 0.9rem; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); }
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.search { margin-bottom: 0.9rem; }
.study-topic { margin-bottom: 0.5rem; }
.study-head { width: 100%; }
.study-head .chev { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.study-sec { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1rem 0.2rem 0.45rem; }
.study-row { color: var(--ink); text-decoration: none; }
.study-row b { font-weight: 600; }
.tick { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: 0.75rem; color: #fff; }
.tick.on { background: var(--good); border-color: var(--good); }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.9rem; padding: 0.3rem 0; margin-bottom: 0.2rem; }
.card-title { font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; }
.note-card { margin-top: 0.6rem; font-size: 1.0rem; line-height: 1.58; }
.note-card section:first-child { border-top: 0; padding-top: 0; }
.note-card li { margin: 0.35rem 0; }
.fold { border-top: 1px solid var(--line); padding: 0.55rem 0 0.2rem; }
.fold summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 40px;
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: "▸"; font-size: 0.9rem; transition: transform .15s; }
.fold[open] summary::after { transform: rotate(90deg); }
.fold ul { padding-left: 1.1rem; margin: 0.2rem 0 0.4rem; }
.pearls-top { margin-top: 0.7rem; padding: 0.8rem 0.95rem; border-radius: var(--radius-lg); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.pearls-top h3 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin: 0 0 0.35rem; }
.pearls-top ul { margin: 0; padding-left: 1.1rem; line-height: 1.5; }
.pearls-top li { margin: 0.3rem 0; }
.card-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 1rem 0 1.2rem; }
.card-nav .btn { font-size: 0.82rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; text-align: center; line-height: 30px; text-decoration: none; color: var(--ink); }
.card-nav .btn:last-child { text-align: center; }
.test-me { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 0.6rem); }
.test-me .btn { box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.study-link { margin-top: 0.8rem; text-decoration: none; text-align: center; display: grid; place-items: center; color: var(--accent); }

/* ── today (home) ───────────────────────────────────────────────── */
.today { border-radius: var(--radius-lg); padding: 1.1rem 1.15rem 0.9rem; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #8a5bd6 0%, transparent 55%), linear-gradient(135deg, var(--accent), #4b55c9);
  box-shadow: 0 10px 30px rgba(52, 70, 180, 0.25); }
.today .eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; font-weight: 700; }
.today-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.today-n { font-size: 2.3rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.today-n small { font-size: 1rem; font-weight: 600; opacity: 0.85; letter-spacing: 0; }
.streak { display: flex; align-items: center; gap: 0.4rem; background: rgba(255,255,255,0.16); border-radius: 999px; padding: 0.35rem 0.75rem 0.35rem 0.6rem; }
.streak b { font-size: 1.3rem; }
.streak span { font-size: 0.62rem; line-height: 1.1; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; }
.today-split { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin: 0.55rem 0 0.85rem; font-size: 0.88rem; }
.today-split .fine { color: rgba(255,255,255,0.75); font-size: 0.78rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; vertical-align: 1px; }
.dot.due { background: #ffd166; } .dot.new { background: #7ee2b8; }
.today-go { background: #fff; color: #2c3aa8; border-color: #fff; font-weight: 700; }
.today-go:disabled { background: rgba(255,255,255,0.22); color: #fff; border-color: transparent; opacity: 1; }
.fc { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; margin-top: 0.95rem; height: 64px; align-items: end; }
.fc-d { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.fc-d i { width: 100%; max-width: 26px; min-height: 3px; border-radius: 5px 5px 2px 2px; background: rgba(255,255,255,0.55); margin-bottom: 15px; }
.fc-d span { position: absolute; bottom: 15px; font-size: 0.62rem; opacity: 0.0; }
.fc-d em { position: absolute; bottom: 0; font-style: normal; font-size: 0.6rem; opacity: 0.8; }
.fc-d:first-child i { background: #ffd166; }
.home-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.75rem; }
.home-acts .btn { text-decoration: none; color: var(--ink); display: grid; place-items: center; }
.q-tools .btn { display: grid; place-items: center; }
.q-tools #flag[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); }
.q-tools #flag[aria-pressed="true"] svg path:last-child { fill: currentColor; }
.study-scope { margin-bottom: 0.7rem; display: flex; }
.study-scope button { flex: 1; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.standards ul { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.standards li { padding: 0.5rem 0; border-top: 1px solid var(--line); }
.standards li:first-child { border-top: 0; }
