/* Application shell: masthead, sidebar, and the marking views. */

/* ---------------------------------------------------------------- masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--raised); position: sticky; top: 0; z-index: 20; }
.masthead-inner { max-width: 1120px; margin: 0 auto; padding: 0 var(--s-5);
  display: flex; align-items: center; gap: var(--s-5); min-height: 56px; }
.brand { font-family: var(--f-serif); font-weight: 600; font-size: var(--t-md);
  letter-spacing: -0.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: var(--s-1); flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { font-size: var(--t-sm); color: var(--muted); text-decoration: none;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md); white-space: nowrap; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 500; background: var(--sunken); }
.masthead-meta { display: flex; align-items: center; gap: var(--s-2); flex: none;
  font-size: var(--t-sm); color: var(--muted); }

/* The nav is the only part allowed to give up space; without min-width:0 a
   flex child refuses to shrink below its content and pushes the trailing
   controls off-screen, which is exactly what happened at 375px. */
.nav { min-width: 0; }

/* ------------------------------------------------------------------ layout */
.view { padding: var(--s-6) 0 var(--s-8); }
.view-head { margin-bottom: var(--s-5); }
.view-head h1 { margin-bottom: var(--s-2); }
.split { display: grid; grid-template-columns: 260px 1fr; gap: var(--s-6); align-items: start; }
.sidebar { position: sticky; top: 76px; }
.sidebar-group + .sidebar-group { margin-top: var(--s-5); }
.sidebar h3 { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: var(--s-2); }
.sidebar a { display: block; font-size: var(--t-sm); color: var(--muted); text-decoration: none;
  padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); border-left: 2px solid transparent; }
.sidebar a:hover { color: var(--ink); background: var(--sunken); }
.sidebar a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .sidebar { position: static; } }

/* --------------------------------------------------------------- mark meter
   A mark is a position on a scale, so it is drawn as one. The number stays
   readable on its own; the bar is not the only carrier of the value. */
.meter { display: flex; align-items: baseline; gap: var(--s-3); }
.meter-value { font-family: var(--f-mono); font-size: var(--t-xl); font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1; }
.meter-max { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--muted); }
.bar { height: 6px; background: var(--sunken); border-radius: var(--r-sm); overflow: hidden; margin-top: var(--s-2); }
.bar-fill { height: 100%; background: var(--accent); border-radius: var(--r-sm); }
.bar-fill.is-good { background: var(--good); }
.bar-fill.is-warn { background: var(--warn); }
.bar-fill.is-bad { background: var(--bad); }

/* --------------------------------------------------------- criterion blocks */
.criterion { border-top: 1px solid var(--rule); padding: var(--s-4) 0; }
.criterion:first-child { border-top: none; }
.criterion-head { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-2); }
.criterion-id { font-family: var(--f-mono); font-size: var(--t-xs); font-weight: 600;
  color: var(--accent); letter-spacing: 0.08em; }
.criterion-name { font-weight: 500; flex: 1; }
.criterion-mark { font-family: var(--f-mono); font-size: var(--t-md); font-weight: 600;
  font-variant-numeric: tabular-nums; }
.criterion-body { font-size: var(--t-sm); }
.evidence { border-left: 2px solid var(--rule); padding-left: var(--s-3); margin: var(--s-2) 0;
  font-family: var(--f-serif); font-style: italic; color: var(--muted); }
.gap { color: var(--ink); }
.gap b { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--warn); display: block; margin-bottom: var(--s-1); }

/* --------------------------------------------------------------- the ladder
   Shows every rung so the student can see where they sit and what the next one
   actually asks for. The rung above is the only one that matters. */
.ladder { list-style: none; padding: 0; margin: var(--s-3) 0 0; border: 1px solid var(--rule);
  border-radius: var(--r-md); overflow: hidden; }
