/* ============================================================
   STAT 312 Revision — styles
   QU maroon #8A1538 + white + gray. Mobile-first. Light/dark.
   ============================================================ */

:root {
  --qu-maroon: #8A1538;
  --qu-maroon-dark: #6d0f2b;
  --qu-maroon-light: #a83350;
  --accent: var(--qu-maroon);
  --accent-contrast: #ffffff;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #1b1d21;
  --text-muted: #5b6068;
  --text-faint: #878d96;

  --ok: #1c7c4a;
  --ok-bg: #e6f4ec;
  --err: #b3261e;
  --err-bg: #fbe9e8;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --info-bg: #eef1fb;

  --shadow: 0 1px 3px rgba(16,18,22,.08), 0 1px 2px rgba(16,18,22,.06);
  --shadow-lg: 0 8px 30px rgba(16,18,22,.14);
  --radius: 14px;
  --radius-sm: 9px;

  --sidenav-w: 232px;
  --maxw: 900px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="dark"] {
  --bg: #14151a;
  --surface: #1e2027;
  --surface-2: #262a33;
  --border: #333844;
  --text: #eceef2;
  --text-muted: #a7adb8;
  --text-faint: #7d838f;
  --accent: #d46a86;
  --accent-contrast: #1a0d12;
  --qu-maroon: #d46a86;

  --ok: #7fd6a3; --ok-bg: #16301f;
  --err: #f2a29c; --err-bg: #351a18;
  --warn: #e6c079; --warn-bg: #322910;
  --info-bg: #1c2130;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .8em; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-contrast); padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.app__brand {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .55rem .9rem; padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--qu-maroon); color: #fff;
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .app__brand { background: #24262e; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,.16); font-weight: 700; font-size: 1.15rem; font-style: italic;
}
.brand__name { font-weight: 700; font-size: 1.05rem; display: flex; flex-direction: column; line-height: 1; }
.brand__name small { font-weight: 500; opacity: .82; font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; margin-top: 3px; }

.theme-toggle {
  background: rgba(255,255,255,.16); color: #fff; border: 0; width: 38px; height: 38px;
  border-radius: 10px; font-size: 1.2rem; cursor: pointer; display: grid; place-items: center;
}
.theme-toggle:hover { background: rgba(255,255,255,.28); }

.sidenav { display: none; }

.app__main { padding: 1rem .9rem calc(5.2rem + var(--safe-b)); }
.view { max-width: var(--maxw); margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .5rem 0 .55rem; font-size: .66rem; color: var(--text-muted);
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav a .nav-ic { font-size: 1.15rem; }
.bottomnav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav-ic { line-height: 1; }

/* ---------- Install banner ---------- */
/* The `hidden` attribute must win over `display:flex` below, otherwise the
   banner can never be hidden or dismissed. */
.install-banner[hidden] { display: none !important; }
.install-banner {
  position: fixed; z-index: 60; left: 0; right: 0; bottom: calc(4.4rem + var(--safe-b));
  margin: 0 auto; max-width: 560px; width: calc(100% - 1.4rem);
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: var(--qu-maroon); color: #fff; padding: .6rem .8rem; border-radius: 12px;
  box-shadow: var(--shadow-lg); animation: slideup .3s ease;
}
@keyframes slideup { from { transform: translateY(20px); opacity: 0;} to { transform: none; opacity: 1;} }
.install-banner__text { font-size: .88rem; font-weight: 500; }
.install-banner__actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: .6rem 1rem; border-radius: 10px;
  transition: background .15s, transform .05s; text-align: center;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.btn--primary:hover { background: var(--qu-maroon-dark); }
:root[data-theme="dark"] .btn--primary:hover { background: var(--qu-maroon-light); }
.btn--sm { padding: .38rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn--on-accent { background: #fff; color: var(--qu-maroon); border-color: transparent; }
.btn--ghost-accent { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn--ghost-accent:hover { background: rgba(255,255,255,.15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / generic ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.05rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card--pad-lg { padding: 1.3rem; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.stack > * + * { margin-top: .8rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: .9rem; }
.hidden { display: none !important; }

.page-head { margin-bottom: 1rem; }
.page-head h1 { margin-bottom: .2rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; font-weight: 700; color: var(--accent); }

.tag {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: .16rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.tag--accent { background: var(--info-bg); color: var(--accent); border-color: transparent; }

/* ---------- Home / timeline ---------- */
.hero {
  background: linear-gradient(135deg, var(--qu-maroon), var(--qu-maroon-dark));
  color: #fff; border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #3a1622, #24262e); border: 1px solid var(--border); }
.hero h1 { color: #fff; }
.hero__where { font-size: .92rem; opacity: .92; }
.hero__week { font-size: 1.1rem; font-weight: 700; margin-top: .3rem; }

.countdowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: .6rem; margin: .2rem 0 1.1rem; }
.cd {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .8rem;
  box-shadow: var(--shadow); border-left: 4px solid var(--accent);
}
.cd--soon { border-left-color: var(--err); }
.cd--done { opacity: .55; border-left-color: var(--text-faint); }
.cd__label { font-weight: 700; font-size: .9rem; }
.cd__days { font-size: 1.35rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.cd--soon .cd__days { color: var(--err); }
.cd__date { font-size: .74rem; color: var(--text-muted); }

.timeline { position: relative; margin: .4rem 0 .5rem; }
.tl-week {
  display: grid; grid-template-columns: 46px 1fr; gap: .7rem; padding: .55rem .2rem;
  border-bottom: 1px solid var(--border);
}
.tl-week:last-child { border-bottom: 0; }
.tl-week__num {
  display: grid; place-content: center; align-self: start; width: 42px; height: 42px; border-radius: 10px;
  background: var(--surface-2); font-weight: 800; color: var(--text-muted); font-size: .78rem; text-align: center; line-height: 1.05;
}
.tl-week--now .tl-week__num { background: var(--accent); color: var(--accent-contrast); }
.tl-week--break .tl-week__num { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 5px, var(--border) 5px, var(--border) 10px); }
.tl-week--now { background: var(--info-bg); border-radius: 10px; }
.tl-week__body { min-width: 0; }
.tl-week__dates { font-size: .74rem; color: var(--text-faint); }
.tl-week__topic { font-weight: 600; font-size: .92rem; }
.tl-week__assess { margin-top: .25rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.pill { font-size: .68rem; font-weight: 700; padding: .12rem .45rem; border-radius: 6px; background: var(--warn-bg); color: var(--warn); }
.pill--quiz { background: var(--info-bg); color: var(--accent); }
.pill--exam { background: var(--err-bg); color: var(--err); }
.tl-week--now .tl-week__topic::after { content: "  ← you are here"; color: var(--accent); font-weight: 700; font-size: .8rem; }

/* ---------- Stage list & stage page ---------- */
.stage-grid { display: grid; gap: .9rem; }
@media (min-width: 560px){ .stage-grid { grid-template-columns: 1fr 1fr; } }
.stage-card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); color: var(--text); position: relative; overflow: hidden;
}
.stage-card:hover { text-decoration: none; box-shadow: var(--shadow-lg); transform: translateY(-2px); transition: .15s; }
.stage-card__no {
  position: absolute; right: -8px; top: -14px; font-size: 4rem; font-weight: 800; color: var(--surface-2);
  z-index: 0; user-select: none;
}
.stage-card > * { position: relative; z-index: 1; }
.stage-card__lectures { font-size: .72rem; color: var(--text-faint); font-weight: 600; }
.stage-card__title { font-weight: 700; font-size: 1.02rem; margin: .1rem 0 .3rem; }
.stage-card__goal { font-size: .86rem; color: var(--text-muted); }
.stage-card__foot { margin-top: .6rem; display: flex; align-items: center; justify-content: space-between; }
.progress-ring { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: .55rem; }
.progress-ring > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }

.concept { border-left: 3px solid var(--accent); padding: .1rem 0 .1rem .8rem; margin: .2rem 0 1rem; }
.concept h3 { margin-bottom: .2rem; }

.box { border-radius: var(--radius-sm); padding: .8rem .9rem; margin: .9rem 0; border: 1px solid transparent; }
.box__title { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; display: flex; align-items: center; gap: .4rem; }
.box--mistake { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.box--mistake .box__title { color: var(--err); }
.box--tip { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.box--tip .box__title { color: var(--ok); }
.box--info { background: var(--info-bg); }
.box--info .box__title { color: var(--accent); }
.box ul { margin: .3rem 0; padding-left: 1.2rem; }
.box li { margin: .2rem 0; }

/* checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { margin: 0; }
.checklist label {
  display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .6rem; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
}
.checklist label:hover { background: var(--surface-2); }
.checklist input { margin-top: .28rem; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.checklist input:checked + span { color: var(--text-muted); text-decoration: line-through; }

.link-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .4rem; }

/* ---------- Flashcards ---------- */
.deck-meta { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .8rem; flex-wrap: wrap; }
.flash-stage { perspective: 1400px; }
.flashcard {
  position: relative; width: 100%; min-height: 320px; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s; margin-bottom: 1rem;
}
.flashcard.is-flipped { transform: rotateY(180deg); }
.flashcard__face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.3rem; display: flex; flex-direction: column;
  overflow: auto;
}
.flashcard__face--back { transform: rotateY(180deg); background: var(--surface-2); }
.flashcard__kind { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: .5rem; }
.flashcard__content { flex: 1; display: flex; flex-direction: column; justify-content: center; font-size: 1.05rem; white-space: pre-wrap; }
.flashcard__content.is-code {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .82rem; text-align: left; justify-content: flex-start; line-height: 1.5;
}
.flashcard__content.is-code .katex { font-family: KaTeX_Main, "Times New Roman", serif; }
.flashcard__hint { text-align: center; font-size: .74rem; color: var(--text-faint); margin-top: .6rem; }
.flashcard__src { font-size: .7rem; color: var(--text-faint); margin-top: .5rem; }
.flash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.flash-progress { text-align: center; font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem; }
.box-badges { display: flex; gap: .35rem; justify-content: center; margin-top: .3rem; flex-wrap: wrap; }
.box-badge { font-size: .66rem; padding: .12rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--text-muted); }

/* ---------- Quiz ---------- */
.quiz-list-item { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.q-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .78rem; color: var(--text-muted); margin-bottom: .3rem; }
.q-progress-bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: .5rem 0 1rem; }
.q-progress-bar > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.q-stem { font-size: 1.05rem; font-weight: 500; margin: .3rem 0 1rem; }
.q-source { font-size: .72rem; color: var(--text-faint); margin-bottom: .8rem; }
.options { display: grid; gap: .55rem; }
.opt {
  display: flex; gap: .65rem; align-items: flex-start; text-align: left; width: 100%;
  padding: .75rem .8rem; border: 1.5px solid var(--border); border-radius: 11px; background: var(--surface);
  cursor: pointer; font: inherit; color: var(--text); transition: .12s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt__marker {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-faint);
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--text-muted);
}
.opt--multi .opt__marker { border-radius: 6px; }
.opt.is-selected { border-color: var(--accent); background: var(--info-bg); }
.opt.is-selected .opt__marker { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-correct .opt__marker { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--err); background: var(--err-bg); }
.opt.is-wrong .opt__marker { background: var(--err); border-color: var(--err); color: #fff; }
.opt__body { flex: 1; padding-top: 1px; }
.opt:disabled { cursor: default; }

.feedback { margin-top: 1rem; padding: .85rem .9rem; border-radius: 11px; font-size: .92rem; }
.feedback--ok { background: var(--ok-bg); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.feedback--err { background: var(--err-bg); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); }
.feedback__verdict { font-weight: 700; margin-bottom: .25rem; }
.feedback--ok .feedback__verdict { color: var(--ok); }
.feedback--err .feedback__verdict { color: var(--err); }

.multi-hint { font-size: .78rem; color: var(--warn); background: var(--warn-bg); padding: .4rem .6rem; border-radius: 8px; margin-bottom: .8rem; }

.timer-chip { font-variant-numeric: tabular-nums; font-weight: 700; padding: .2rem .55rem; border-radius: 8px; background: var(--surface-2); font-size: .82rem; }
.timer-chip--low { background: var(--err-bg); color: var(--err); }

.score-ring { display: grid; place-items: center; width: 140px; height: 140px; margin: 0 auto 1rem; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct,0%), var(--surface-2) 0); }
.score-ring__inner { width: 112px; height: 112px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.score-ring__pct { font-size: 1.7rem; font-weight: 800; }
.skill-bar { margin: .5rem 0; }
.skill-bar__label { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: .2rem; }
.skill-bar__track { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.skill-bar__fill { height: 100%; background: var(--accent); border-radius: 5px; }

/* setup toggles */
.setup-row { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.setup-row:last-of-type { border-bottom: 0; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch__slider::before { content:""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow); }
.switch input:checked + .switch__slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }
select.input { font: inherit; padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ---------- Formulas ---------- */
.search-box { width: 100%; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); font: inherit; margin-bottom: 1rem; }
.formula-item { border: 1px solid var(--border); border-radius: 11px; padding: .8rem .9rem; margin-bottom: .7rem; background: var(--surface); }
.formula-item__head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .4rem; }
.formula-item__name { font-weight: 600; font-size: .92rem; }
.formula-render { overflow-x: auto; padding: .3rem 0; }
.copy-btn { font-size: .72rem; padding: .25rem .55rem; }
.copy-btn.copied { background: var(--ok); color: #fff; border-color: transparent; }
.formula-group-title { margin: 1.3rem 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }

/* ---------- FAQ ---------- */
.faq-cat-title { margin: 1.4rem 0 .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
details.faq { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; margin-bottom: .6rem; overflow: hidden; }
details.faq > summary { padding: .8rem .9rem; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
details.faq > summary::-webkit-details-marker { display: none; }
details.faq > summary::after { content: "+"; color: var(--accent); font-weight: 700; font-size: 1.2rem; flex-shrink: 0; }
details.faq[open] > summary::after { content: "−"; }
details.faq > summary:hover { background: var(--surface-2); }
.faq__body { padding: 0 .9rem .9rem; color: var(--text); border-top: 1px solid var(--border); padding-top: .7rem; }

/* ---------- About / progress ---------- */
.def-list { display: grid; gap: .55rem; }
.def-list div { display: grid; grid-template-columns: 120px 1fr; gap: .6rem; font-size: .9rem; }
.def-list dt { color: var(--text-muted); font-weight: 600; }
@media (max-width: 420px){ .def-list div { grid-template-columns: 1fr; gap: .1rem; } .def-list dt { font-size: .78rem; } }
.disclaimer { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 11px; padding: .8rem .9rem; font-size: .88rem; font-weight: 500; }

.powered-by { display: flex; gap: .8rem; align-items: center; margin-top: 1rem; }
.powered-by__mark {
  flex-shrink: 0; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--qu-maroon); color: #fff; font-style: italic; font-weight: 700; font-size: 1.5rem;
  font-family: Georgia, "Times New Roman", serif;
}
:root[data-theme="dark"] .powered-by__mark { background: var(--surface-2); color: var(--accent); }
.contact-field { margin: .6rem 0; }
.contact-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: .25rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: .7rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem; text-align: center; box-shadow: var(--shadow); }
.stat__num { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat__label { font-size: .74rem; color: var(--text-muted); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: calc(5rem + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .85rem;
  z-index: 80; box-shadow: var(--shadow-lg); animation: fade .2s;
}

/* KaTeX sizing in cards */
.katex { font-size: 1.02em; }
.katex-display { margin: .5em 0; overflow-x: auto; overflow-y: hidden; padding: .2em 0; }

/* ============================================================
   Desktop: sidebar layout
   ============================================================ */
@media (min-width: 860px) {
  .app { display: grid; grid-template-columns: var(--sidenav-w) 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
  .app__brand { grid-column: 1 / -1; }
  .sidenav {
    display: flex; flex-direction: column; justify-content: space-between;
    position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px);
    background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .7rem;
  }
  .sidenav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
  .sidenav__list a {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
    color: var(--text-muted); font-weight: 600; font-size: .92rem;
  }
  .sidenav__list a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
  .sidenav__list a[aria-current="page"] { background: var(--info-bg); color: var(--accent); }
  .sidenav__list .nav-ic { font-size: 1.1rem; width: 22px; text-align: center; }
  .sidenav__foot { padding: .5rem .3rem; }
  .sidenav__progress { font-size: .82rem; color: var(--text-muted); font-weight: 600; }
  .app__main { padding: 1.6rem 2rem 3rem; }
  .bottomnav { display: none; }
  .install-banner { bottom: 1.4rem; right: 1.4rem; left: auto; margin: 0; max-width: 380px; }
  h1 { font-size: 1.75rem; }
}

@media (min-width: 1180px) {
  .app__main { padding: 1.8rem 3rem 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .flashcard { transition: none; }
}