.ladder li { display: flex; gap: var(--s-3); padding: var(--s-2) var(--s-3); font-size: var(--t-sm);
  color: var(--muted); border-top: 1px solid var(--rule-soft); max-width: none; margin: 0; }
.ladder li:first-child { border-top: none; }
.ladder li.is-here { background: var(--accent-wash); color: var(--ink); font-weight: 500; }
.ladder li.is-next { background: var(--warn-wash); color: var(--ink); }
.ladder .rung-n { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--muted); min-width: 1.5em; }
.ladder li.is-here .rung-n, .ladder li.is-next .rung-n { color: inherit; }

/* ------------------------------------------------------------- requirements */
.req { display: flex; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--rule-soft); }
.req:first-child { border-top: none; }
.req-mark { font-family: var(--f-mono); font-weight: 600; min-width: 1.6em; }
.req-mark.met { color: var(--good); }
.req-mark.unmet { color: var(--bad); }
.req-mark.unknown { color: var(--muted); }
.req-text { flex: 1; font-size: var(--t-sm); }
.req-text b { display: block; color: var(--ink); font-weight: 500; margin-bottom: 2px; }

/* ------------------------------------------------------------- word counter */
.counter { display: flex; align-items: baseline; gap: var(--s-2); font-family: var(--f-mono);
  font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.counter-n { font-size: var(--t-md); font-weight: 600; }
.counter.is-over .counter-n { color: var(--bad); }
.counter.is-near .counter-n { color: var(--warn); }
.counter.is-ok .counter-n { color: var(--good); }

/* ---------------------------------------------------------------- topic list */
.topic { display: flex; gap: var(--s-3); align-items: baseline; padding: var(--s-3) 0;
  border-top: 1px solid var(--rule-soft); }
.topic:first-child { border-top: none; }
.topic-code { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--muted); min-width: 3.2em; }
.topic-title { flex: 1; }
.topic-title a { color: var(--ink); text-decoration: none; }
.topic-title a:hover { color: var(--accent); text-decoration: underline; }
.state-btns { display: flex; gap: 2px; }
.state-btn { font-family: var(--f-mono); font-size: var(--t-xs); padding: 3px 8px; min-height: 26px;
  border: 1px solid var(--rule); background: var(--raised); color: var(--muted);
  cursor: pointer; border-radius: var(--r-sm); }
.state-btn[aria-pressed="true"] { border-color: currentColor; font-weight: 600; }
.state-btn[data-state="1"][aria-pressed="true"] { color: var(--warn); background: var(--warn-wash); }
.state-btn[data-state="2"][aria-pressed="true"] { color: var(--good); background: var(--good-wash); }

/* ----------------------------------------------------------------- toasts */
#toast-host { position: fixed; bottom: var(--s-5); left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; }
.toast { background: var(--ink); color: var(--paper); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md); font-size: var(--t-sm); box-shadow: var(--e-2); max-width: 90vw; }
.toast-error { background: var(--bad); color: var(--raised); }
.toast-good { background: var(--good); color: var(--raised); }

/* ------------------------------------------------------------------ landing */
.hero { padding: var(--s-8) 0 var(--s-7); border-bottom: 1px solid var(--rule); }
.hero h1 { font-size: var(--t-2xl); max-width: 17ch; margin-bottom: var(--s-4); }
.hero .lede { font-size: var(--t-md); max-width: 56ch; margin-bottom: var(--s-5); }
.hero-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.feature { padding: var(--s-6) 0; border-bottom: 1px solid var(--rule-soft); }
.feature-grid { display: grid; grid-template-columns: 200px 1fr; gap: var(--s-6); align-items: start; }
.feature-grid h2 { font-size: var(--t-lg); }
@media (max-width: 720px) { .feature-grid { grid-template-columns: 1fr; gap: var(--s-3); } }

/* --------------------------------------------------------------- auth pages */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--sunken); border-right: 1px solid var(--rule);
  padding: var(--s-8) var(--s-7); display: flex; flex-direction: column; justify-content: center; }
.auth-main { padding: var(--s-8) var(--s-7); display: flex; flex-direction: column; justify-content: center; }
.auth-form { width: 100%; max-width: 380px; }
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; min-height: 0; }
  .auth-side { border-right: none; border-bottom: 1px solid var(--rule); padding: var(--s-6) var(--s-5); }
  .auth-main { padding: var(--s-6) var(--s-5); }
}

/* --------------------------------------------- offline banner: say what works */
.offline { background: var(--warn-wash); color: var(--warn); border-bottom: 1px solid var(--rule);
  padding: var(--s-2) var(--s-5); font-size: var(--t-sm); text-align: center; }

.page-foot { padding-top: var(--s-6); padding-bottom: var(--s-7); }
.auth-title { margin-top: var(--s-5); }
.auth-side .lede { font-size: var(--t-base); }
.mt-4 { margin-top: var(--s-4); }

.note-good-ish { border-left-color: var(--good); }
.note-good-ish b { color: var(--good); }

/* ------------------------------------------------- show/hide password control */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 68px; }
.pw-toggle {
  position: absolute; top: 50%; right: var(--s-2); transform: translateY(-50%);
  font: inherit; font-size: var(--t-sm); font-weight: 500;
  background: transparent; border: 1px solid var(--rule); border-radius: var(--r-sm);
  color: var(--muted); padding: 2px var(--s-2); min-height: 26px; cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); border-color: var(--muted); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
@media (pointer: coarse) { .pw-toggle { min-height: 34px; } }

/* ------------------------------------------------------------- theme toggle */
.theme-toggle { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.06em;
  text-transform: uppercase; min-width: 56px; }

/* ------------------------------------------------------------------- search */
.search-btn { font-size: var(--t-sm); color: var(--muted); background: var(--sunken);
  border: 1px solid var(--rule); border-radius: var(--r-md); padding: var(--s-1) var(--s-3);
  min-height: 30px; cursor: pointer; display: inline-flex; align-items: center; gap: var(--s-2);
  transition: border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease); }
.search-btn:hover { border-color: var(--muted); color: var(--ink); }
.search-btn kbd { font-family: var(--f-mono); font-size: var(--t-xs); border: 1px solid var(--rule);
  border-radius: var(--r-sm); padding: 0 4px; color: var(--muted); background: var(--raised); }

.search-overlay { position: fixed; inset: 0; z-index: 200; display: grid;
  place-items: start center; padding-top: 12vh; background: rgb(0 0 0 / 0.45);
  animation: fade var(--motion) var(--ease) both; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.search-panel { width: min(620px, 92vw); background: var(--raised); border: 1px solid var(--rule);
  border-radius: var(--r-lg); box-shadow: var(--e-2); overflow: hidden;
  animation: rise var(--motion-slow) var(--ease-out) both; }
.search-panel input { border: none; border-bottom: 1px solid var(--rule); border-radius: 0;
  font-size: var(--t-md); padding: var(--s-4); min-height: 56px; }
.search-panel input:focus-visible { outline: none; border-bottom-color: var(--accent); }
.search-results { max-height: min(52vh, 440px); overflow-y: auto; }
.search-hit { display: block; width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid var(--rule-soft); padding: var(--s-3) var(--s-4); cursor: pointer;
  font: inherit; color: var(--ink); }
.search-hit:last-child { border-bottom: none; }
.search-hit:hover, .search-hit[aria-selected="true"] { background: var(--sunken); }
.search-hit .hit-kind { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); }
.search-hit .hit-title { font-weight: 500; }
.search-hit .hit-sub { font-size: var(--t-sm); color: var(--muted); }
.search-empty { padding: var(--s-5) var(--s-4); color: var(--muted); font-size: var(--t-sm); text-align: center; }
.search-foot { border-top: 1px solid var(--rule); padding: var(--s-2) var(--s-4);
  font-size: var(--t-xs); color: var(--muted); font-family: var(--f-mono); }

/* ------------------------------------------------------------ google sign-in */
.btn-google { width: 100%; justify-content: center; gap: var(--s-3); font-weight: 500;
  background: var(--raised); color: var(--ink); border: 1px solid var(--rule); }
.btn-google:hover { border-color: var(--muted); background: var(--sunken); }
.or-divider { display: flex; align-items: center; gap: var(--s-3);
  margin: var(--s-4) 0; color: var(--muted); font-size: var(--t-sm); }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* ============================================================== study layout
   A book-style tree on the left, reading pane on the right. The tree stays put
   so a student always knows where they are in the syllabus, rather than
   navigating back to a list each time. */
.study { display: grid; grid-template-columns: 272px 1fr; gap: var(--s-6); align-items: start; }
@media (max-width: 900px) { .study { grid-template-columns: 1fr; } }

.tree { position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow-y: auto;
  border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--raised); padding: var(--s-3); }
@media (max-width: 900px) { .tree { position: static; max-height: none; } }

.tree-unit + .tree-unit { margin-top: var(--s-3); border-top: 1px solid var(--rule-soft); padding-top: var(--s-3); }
.tree-unit-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-2);
  font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.1em; text-transform: uppercase; }
.tree-dot { width: 8px; height: 8px; border-radius: var(--r-circle); flex: none; background: var(--unit-colour); }
.tree-unit-name { color: var(--unit-colour); font-weight: 600; }
.tree-unit-count { margin-left: auto; color: var(--muted); font-weight: 400; }

.tree a { display: flex; align-items: baseline; gap: var(--s-2); padding: var(--s-1) var(--s-2);
  font-size: var(--t-sm); color: var(--muted); text-decoration: none; border-radius: var(--r-sm);
  border-left: 2px solid transparent; transition: background-color var(--dur-fast) var(--ease); }
.tree a:hover { background: var(--sunken); color: var(--ink); }
.tree a[aria-current="page"] { background: var(--unit-wash); color: var(--unit-colour);
  border-left-color: var(--unit-colour); font-weight: 600; }
.tree-code { font-family: var(--f-mono); font-size: var(--t-xs); flex: none; min-width: 2.6em; }
.tree-state { margin-left: auto; width: 7px; height: 7px; border-radius: var(--r-circle); flex: none;
  background: var(--rule); }
.tree-state[data-state="1"] { background: var(--warn); }
.tree-state[data-state="2"] { background: var(--good); }

/* --- unit-tinted headers ------------------------------------------------- */
.unit-banner { border-left: 3px solid var(--unit-colour); background: var(--unit-wash);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md); margin-bottom: var(--s-4); }
.unit-banner .eyebrow { color: var(--unit-colour); margin: 0 0 2px; }
.unit-banner h1, .unit-banner h2 { margin: 0; }

/* --- content-type tabs --------------------------------------------------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--rule); margin-bottom: var(--s-5); }
.tabs button { font: inherit; font-size: var(--t-sm); font-weight: 500; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  padding: var(--s-2) var(--s-3); margin-bottom: -1px; min-height: 40px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--unit-colour); border-bottom-color: var(--unit-colour); }

/* --- definition block: the single most useful thing on a study page ------ */
.define { border: 1px solid var(--rule); border-left: 3px solid var(--unit-colour);
  border-radius: var(--r-md); background: var(--raised); padding: var(--s-4);
  margin: 0 0 var(--s-3); }
.define dt { font-weight: 600; font-size: var(--t-md); margin-bottom: var(--s-1); }
.define dd { margin: 0; color: var(--slate, var(--muted)); font-size: var(--t-base); line-height: 1.6; }
.define-label { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--unit-colour); display: block; margin-bottom: var(--s-2); }

/* Study prose reads longer than tool text, so it gets a size up. */
.prose { font-size: var(--t-md); line-height: 1.65; }
.prose li { margin-bottom: var(--s-2); }

/* --- progress bar on the tree header ------------------------------------- */
.unit-progress { height: 3px; background: var(--rule-soft); border-radius: var(--r-sm);
  margin: var(--s-1) var(--s-2) 0; overflow: hidden; }
.unit-progress span { display: block; height: 100%; background: var(--unit-colour);
  transition: width var(--dur-slow) var(--ease); }
.mb-4 { margin-bottom: var(--s-4); }


/* --------------------------------------------------- masthead on small screens
   Below 700px the search label and the year/level chip are dropped rather than
   allowed to overflow. The icon and the toggle remain, so nothing is lost —
   only the words that were restating them. */
@media (max-width: 700px) {
  .masthead-inner { gap: var(--s-3); }
  .masthead-meta #user-chip { display: none; }
  .search-btn .search-label,
  .search-btn kbd { display: none; }
  .search-btn { padding: var(--s-1) var(--s-2); min-width: 0; }
  .theme-toggle { min-width: 0; padding: var(--s-1) var(--s-2); }
}
@media (max-width: 460px) {
  .masthead-meta .btn-quiet[href="#/account"] { padding: var(--s-1) var(--s-2); }
}
.search-icon { flex: none; opacity: 0.8; }

/* ================================================================== diagrams
   Inline SVG so it inherits the theme, scales without blurring and works
   offline. Colours come from tokens, never hard-coded, or dark mode breaks. */
.dg { width: 100%; height: auto; max-width: 420px; display: block; }
.dg-axis { stroke: var(--ink); stroke-width: 1.4; }
.dg-curve { stroke: var(--unit-colour, var(--accent)); stroke-width: 2; fill: none; }
.dg-curve-2 { stroke: var(--warn); stroke-dasharray: none; }
.dg-limit { stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 5 3; }
.dg-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.75; }
.dg-gap { stroke: var(--bad); stroke-width: 2.5; }
.dg-dot { fill: var(--ink); }
.dg-shift { stroke: var(--muted); stroke-width: 1.4; }
.dg-shifthead { fill: var(--muted); }
.dg-area { fill: var(--accent); opacity: 0.16; }
.dg-area-loss { fill: var(--bad); opacity: 0.3; }
.dg-area-rev { fill: var(--good); opacity: 0.22; }
.dg-area-cs { fill: var(--accent); opacity: 0.2; }
.dg-area-ps { fill: var(--good); opacity: 0.2; }
.dg-axis-label { fill: var(--muted); font-family: var(--f-sans); font-size: 10px; }
.dg-label { fill: var(--ink); font-family: var(--f-sans); font-size: 10px; font-weight: 600; }
.dg-label-key { fill: var(--muted); font-weight: 500; font-size: 9px; }
.dg-note { fill: var(--muted); font-weight: 400; font-size: 9px; }
.dg-tick { fill: var(--muted); font-family: var(--f-mono); font-size: 9px; }

.dg-card { border: 1px solid var(--rule); border-radius: var(--r-lg);
  background: var(--raised); padding: var(--s-4); margin-bottom: var(--s-4); }
.dg-card h3 { margin: 0 0 var(--s-1); font-family: var(--f-sans); font-size: var(--t-base); }
.dg-card .dg-what { color: var(--muted); font-size: var(--t-sm); margin-bottom: var(--s-3); }
.dg-figure { display: flex; justify-content: center; padding: var(--s-2) 0 var(--s-3); }
.dg-technique { border-left: 2px solid var(--warn); background: var(--warn-wash);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--t-sm); }
.dg-technique b { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--warn); display: block; margin-bottom: 2px; }
@media (min-width: 1000px) {
  .dg-card { display: grid; grid-template-columns: 420px 1fr; gap: var(--s-5); align-items: start; }
  .dg-card h3, .dg-card .dg-what, .dg-card .dg-technique { grid-column: 2; }
  .dg-figure { grid-column: 1; grid-row: 1 / span 3; padding: 0; }
}

/* ================================================================= motion
   Every animation here is doing a job: showing that something arrived, that a
   number changed, or that an action registered. None of it is scroll-triggered
   decoration, and all of it is off under prefers-reduced-motion. */

@keyframes dg-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dg-pop { 0% { transform: scale(0.86); opacity: 0; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
@keyframes dg-float-up { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
@keyframes dg-flame { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }
@keyframes dg-shine { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes dg-ring { from { stroke-dashoffset: var(--ring-circumference); } }

/* Views arrive rather than blink into place. Staggered so the eye follows. */
.view > * { animation: dg-rise var(--dur-slow) var(--ease) both; }
.view > *:nth-child(2) { animation-delay: 40ms; }
.view > *:nth-child(3) { animation-delay: 80ms; }
.view > *:nth-child(4) { animation-delay: 120ms; }

.card, .dg-card, .define { animation: dg-rise var(--dur-base) var(--ease) both; }

/* ------------------------------------------------------------- streak + xp */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
@media (max-width: 640px) { .stat-row { grid-template-columns: 1fr 1fr; } }

.stat {
  border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--raised);
  padding: var(--s-4); position: relative; overflow: hidden;
  transition: transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}
.stat:hover { transform: translateY(-2px); border-color: var(--muted); }
.stat-value { font-family: var(--f-mono); font-size: var(--t-xl); font-weight: 600;
  line-height: 1; font-variant-numeric: tabular-nums; display: block; }
.stat-label { font-size: var(--t-sm); color: var(--muted); margin-top: var(--s-1); display: block; }
.stat-sub { font-size: var(--t-xs); color: var(--muted); margin-top: var(--s-1); display: block; }

.streak-flame { display: inline-block; animation: dg-flame 1.8s ease-in-out infinite; }
.stat-hot .stat-value { color: var(--warn); }

/* The level ring: a real fraction of a circle, drawn once and animated in. */
.ring { --ring-circumference: 176; display: block; }
.ring circle { fill: none; stroke-width: 6; }
.ring .ring-track { stroke: var(--rule); }
.ring .ring-fill { stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  transform: rotate(-90deg); transform-origin: 50% 50%;
  animation: dg-ring var(--dur-slow) var(--ease) both; }
.ring-wrap { position: relative; width: 68px; height: 68px; flex: none; }
.ring-text { position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--f-mono); font-size: var(--t-md); font-weight: 600; }

/* ------------------------------------------------------- reward feedback */
#reward-host { position: fixed; inset: 0; pointer-events: none; z-index: 120;
  display: grid; place-items: center; }
.reward-pop { font-family: var(--f-mono); font-size: var(--t-lg); font-weight: 600;
  color: var(--good); animation: dg-float-up 1.4s var(--ease) both; }
.level-up { pointer-events: auto; background: var(--raised); border: 1px solid var(--good);
  border-radius: var(--r-lg); padding: var(--s-5) var(--s-6); box-shadow: var(--e-2);
  text-align: center; animation: dg-pop var(--dur-slow) var(--ease) both; max-width: 320px; }
.level-up h3 { font-size: var(--t-lg); margin-bottom: var(--s-2); }
.level-up .lv { font-family: var(--f-mono); font-size: var(--t-2xl); color: var(--good);
  display: block; line-height: 1; margin-bottom: var(--s-2); }

/* A skeleton that shimmers reads as loading; a static one reads as broken. */
.skeleton { background: linear-gradient(90deg, var(--sunken) 25%, var(--rule-soft) 50%, var(--sunken) 75%);
  background-size: 200% 100%; animation: dg-shine 1.4s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .view > *, .card, .dg-card, .define, .ring .ring-fill,
  .reward-pop, .level-up, .streak-flame, .skeleton { animation: none !important; }
  .stat:hover { transform: none; }
}
