/* SysDesign Atlas — iPad / offline edition.

   Sized for iPad Air 11" (820×1180 pt portrait, 1180×820 landscape) but fluid
   from phone width up. At ≥1024px the curriculum sidebar is pinned; below that
   it slides over as a drawer.

   The build splices the website's prose styles (callouts, diagrams, tables,
   code, viz figures) in at the marker further down, so the article body looks
   exactly like the site. Everything above the marker defines the variables
   those rules read; everything below adapts them for touch. */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-inset: #eef0f4;
  --panel: #ffffff;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #0d1117;
  --text-soft: #4a5462;
  --text-dim: #78828f;
  --accent: #2563eb;
  --accent-text: #1d4ed8;
  --grid: rgba(37, 99, 235, 0.055);
  --glow: rgba(37, 99, 235, 0.14);
  --code-bg: #f6f7f9;
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --scrim: rgba(15, 23, 42, 0.32);
  --good: #059669;

  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --font-serif: 'Iowan Old Style', Charter, Georgia, 'Times New Roman', serif;

  --prose-size: 17.5px;
  --prose-scale: 1;
  --prose-leading: 1.72;
  --prose-face: var(--font-sans);
  --read-max: 740px;
  --width-scale: 1;

  --sb-w: 300px;
  --bar-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: clamp(20px, 5vw, 44px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root.sepia {
  --bg: #f6f0e4;
  --bg-soft: #efe7d7;
  --bg-inset: #e6dbc6;
  --panel: #fbf6ec;
  --border: #e0d3bb;
  --border-strong: #cbb999;
  --text: #2a2116;
  --text-soft: #4e4130;
  --text-dim: #877760;
  --accent: #b45309;
  --accent-text: #9a4508;
  --grid: rgba(180, 83, 9, 0.05);
  --glow: rgba(180, 83, 9, 0.13);
  --code-bg: #f0e8d8;
  --shadow-lg: 0 12px 40px rgba(60, 40, 10, 0.14);
  --scrim: rgba(40, 28, 10, 0.3);
  --good: #4d7c0f;
}

:root.dark {
  --bg: #07090e;
  --bg-soft: #0c1017;
  --bg-inset: #131924;
  --panel: #0d1219;
  --border: #1e2633;
  --border-strong: #2d3949;
  --text: #e8eef7;
  --text-soft: #a3b0c2;
  --text-dim: #6e7d91;
  --accent: #38bdf8;
  --accent-text: #7dd3fc;
  --grid: rgba(56, 189, 248, 0.05);
  --glow: rgba(56, 189, 248, 0.16);
  --code-bg: #0b1017;
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.5);
  --good: #34d399;
}

:root[data-size='s']  { --prose-size: 16px; }
:root[data-size='l']  { --prose-size: 19px; }
:root[data-size='xl'] { --prose-size: 20.5px; }
:root[data-leading='tight'] { --prose-leading: 1.55; }
:root[data-leading='loose'] { --prose-leading: 1.9; }
:root[data-width='narrow'] { --width-scale: 0.86; }
:root[data-width='wide']   { --width-scale: 1.18; }
:root[data-font='serif']   { --prose-face: var(--font-serif); }

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + var(--safe-t) + 16px);
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

::selection { background: var(--glow); color: var(--text); }

button { font: inherit; color: inherit; }
button, a, [role='button'] { touch-action: manipulation; }
[hidden] { display: none !important; }

.ic { display: block; flex: none; }


/* ---------- prose ---------- */

.prose {
  font-size: calc(var(--prose-size) * var(--prose-scale));
  line-height: var(--prose-leading);
  font-family: var(--prose-face);
  color: var(--text-soft);
  min-width: 0;

  /* Every framed block — code, ASCII diagram, table, callout, viz figure —
     insets its contents by exactly this much, so the first character of each
     one lands on the same vertical line as the next. They used to range from
     1rem to 1.4rem, which is small enough to look accidental and large enough
     to see. */
  --figure-pad: 1.15rem;
}

/* Nothing in the prose may widen the reading column. Wide monospace blocks
   scroll inside their own frame instead of pushing the page sideways. */
.prose > * { max-width: 100%; min-width: 0; }
.prose :where(pre, figure, table, .callout) { max-width: 100%; }

/* Slim scrollbars inside content blocks — a full-width bar under a diagram
   reads as a layout bug rather than an affordance. */
.diagram pre::-webkit-scrollbar,
.codeblock pre::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar { height: 7px; }
.diagram pre::-webkit-scrollbar-thumb,
.codeblock pre::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 0;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text);
  letter-spacing: -0.022em;
  scroll-margin-top: 100px;
  position: relative;
}

.prose h2 {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 3.2rem 0 1rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
}

.prose h3 { font-size: 1.28rem; font-weight: 660; margin: 2.2rem 0 0.7rem; }
.prose h4 { font-size: 1.05rem; font-weight: 660; margin: 1.7rem 0 0.5rem; color: var(--text-soft); }

.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.45rem; }
.prose li::marker { color: var(--accent); }
.prose li > ul, .prose li > ol { margin: 0.45rem 0 0; }
.prose strong { color: var(--text); font-weight: 640; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.2rem 0; }

.prose a {
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 0.15s, color 0.15s;
}
.prose a:hover { border-bottom-color: var(--accent); }

.anchor {
  position: absolute;
  left: -1.1em;
  color: var(--border-strong);
  opacity: 0;
  border: 0 !important;
  font-weight: 400;
  transition: opacity 0.15s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  color: var(--text);
  white-space: nowrap;
}

/* ---------- code blocks ---------- */

.codeblock {
  position: relative;
  margin: 0 0 1.3rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
}
.code-lang {
  position: absolute;
  top: 0.55rem;
  right: var(--figure-pad);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  z-index: 1;
}
.codeblock pre {
  margin: 0;
  padding: 1.1rem var(--figure-pad);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  background: transparent !important;
}
.codeblock code { font-family: var(--font-mono); }

/* Shiki dual-theme switching */
:root.dark .shiki, :root.dark .shiki span {
  color: var(--shiki-dark) !important;
  background-color: transparent !important;
}
:root:not(.dark) .shiki, :root:not(.dark) .shiki span {
  color: var(--shiki-light) !important;
  background-color: transparent !important;
}

/* ---------- svg diagrams (```viz) ---------- */

.viz {
  margin: 0 0 1.5rem;
  padding: 1.4rem var(--figure-pad) 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 62%),
    var(--bg-soft);
  overflow: hidden;
}
.viz svg { display: block; width: 100%; height: auto; max-height: 420px; margin-inline: auto; }
.viz figcaption {
  margin-top: .85rem;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* nodes fade+rise in sequence */
.viz-node { animation: viz-in .5s both cubic-bezier(.2,0,0,1); animation-delay: var(--d, 0s); }
.viz-node rect {
  fill: color-mix(in srgb, var(--a, #38bdf8) 12%, transparent);
  stroke: color-mix(in srgb, var(--a, #38bdf8) 55%, transparent);
  stroke-width: 1.1;
}
.viz-label {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 650;
}
.viz-label.sm { font-size: 11px; }
.viz-sub {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* edges draw themselves, then a packet travels along them */
.viz-edge {
  fill: none;
  stroke: url(#ve);
  stroke-width: 1.4;
  color: var(--accent);
  stroke-dasharray: 620;
  animation: viz-draw 1.1s both ease-out;
}
.viz-edge.is-dashed { stroke-dasharray: 5 6; animation: none; opacity: .7; }
.viz-edge-label {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 9.5px;
}
.viz-dot { fill: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); }

/* axes */
.viz-axis { animation: viz-in .55s both cubic-bezier(.2,0,0,1); animation-delay: var(--d, 0s); }
.viz-axis line {
  stroke: var(--a, #38bdf8);
  stroke-width: 2;
  color: var(--a, #38bdf8);
  stroke-linecap: round;
  stroke-dasharray: 300;
  animation: viz-draw 1s both ease-out;
  animation-delay: var(--d, 0s);
}
.viz-origin { fill: var(--text-dim); }

/* ring */
.viz-ring {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.2;
  stroke-dasharray: 4 7;
  transform-origin: center;
  animation: viz-spin 60s linear infinite;
}
.viz-ringnode { animation: viz-pop .45s both cubic-bezier(.2,0,0,1); animation-delay: var(--d, 0s); }
.viz-ringnode circle {
  fill: color-mix(in srgb, var(--a, #38bdf8) 16%, var(--panel));
  stroke: var(--a, #38bdf8);
  stroke-width: 1.4;
}
.viz-key { animation: viz-pop .4s both; animation-delay: var(--d, 0s); }
.viz-key circle { fill: var(--text-dim); }

@keyframes viz-in   { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes viz-pop  { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes viz-draw { from { stroke-dashoffset: 620; } to { stroke-dashoffset: 0; } }
@keyframes viz-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .viz-node, .viz-axis, .viz-ringnode, .viz-key, .viz-edge, .viz-axis line { animation: none !important; opacity: 1; }
  .viz-edge { stroke-dasharray: none; }
  .viz-ring { animation: none; }
  .viz-dot { display: none; }
}

/* ---------- steps (numbered sequences) ---------- */

.viz-steps { padding: 1.5rem var(--figure-pad) 1.1rem; }

.vs-list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}
/* the spine, drawn behind the badges */
.vs-list::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent) 55%, transparent),
    color-mix(in srgb, #a78bfa 45%, transparent),
    transparent);
  transform-origin: top;
  animation: vs-spine .8s both cubic-bezier(.2, 0, 0, 1);
}

.vs-list li {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin: 0 0 1.05rem;
  padding: 0;
  animation: vs-in .45s both cubic-bezier(.2, 0, 0, 1);
  animation-delay: var(--d, 0s);
}
.vs-list li:last-child { margin-bottom: 0; }
.vs-list li::marker { content: none; }

.vs-n {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--a, #38bdf8);
  background: color-mix(in srgb, var(--a, #38bdf8) 14%, var(--bg-soft));
  border: 1.5px solid color-mix(in srgb, var(--a, #38bdf8) 55%, transparent);
  box-shadow: 0 0 0 4px var(--bg-soft);
}

.vs-body { display: block; padding-top: 0.28rem; min-width: 0; }
.vs-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}
.vs-sub {
  display: block;
  margin-top: 0.22rem;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-soft);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.vs-note {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

@keyframes vs-in    { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes vs-spine { from { transform: scaleY(0); } to { transform: scaleY(1); } }

@media (prefers-reduced-motion: reduce) {
  .vs-list li, .vs-list::before { animation: none; opacity: 1; transform: none; }
}

/* ---------- ascii diagrams ---------- */

/* The frame stays put and the CODE scrolls inside it. Scrolling the figure
   itself loses the right padding at the end of the scroll and drags the
   gradient border out of alignment, which is what made wide ASCII art look
   broken rather than scrollable. */
.diagram {
  position: relative;
  margin: 0 0 1.4rem;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  background:
    linear-gradient(var(--bg-soft), var(--bg-soft)) padding-box,
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent) 45%, transparent),
      color-mix(in srgb, #a78bfa 35%, transparent)) border-box;
  border: 1px solid transparent;
}
.diagram::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 100% at 50% 0%, var(--glow), transparent 70%);
  pointer-events: none;
  opacity: 0.55;
  z-index: 0;
}
.diagram pre {
  margin: 0;
  position: relative;
  z-index: 1;
  padding: 1.3rem var(--figure-pad);
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.diagram code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre;
  color: var(--text-soft);
}

/* Glyph-level hierarchy: connectors recede, flow direction pops,
   labels read as labels. Turns box-drawing art into a real figure. */
.diagram .d-line { color: color-mix(in srgb, var(--text-dim) 62%, transparent); }
.diagram .d-arrow {
  color: var(--accent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 45%, transparent);
}
.diagram .d-key {
  color: var(--text);
  font-weight: 600;
  letter-spacing: .01em;
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  /* Shadows appear at whichever edge still has content off-screen, so a
     scrollable table announces itself instead of silently clipping. */
  background-image:
    linear-gradient(to right, var(--panel), transparent),
    linear-gradient(to left, var(--panel), transparent),
    linear-gradient(to right, color-mix(in srgb, var(--text) 12%, transparent), transparent),
    linear-gradient(to left, color-mix(in srgb, var(--text) 12%, transparent), transparent);
  background-position: left center, right center, left center, right center;
  background-size: 32px 100%, 32px 100%, 12px 100%, 12px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  /* Only scrolls when genuinely too narrow; above this it wraps instead. */
  min-width: 420px;
  font-size: 13.5px;
  line-height: 1.55;
}

.prose th,
.prose td {
  padding: 0.7rem var(--figure-pad);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  /* The fix: headers used to be nowrap, which forced the whole table wide. */
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.prose thead th {
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.4;
  padding-block: 0.62rem;
  border-bottom: 1px solid var(--border-strong);
}

/* First column is almost always the label being described — give it weight
   and stop it collapsing to one word per line. */
.prose tbody td:first-child {
  color: var(--text);
  font-weight: 600;
  min-width: 8.5rem;
}

/* Keep short numeric/verdict columns from stealing width. */
.prose td:only-child { font-weight: 400; }

.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr { transition: background 0.12s; }
.prose tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* Inline code inside a cell must be allowed to wrap, or one long identifier
   blows out the column. */
.prose td .inline-code,
.prose th .inline-code {
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 640px) {
  /* Tighten the shared inset rather than the table's alone — on a phone every
     frame needs the room back, and they need to keep agreeing with each other. */
  .prose { --figure-pad: 0.8rem; }
  .prose table { font-size: 12.5px; }
  .prose th, .prose td { padding-block: 0.55rem; }
  .prose tbody td:first-child { min-width: 6.5rem; }
}

/* ---------- callouts ---------- */

.callout {
  --c: var(--accent);
  position: relative;
  margin: 0 0 1.4rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 32%, transparent);
  background: color-mix(in srgb, var(--c) 6%, var(--panel));
  overflow: hidden;
}
.callout::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--c), transparent);
}
.callout-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem var(--figure-pad) 0.1rem;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--c);
}
.callout-head::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}
.callout-body { padding: 0.35rem var(--figure-pad) 0.1rem; font-size: 15.5px; }
.callout-body > :last-child { margin-bottom: 0.9rem; }

.callout-tip      { --c: #10b981; }
.callout-warn,
.callout-trap     { --c: #f43f5e; }
.callout-interview{ --c: #38bdf8; }
.callout-math,
.callout-derive   { --c: #f59e0b; }
.callout-goat     { --c: #a78bfa; }
.callout-paper    { --c: #818cf8; }
.callout-exercise { --c: #2dd4bf; }
.callout-note     { --c: #64748b; }
.callout-predict  { --c: #d946ef; }

/* A code block inside a callout still has to be able to scroll — the callout
   clips, so without this the last characters of a wide line simply vanish. */
.callout-body { min-width: 0; }
.callout .codeblock,
.callout .diagram,
.callout .table-wrap { max-width: 100%; }
.callout .codeblock { margin-bottom: 0.9rem; }

/* Derivations are arithmetic; monospace keeps the columns aligned. */
.callout-derive .callout-body { font-family: var(--font-mono); font-size: 14px; }
.callout-derive .callout-body p,
.callout-derive .callout-body li { font-family: inherit; }

/* A primary source is a pointer, not prose — tighten it. */
.callout-paper .callout-body { font-size: 14.5px; }
.callout-paper .callout-body a { text-decoration-thickness: 1px; }

/* ---------- recall cards ----------
   "Check yourself" at the end of a topic: each card is a question with its
   answer folded away, so you have to try before you look. Works with no
   script at all; the iPad edition adds self-grading and spaced review. */

.recall { display: grid; gap: 0.6rem; margin: 0 0 1.4rem; }
.recall-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.recall-card > summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.8rem var(--figure-pad);
  cursor: pointer;
  list-style: none;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}
.recall-card > summary::-webkit-details-marker { display: none; }
.recall-card > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.recall-show {
  flex: none;
  padding-top: 0.15rem;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  color: var(--accent-text);
}
.recall-card[open] .recall-show { opacity: 0; }
.recall-a {
  margin: 0 var(--figure-pad);
  padding: 0.7rem 0 0.95rem;
  border-top: 1px dashed var(--border-strong);
  font-size: 15.5px;
  line-height: 1.62;
  color: var(--text-soft);
}

.prose blockquote {
  margin: 0 0 1.2rem;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-dim);
  font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }




/* ---------- prose, adapted for touch and for the reader's size setting ---------- */

.prose { color: var(--text-soft); }
.prose h2 { font-size: 1.55em; scroll-margin-top: calc(var(--bar-h) + var(--safe-t) + 16px); }
.prose h3 { font-size: 1.2em; scroll-margin-top: calc(var(--bar-h) + var(--safe-t) + 16px); }
.prose h4 { font-size: 1.02em; }

/* Monospace blocks follow the text-size setting instead of staying at a
   fixed pixel size, so XL is genuinely larger everywhere. */
.codeblock pre { font-size: calc(var(--prose-size) * 0.76); }
.diagram code { font-size: calc(var(--prose-size) * 0.72); }
.prose table { font-size: calc(var(--prose-size) * 0.8); }
.callout-body { font-size: calc(var(--prose-size) * 0.93); }
.callout-derive .callout-body { font-size: calc(var(--prose-size) * 0.82); }
.callout-paper .callout-body { font-size: calc(var(--prose-size) * 0.88); }
.callout-head { font-size: calc(var(--prose-size) * 0.76); }

/* Horizontal scrollers inside the article — momentum, and no rubber-banding
   the whole page sideways. */
.diagram pre, .codeblock pre, .table-wrap {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Heading permalinks are a hover affordance; there is no hover here. */
.anchor { display: none; }

@media (hover: none) {
  .prose tbody tr:hover { background: transparent; }
  .prose a:hover { border-bottom-color: color-mix(in srgb, var(--accent) 35%, transparent); }
}

/* External links can't open on a plane — say so instead of failing silently. */
.prose a[target='_blank']::after {
  content: '↗';
  font-size: 0.75em;
  margin-left: 0.15em;
  opacity: 0.6;
}

/* Kept as two rules: a browser that doesn't know ::highlight drops the whole
   selector list it appears in. */
.prose mark.atlas-hit {
  background: color-mix(in srgb, #facc15 55%, transparent);
  color: var(--text);
  border-radius: 3px;
}
::highlight(atlas-hit) {
  background-color: color-mix(in srgb, #facc15 55%, transparent);
  color: var(--text);
}

/* ---------- sidebar ---------- */

#atlas-sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(var(--sb-w) + var(--safe-l));
  padding-left: var(--safe-l);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}

.sb-head {
  flex: none;
  padding: calc(var(--safe-t) + 12px) 14px 8px;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 4px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.sb-brand img { border-radius: 8px; }

.sb-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.sb-main { display: grid; gap: 2px; margin-top: 10px; }
.sb-main a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 15px;
  font-weight: 560;
}
.sb-main a.active { background: var(--bg-inset); color: var(--text); }
.sb-main .sb-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--bg-inset);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 650;
  line-height: 22px;
  text-align: center;
}

.sb-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px 24px;
  border-top: 1px solid var(--border);
}

.sb-group-title {
  padding: 18px 10px 6px;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sb-sec-row { display: flex; align-items: center; }
.sb-sec-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 4px 0 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.sb-sec-link .ic { color: var(--a); }
.sb-sec-link.active { background: color-mix(in srgb, var(--a) 12%, transparent); }
.sb-sec-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count { font-size: 12px; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sb-count.full { color: var(--good); }

.sb-toggle {
  flex: none;
  width: 40px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.sb-toggle .ic { transition: transform 0.2s var(--ease); }
.sb-sec.open .sb-toggle .ic { transform: rotate(90deg); }

.sb-topics {
  display: none;
  list-style: none;
  margin: 2px 0 8px 19px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--border);
}
.sb-sec.open .sb-topics { display: block; }
.sb-topics a {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 8px 8px 6px;
  border-radius: 8px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
}
.sb-topics a.active {
  background: color-mix(in srgb, var(--a) 13%, transparent);
  color: var(--text);
  font-weight: 600;
}
.sb-dot {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
}
.sb-topics a.done .sb-dot { background: var(--good); border-color: var(--good); }
.sb-topics a.done .sb-dot::after {
  content: '';
  width: 6px;
  height: 3.5px;
  margin-top: -1.5px;
  border: solid #fff;
  border-width: 0 0 1.6px 1.6px;
  transform: rotate(-45deg);
}
.sb-topics a.done { color: var(--text-dim); }
.sb-topics a.active.done { color: var(--text); }

.sb-foot {
  flex: none;
  padding: 10px 16px calc(var(--safe-b) + 12px);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

#atlas-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

:root.sb-open #atlas-sidebar { transform: none; box-shadow: var(--shadow-lg); }
:root.sb-open #atlas-scrim { opacity: 1; pointer-events: auto; }

@media (min-width: 1024px) {
  #atlas-sidebar { transform: none; }
  #atlas-scrim { display: none; }
  :root:not(.sb-collapsed) #atlas-main { margin-left: calc(var(--sb-w) + var(--safe-l)); }
  :root.sb-collapsed #atlas-sidebar { transform: translateX(-100%); }
  :root.sb-open #atlas-sidebar { box-shadow: none; }
  #atlas-main { transition: margin-left 0.3s var(--ease); }
}

/* ---------- top bar ---------- */

#atlas-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  height: calc(var(--bar-h) + var(--safe-t));
  padding: var(--safe-t) calc(8px + var(--safe-r)) 0 8px;
  /* Solid, not frosted glass: text scrolling underneath must never compete
     with the title, and a blur running on every scroll frame costs battery
     over a long flight. */
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
#atlas-bar.scrolled { border-bottom-color: var(--border); }

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:active { background: var(--bg-inset); }
.icon-btn.on { color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; }

.bar-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
#atlas-bar:not(.is-topic) .topic-only { display: none; }

.bar-title {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#atlas-bar.show-title .bar-title { opacity: 1; transform: none; }
.bar-kicker {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--a, var(--text-dim));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-name {
  display: block;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#atlas-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  transition: opacity 0.2s;
}
#atlas-bar.is-topic #atlas-progress { opacity: 1; }

/* ---------- views ---------- */

#atlas-view {
  padding: 8px calc(var(--gutter) + var(--safe-r)) calc(72px + var(--safe-b)) var(--gutter);
  animation: view-in 0.24s var(--ease);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.wrap { max-width: 980px; margin: 0 auto; }
.reading { max-width: calc(var(--read-max) * var(--width-scale)); margin: 0 auto; }

.eyebrow {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); background: var(--bg-inset); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root.dark .btn.primary { color: #04121c; }
.btn.primary:active { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn.danger { color: #e11d48; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }

.bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-inset);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--a, var(--accent));
  transition: width 0.4s var(--ease);
}

.empty {
  padding: 18px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-dim);
  font-size: 14.5px;
}

/* ---------- home ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 0 26px;
}
.hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(2.1rem, 4.4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}
.hero p { margin: 0; max-width: 560px; color: var(--text-soft); font-size: 16.5px; }
.hero-text { flex: 1; min-width: 0; }

.ring { position: relative; flex: none; width: 116px; height: 116px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { stroke: var(--bg-inset); }
.ring .ring-fg { stroke: url(#atlas-ring-grad); transition: stroke-dashoffset 0.6s var(--ease); }
.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.1;
}
.ring-label b { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.ring-label span { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }

.home-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 760px) { .home-grid { grid-template-columns: 1.5fr 1fr; } }

.continue {
  position: relative;
  display: block;
  padding: 20px 22px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
.continue::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--a) 14%, transparent), transparent 60%);
  pointer-events: none;
}
.continue > * { position: relative; }
.continue .eyebrow { color: var(--a); }
.continue h3 { margin: 8px 0 4px; font-size: 21px; line-height: 1.25; letter-spacing: -0.02em; }
.continue p { margin: 0 0 14px; color: var(--text-soft); font-size: 14.5px; }
.continue .meta-row { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-dim); }
.continue .bar-track { flex: 1; }
.continue .cta { margin-top: 16px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { display: flex; flex-direction: column; justify-content: center; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }

.install { padding: 18px 20px; margin-bottom: 14px; }
.install h3 { margin: 0 0 6px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.install ol { margin: 8px 0 0; padding-left: 1.3rem; color: var(--text-soft); font-size: 15px; }
.install li { margin-bottom: 4px; }
.install p { margin: 0; color: var(--text-soft); font-size: 15px; }
.install .bar-track { margin-top: 12px; }
.install-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.install-row ol { margin: 6px 0 0; padding-left: 1.2rem; color: var(--text-soft); font-size: 14px; }
.install-row li { margin-bottom: 3px; }
.install-row p { margin: 4px 0 0; color: var(--text-soft); font-size: 14px; }
.install-row .install-actions { margin-top: 8px; }

.review-strip { margin: 22px 0 6px; }
.review-strip h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a, var(--accent)); }
.chip.done { color: var(--text-dim); }
.chip.done .dot { background: var(--good); }

.group { margin-top: 34px; }
.group-head h2 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.group-head p { margin: 4px 0 14px; color: var(--text-dim); font-size: 14.5px; }

.sec-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sec-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s, border-color 0.15s;
}
.sec-card:active { transform: scale(0.985); }
.sec-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--a), transparent);
}
.sec-ico {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--a) 14%, transparent);
  color: var(--a);
}
.sec-card h3 { margin: 0; font-size: 17px; letter-spacing: -0.015em; }
.sec-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sec-foot { margin-top: auto; display: grid; gap: 7px; font-size: 12.5px; color: var(--text-dim); }
.sec-foot .row { display: flex; justify-content: space-between; }

/* ---------- section ---------- */

.sec-head { padding: 22px 0 8px; }
.sec-head .sec-ico { width: 52px; height: 52px; border-radius: 15px; margin-bottom: 14px; }
.sec-head h1 { margin: 6px 0 8px; font-size: clamp(1.9rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.sec-head p { margin: 0 0 18px; max-width: 640px; color: var(--text-soft); font-size: 16.5px; }
.sec-progress { display: flex; align-items: center; gap: 14px; max-width: 520px; font-size: 13.5px; color: var(--text-dim); }
.sec-progress .bar-track { flex: 1; }
.sec-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.topic-list { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 10px; }
.topic-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s;
}
.topic-row:active { transform: scale(0.99); }
.topic-num {
  flex: none;
  width: 30px;
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--a);
}
.topic-body { flex: 1; min-width: 0; }
.topic-body h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.012em; line-height: 1.3; }
.topic-body p { margin: 0 0 8px; color: var(--text-soft); font-size: 14px; line-height: 1.5; }
.topic-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--text-dim); }
.topic-state {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: #fff;
}
.topic-row.done .topic-state { background: var(--good); border-color: var(--good); }
.topic-row.done h3 { color: var(--text-soft); }
.topic-state.partial { border-color: var(--a); border-style: dashed; }

/* ---------- topic ---------- */

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 18px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.crumb-sec {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--a);
  font-weight: 650;
  text-decoration: none;
}

.topic-title {
  margin: 10px 0 0;
  font-size: clamp(2rem, 3.6vw, 2.6rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.032em;
  color: var(--text);
}
.topic-summary { margin: 14px 0 0; font-size: 18.5px; line-height: 1.55; color: var(--text-soft); }

.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}
.badge.tint {
  border-color: transparent;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: color-mix(in srgb, var(--c) 72%, var(--text));
  font-weight: 700;
}

.prereq {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  font-size: 14.5px;
}
.prereq-label { font-size: 12px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.prereq .chips { gap: 6px; }
.prereq .chip { min-height: 34px; font-size: 13.5px; }
.prereq-unlocks { margin-top: 12px; color: var(--text-soft); }
.prereq-unlocks b { color: var(--text); }

.resume {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  font-size: 14.5px;
  color: var(--text-soft);
}
.resume span { flex: 1; }

.topic .prose { margin-top: 30px; }

.finish {
  margin-top: 48px;
  padding: 22px;
  text-align: center;
}
.finish h3 { margin: 0 0 4px; font-size: 18px; }
.finish p { margin: 0 0 16px; font-size: 14.5px; color: var(--text-dim); }
.finish .btn-done { min-width: 220px; }
.finish.is-done .btn-done { background: color-mix(in srgb, var(--good) 14%, var(--panel)); border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); }
.conf { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; font-size: 14px; color: var(--text-dim); }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--bg-inset);
}
.seg button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
:root.dark .seg button.on { background: var(--border-strong); }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 0 6px; }

.notes { margin-top: 16px; padding: 18px; }
.notes-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.notes-head b { font-size: 15px; }
.notes-head span { font-size: 12.5px; color: var(--text-dim); }
.notes textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  font: 16px/1.55 var(--font-sans); /* ≥16px or iOS zooms on focus */
  resize: vertical;
}
.notes textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }

.pn { display: grid; gap: 12px; margin-top: 28px; grid-template-columns: 1fr 1fr; }
.pn a {
  display: block;
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.pn a:active { transform: scale(0.99); }
.pn small {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pn .next small { justify-content: flex-end; }
.pn b { display: block; margin-top: 5px; font-size: 15.5px; line-height: 1.35; }
.pn .next { text-align: right; grid-column: 2; }
.pn em { display: block; margin-top: 3px; font-style: normal; font-size: 12.5px; color: var(--a, var(--text-dim)); }

.topic-loading { padding-top: 40px; }
.skel {
  height: 14px;
  margin: 14px 0;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--bg-inset), var(--bg-soft), var(--bg-inset));
  background-size: 400px 100%;
  animation: skel 1.3s linear infinite;
}
@keyframes skel { from { background-position: -400px 0; } to { background-position: 400px 0; } }

/* ---------- library & settings ---------- */

.page-head { padding: 22px 0 6px; }
.page-head h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; }
.page-head p { margin: 6px 0 0; color: var(--text-soft); }

.block { margin-top: 30px; }
.block > h2 { margin: 0 0 12px; font-size: 13px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); }

.list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--border); }
.list > * { background: var(--panel); }
.row-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
}
.row-link:active { background: var(--bg-inset); }
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-size: 15.5px; font-weight: 620; line-height: 1.35; }
.row-main small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-kicker { color: var(--a); font-weight: 650; }
.row-side { flex: none; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.row-link .ic.chev { color: var(--text-dim); }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 12px 16px;
}
.set-row > div:first-child { min-width: 0; }
.set-row b { display: block; font-size: 15.5px; font-weight: 600; }
.set-row small { display: block; font-size: 13px; color: var(--text-dim); }
.set-row.stack { flex-direction: column; align-items: stretch; }

.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: var(--text-dim); vertical-align: 1px; }
.status-dot.ok { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.status-dot.busy { background: #f59e0b; animation: pulse 1.4s ease-in-out infinite; }
.status-dot.bad { background: #f43f5e; }
@keyframes pulse { 50% { opacity: 0.35; } }

.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14.5px; color: var(--text-soft); padding: 16px; }
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg-soft);
  font: 600 12.5px/1.6 var(--font-mono);
  text-align: center;
  color: var(--text);
}

/* ---------- popover (reading settings, contents) ---------- */

#atlas-popover {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.pop {
  position: absolute;
  top: calc(var(--safe-t) + var(--bar-h) + 6px);
  right: calc(10px + var(--safe-r));
  width: min(370px, calc(100vw - 20px));
  max-height: calc(100dvh - var(--safe-t) - var(--bar-h) - var(--safe-b) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s var(--ease);
  transform-origin: top right;
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.pop h4 { margin: 2px 2px 12px; font-size: 13px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.pop-field { margin-bottom: 14px; }
.pop-field:last-child { margin-bottom: 0; }
.pop-field label { display: block; margin: 0 2px 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.theme-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--border-strong); vertical-align: -1px; }

.toc-list { display: grid; gap: 1px; margin: 0 -6px; }
.toc-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.toc-item.lvl-3 { padding-left: 26px; font-size: 13.5px; color: var(--text-dim); }
.toc-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); font-weight: 600; }
.toc-item:active { background: var(--bg-inset); }

/* ---------- search ---------- */

#atlas-search {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(var(--safe-t) + 18px) 14px 14px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.15s;
}
@keyframes fade-in { from { opacity: 0; } }
.search-panel {
  width: min(720px, 100%);
  max-height: calc(100dvh - var(--safe-t) - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s var(--ease);
  transform-origin: top center;
}
.search-field {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.search-field input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font-size: 18px;
  -webkit-appearance: none;
  appearance: none;
}
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-cancel {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}
.sr-label { padding: 10px 12px 6px; font-size: 12px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); }
.sr-item {
  display: block;
  padding: 11px 12px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.sr-item.sel { background: var(--bg-inset); }
.sr-item:active { background: var(--bg-inset); }
.sr-title { display: flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 620; color: var(--text); }
.sr-title .done-tick { color: var(--good); font-size: 13px; }
.sr-meta { margin-top: 2px; font-size: 12.5px; color: var(--text-dim); }
.sr-meta .k { color: var(--a); font-weight: 650; }
.sr-snip { margin-top: 5px; font-size: 14px; line-height: 1.5; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-snip mark, .sr-title mark, .sr-head mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.sr-head { margin-top: 4px; font-size: 13.5px; color: var(--text-soft); }
.sr-empty { padding: 28px 16px; text-align: center; color: var(--text-dim); font-size: 15px; }

/* ---------- toast & update banner ---------- */

#atlas-toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(var(--safe-b) + 20px);
  display: flex;
  align-items: center;
  gap: 12px;
  /* left: 50% leaves only half the screen for shrink-to-fit, which on a phone
     wraps a short message one word per line. Size to the text instead. */
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14.5px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s;
  pointer-events: none;
}
/* A toast never blocks the Pencil or a tap underneath — only its button
   takes input. */
#atlas-toast.show { transform: translate(-50%, 0); opacity: 1; }
#atlas-toast.show button { pointer-events: auto; }
/* Above the highlighter dock instead of on top of it. */
:root:has(#atlas-dock:not([hidden])) #atlas-toast { bottom: calc(var(--safe-b) + 76px); }
#atlas-toast:not(:has(button)) { padding-right: 18px; }
#atlas-toast button {
  flex: none;
  white-space: nowrap;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

/* ---------- highlighter (annotate.js) ---------- */

:root {
  --hl-yellow: rgba(250, 204, 21, 0.42);
  --hl-green: rgba(74, 222, 128, 0.36);
  --hl-blue: rgba(96, 165, 250, 0.34);
  --hl-pink: rgba(244, 114, 182, 0.32);
  --hl-preview: var(--hl-yellow);
}
:root.dark {
  --hl-yellow: rgba(250, 204, 21, 0.3);
  --hl-green: rgba(74, 222, 128, 0.27);
  --hl-blue: rgba(96, 165, 250, 0.32);
  --hl-pink: rgba(244, 114, 182, 0.3);
}

::highlight(atlas-hl-yellow) { background-color: var(--hl-yellow); }
::highlight(atlas-hl-green) { background-color: var(--hl-green); }
::highlight(atlas-hl-blue) { background-color: var(--hl-blue); }
::highlight(atlas-hl-pink) { background-color: var(--hl-pink); }
::highlight(atlas-hl-preview) { background-color: var(--hl-preview); }
::highlight(atlas-hl-flash) { background-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.hl-yellow { --swatch: #facc15; }
.hl-green { --swatch: #4ade80; }
.hl-blue { --swatch: #60a5fa; }
.hl-pink { --swatch: #f472b6; }

.topic { position: relative; padding-bottom: 36px; }

.atlas-markers { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.atlas-marker {
  position: absolute;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--swatch) 55%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--swatch) 22%, var(--panel));
  color: var(--text);
  pointer-events: auto;
  cursor: pointer;
}

/* The "needs a new home" tray above the article. */
.atlas-ink-top { display: grid; gap: 10px; margin-top: 18px; }
.atlas-ink-top:empty { display: none; }
.atlas-orphans {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, #f59e0b 45%, transparent);
  background: color-mix(in srgb, #f59e0b 8%, var(--panel));
}
.atlas-orphans summary { font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text); }
.atlas-orphans p { margin: 6px 0 10px; font-size: 13.5px; color: var(--text-dim); }
.atlas-orphans ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.atlas-orphans li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.atlas-orphans q { flex: 1; min-width: 160px; font-size: 14px; color: var(--text-soft); }
.atlas-orphans .acts { display: flex; gap: 6px; }
.atlas-orphans .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--swatch); }
.chip .dot.hl-yellow, .chip .dot.hl-green, .chip .dot.hl-blue, .chip .dot.hl-pink { background: var(--swatch); }

@keyframes plus-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---- menus ---- */

.atlas-menu {
  position: fixed;
  z-index: 65;
  max-width: min(460px, calc(100vw - 20px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  animation: pop-in 0.15s var(--ease);
  -webkit-user-select: none;
  user-select: none;
}
.menu-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.menu-row.end { justify-content: flex-end; margin-top: 8px; }
.atlas-menu button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: 600 14.5px var(--font-sans);
  cursor: pointer;
}
.atlas-menu button:active { background: var(--bg-inset); }
.atlas-menu button.danger { color: #e11d48; }
.atlas-menu button.primary { background: var(--accent); color: #fff; }
:root.dark .atlas-menu button.primary { color: #04121c; }
.menu-sep { width: 1px; height: 24px; margin: 0 2px; background: var(--border); }
.menu-note { padding: 2px 6px 8px; font-size: 12.5px; color: var(--text-dim); }
.menu-note button { min-height: 28px; padding: 0 8px; font-size: 12.5px; color: var(--accent-text); }
.menu-text {
  max-height: 200px;
  overflow: auto;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 14.5px;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
}
.atlas-note-editor { width: min(440px, calc(100vw - 20px)); -webkit-user-select: text; user-select: text; }
.menu-quote { padding: 2px 4px 8px; font-size: 13.5px; font-style: italic; color: var(--text-dim); }
.atlas-note-editor textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: 16px/1.5 var(--font-sans);
  resize: vertical;
}

.swatch {
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
}
.atlas-menu .swatch { min-height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--panel); background: var(--swatch); }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
/* ---- the dock: Highlighter ---- */

#atlas-dock {
  position: fixed;
  z-index: 45;
  right: calc(14px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
}
.dock-colors { display: flex; align-items: center; gap: 5px; padding: 0 8px 0 4px; margin-right: 2px; border-right: 1px solid var(--border); animation: plus-in 0.18s var(--ease); }
.dock-colors .swatch { width: 26px; height: 26px; }
.dock-erase {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: 3px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bg-inset);
  color: var(--text-soft);
  cursor: pointer;
}
.dock-erase[aria-pressed='true'] { background: var(--text); color: var(--bg); }
.dock-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dock-btn:active, .dock-erase:active { transform: scale(0.94); }
.dock-hl[aria-pressed='true'] { background: color-mix(in srgb, var(--swatch) 45%, var(--panel)); color: var(--text); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--swatch) 80%, transparent); }
.hl-erasing .dock-hl[aria-pressed='true'] { background: var(--bg-inset); box-shadow: inset 0 0 0 1.5px var(--border-strong); }

/* ---- touch diagnostics ---- */

#atlas-diag {
  position: fixed;
  z-index: 80;
  left: calc(10px + var(--safe-l));
  bottom: calc(10px + var(--safe-b));
  max-width: min(520px, calc(100vw - 20px));
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 13, 19, 0.86);
  color: #d7e3f4;
  font: 500 11px/1.45 var(--font-mono);
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
}

/* Library → Annotations */
.ann-filters { margin-bottom: 14px; }
.chip { cursor: pointer; font-family: var(--font-sans); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.ann-topic { margin-bottom: 14px; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); }
.ann-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ann-head a, .ann-head b { color: var(--text); font-weight: 650; text-decoration: none; }
.ann-head small { flex: none; color: var(--a); font-size: 12.5px; font-weight: 650; }
.ann-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.ann-row:last-child { border-bottom: 0; }
.ann-row:active { background: var(--bg-inset); }
.ann-bar { width: 4px; flex: none; border-radius: 2px; background: var(--swatch); }
.ann-body { display: grid; gap: 4px; min-width: 0; }
.ann-quote { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; line-height: 1.5; color: var(--text); }
.ann-note { font-size: 13.5px; color: var(--text-dim); white-space: pre-wrap; }
.ann-ink { align-items: center; }
.hl-inline { background: color-mix(in srgb, var(--swatch) 40%, transparent); border-radius: 3px; padding: 0 2px; }

/* Sync */
.sb-sync { margin-top: 6px; }
.sb-sync a { color: inherit; text-decoration: none; }
.status-dot.wait { background: #f59e0b; }
.sync-form .field {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  font: 16px var(--font-sans); /* ≥16px or iOS zooms on focus */
}
.sync-form .field:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.form-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.form-err { font-size: 13.5px; color: #e11d48; }
.sync-msg { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #f59e0b 12%, var(--panel)); font-size: 14px; color: var(--text-soft); }
.set-row small a { color: var(--accent-text); }

/* ---------- reading tracker (track.js) ---------- */

:root { --heat-0: var(--bg-inset); --heat-1: color-mix(in srgb, var(--good) 28%, var(--bg-inset)); --heat-2: color-mix(in srgb, var(--good) 50%, var(--bg-inset)); --heat-3: color-mix(in srgb, var(--good) 74%, var(--bg-inset)); --heat-4: var(--good); }

/* where you stopped last time */
.resume-ribbon {
  position: absolute;
  left: -30px;
  z-index: 2;
  width: 22px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--accent);
  pointer-events: auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}
@media (max-width: 860px) { .resume-ribbon { left: -22px; } }

/* sidebar: a ring that fills as a topic's sections are read */
.sb-topics a.reading .sb-dot {
  border: 0;
  background:
    radial-gradient(circle, var(--bg-soft) 47%, transparent 50%),
    conic-gradient(var(--a) var(--pct), var(--border-strong) 0);
}
.topic-row:not(.done) .topic-state.partial {
  border: 0;
  background:
    radial-gradient(circle, var(--panel) 56%, transparent 59%),
    conic-gradient(var(--a) var(--pct), var(--border-strong) 0);
}

/* contents: ticks beside sections you've read */
.toc-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toc-item .ic { flex: none; color: var(--good); }
.toc-item.read span { color: var(--text-soft); }

.review-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 0; font-size: 13.5px; color: var(--text-dim); }

/* review recap above a due topic */
.recap {
  margin-top: 22px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
}
.recap.done { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-size: 14.5px; font-weight: 600; color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 7%, var(--panel)); }
.recap-head { display: grid; gap: 2px; margin-bottom: 12px; }
.recap-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); }
.recap-head b { font-size: 18px; color: var(--text); }
.recap-head small { font-size: 13px; color: var(--text-dim); }
.recap-hl { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.recap-hl li { display: grid; gap: 3px; padding: 8px 12px; border-left: 3px solid var(--swatch); border-radius: 0 10px 10px 0; background: var(--panel); font-size: 15px; color: var(--text); line-height: 1.5; }
.recap-hl em { font-style: normal; font-size: 13.5px; color: var(--text-dim); }
.recap-note { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel); }
.recap-note b { display: block; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.recap-note p { margin: 4px 0 0; font-size: 15px; white-space: pre-wrap; color: var(--text-soft); }
.recap-meta { margin: 0 0 12px; font-size: 14px; color: var(--text-dim); }
.recap-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; color: var(--text-soft); }

/* Home */
.tr-today { display: flex; align-items: center; gap: 18px; height: 100%; padding: 18px 20px; }
.tr-ring-wrap { position: relative; flex: none; }
.tr-ring circle { fill: none; }
.tr-ring .bg { stroke: var(--bg-inset); }
.tr-ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.tr-ring .fg.met { stroke: var(--good); }
.tr-ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.05; }
.tr-ring-label b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tr-ring-label span { font-size: 11px; color: var(--text-dim); font-weight: 600; }
.tr-today-text { display: grid; gap: 3px; min-width: 0; font-size: 13.5px; color: var(--text-dim); }
.tr-today-text b { font-size: 16.5px; color: var(--text); letter-spacing: -0.01em; }

.tr-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin-top: 2px; }
.tr-tile { display: grid; gap: 8px; align-content: start; padding: 16px 18px; color: inherit; text-decoration: none; min-width: 0; }
.tr-tile > b { font-size: 16px; }
.tr-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 14.5px; }
.tr-row:first-of-type { border-top: 0; }
.tr-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-row small { flex: none; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.tr-row small.due, .row-side.due { color: #d97706; }
:root.dark .tr-row small.due, :root.dark .row-side.due { color: #fbbf24; }
.tr-empty { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-dim); }
.tr-more { font-size: 13px; color: var(--accent-text); text-decoration: none; }
.tr-goal-state { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.tr-goal-state.on, .tr-goal-state.done { color: var(--good); }
.tr-goal-state.behind, .tr-goal-state.late { color: #d97706; }
.tr-quote { display: grid; gap: 2px; padding: 7px 10px; border-left: 3px solid var(--swatch); border-radius: 0 9px 9px 0; background: var(--bg-soft); color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.45; }
.tr-quote small { font-size: 12px; color: var(--text-dim); }

.tr-week { display: grid; gap: 6px; }
.tr-bars { position: relative; display: flex; align-items: flex-end; gap: 7px; height: 64px; }
.tr-week.big .tr-bars { height: 150px; gap: 12px; }
.tr-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.tr-bar i { display: block; width: 100%; border-radius: 5px 5px 2px 2px; background: color-mix(in srgb, var(--accent) 45%, var(--bg-inset)); }
.tr-bar.today i { background: var(--accent); }
.tr-bar.met i { background: var(--good); }
.tr-goal { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--text-dim) 60%, transparent); }
.tr-days { display: flex; gap: 7px; font-size: 11px; font-weight: 600; color: var(--text-dim); }
.tr-week.big .tr-days { gap: 12px; }
.tr-days span { flex: 1; text-align: center; }
.tr-days span.today { color: var(--text); }

/* Progress page */
.tr-summary { display: grid; gap: 12px; grid-template-columns: 1.6fr repeat(3, 1fr); margin-top: 16px; }
@media (max-width: 900px) { .tr-summary { grid-template-columns: repeat(3, 1fr); } .tr-summary .tr-today { grid-column: 1 / -1; } }
@media (max-width: 520px) { .tr-summary { grid-template-columns: 1fr 1fr; } }
.tr-stat { display: grid; align-content: center; gap: 2px; padding: 16px 18px; }
.tr-stat b { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tr-stat b small { font-size: 15px; color: var(--text-dim); font-weight: 700; }
.tr-stat span { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.tr-pad { padding: 18px 20px; }
.tr-heat { display: grid; grid-template-columns: repeat(18, 1fr); gap: 4px; max-width: 620px; }
.tr-col { display: grid; grid-template-rows: repeat(7, auto); gap: 4px; }
.tr-heat i { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; background: var(--heat-0); }
.tr-legend i { display: block; width: 14px; height: 14px; border-radius: 4px; background: var(--heat-0); }
.tr-heat i.l1, .tr-legend i.l1 { background: var(--heat-1); }
.tr-heat i.l2, .tr-legend i.l2 { background: var(--heat-2); }
.tr-heat i.l3, .tr-legend i.l3 { background: var(--heat-3); }
.tr-heat i.l4, .tr-legend i.l4 { background: var(--heat-4); }
.tr-heat i.future { background: transparent; }
.tr-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; font-size: 11.5px; color: var(--text-dim); }
.tr-legend span { margin: 0 4px; }
.tr-tracks { display: grid; gap: 8px; }
.tr-track { display: grid; gap: 6px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: inherit; text-decoration: none; }
.tr-track-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.tr-track-head span { font-size: 13px; color: var(--text-dim); font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-track-bar { position: relative; height: 7px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.tr-track-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.tr-track-bar i.read { background: color-mix(in srgb, var(--a) 35%, transparent); }
.tr-track-bar i.done { background: var(--a); }
.tr-track small { font-size: 12.5px; color: var(--text-dim); }
.tr-goal-form { display: grid; gap: 14px; padding: 16px 18px; }
.tr-goal-now { display: grid; gap: 4px; padding-left: 12px; border-left: 3px solid var(--a); font-size: 13.5px; color: var(--text-dim); }
.tr-goal-now b { font-size: 16px; color: var(--text); }
.tr-goal-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.tr-goal-fields label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--text-dim); }
.tr-goal-fields select, .tr-goal-fields input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: 16px var(--font-sans);
}
.tr-goal-fields select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2378828f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.tr-goal-fields input { -webkit-appearance: none; appearance: none; }
.tr-goal-btns { display: flex; gap: 8px; }
.home-grid > [data-slot] > .card { height: 100%; }

/* ---------- narrow widths (Split View, Slide Over, phones) ---------- */

@media (max-width: 640px) {
  :root { --gutter: 18px; }
  .hero { flex-direction: column-reverse; align-items: flex-start; gap: 14px; }
  .ring { width: 92px; height: 92px; }
  .pn { grid-template-columns: 1fr; }
  .pn .next { grid-column: 1; }
  .topic-summary { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- prep plan (plan.js) ---------- */

:root { --plan-hld: #0284c7; --plan-lld: #7c3aed; --plan-mile: #d97706; --plan-late: #b45309; }
:root.dark { --plan-hld: #38bdf8; --plan-lld: #a78bfa; --plan-mile: #fbbf24; --plan-late: #fbbf24; }
:root.sepia { --plan-late: #9a3412; }

/* rows */
.pl-list { display: grid; }
.pl-list.card { padding: 2px 16px; }
.pl-item { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--border); }
.pl-item:first-child { border-top: 0; }
.pl-check { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: -6px -4px -6px -10px; padding: 0; border: 0; background: none; cursor: pointer; }
.pl-check span { display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--border-strong); border-radius: 50%; color: transparent; transition: background 0.15s, border-color 0.15s, transform 0.12s; }
.pl-check:active span { transform: scale(0.9); }
.pl-check[aria-pressed='true'] span { background: var(--good); border-color: var(--good); color: #fff; }
:root.dark .pl-check[aria-pressed='true'] span { color: #04121c; }
.pl-body { flex: 1; min-width: 0; display: grid; gap: 4px; padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pl-title { font-size: 15.5px; font-weight: 620; line-height: 1.32; color: var(--text); }
.pl-item.done .pl-title { color: var(--text-dim); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-dim) 55%, transparent); }
.pl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; font-size: 12.5px; color: var(--text-dim); }
.pl-track { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.pl-track.hld { background: color-mix(in srgb, var(--plan-hld) 15%, transparent); color: var(--plan-hld); }
.pl-track.lld { background: color-mix(in srgb, var(--plan-lld) 15%, transparent); color: var(--plan-lld); }
.pl-track.mile { background: color-mix(in srgb, var(--plan-mile) 17%, transparent); color: var(--plan-mile); }
.pl-flag { display: inline-flex; align-items: center; gap: 3px; height: 19px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pl-flag.late { background: color-mix(in srgb, var(--plan-late) 14%, transparent); color: var(--plan-late); }
.pl-flag.ahead { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.pl-flag.partial { background: color-mix(in srgb, var(--plan-hld) 13%, transparent); color: var(--plan-hld); }
.pl-flag.stuck { background: color-mix(in srgb, #e11d48 13%, transparent); color: #e11d48; }
.pl-flag.rev { background: color-mix(in srgb, #db2777 12%, transparent); color: #db2777; }
.pl-flag.timing { background: var(--accent); color: #fff; font-variant-numeric: tabular-nums; }
:root.dark .pl-flag.timing { color: #04121c; }
.pl-slot { font-size: 12px; font-weight: 650; color: var(--accent-text); }
.pl-go { flex: none; }
.pl-item.compact { min-height: 0; gap: 8px; padding: 6px 0; }
.pl-item.compact .pl-check { width: 36px; height: 36px; margin: -4px -4px -4px -8px; }
.pl-item.compact .pl-check span { width: 22px; height: 22px; }
.pl-item.compact .pl-title { font-size: 14px; }
.pl-item.compact .pl-meta { font-size: 12px; }
.pl-empty { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.pl-empty b { color: var(--text); font-weight: 650; }
.pl-done-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 14px; font-weight: 600; color: var(--good); }
.pl-link { padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 650; text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* Home */
.pl-home { margin-bottom: 14px; padding: 16px 20px 14px; }
.pl-home-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.pl-home-ring { position: relative; flex: none; width: 58px; height: 58px; }
.pl-home-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pl-home-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.pl-home-text b { font-size: 17px; letter-spacing: -0.01em; }
.pl-home-text small { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-home .tr-more { display: inline-block; margin-top: 6px; }
/* Phones (Galaxy S24 is 360px wide): ring, text and button don't fit on one
   row, so the button drops under the text and the week line can wrap. */
@media (max-width: 480px) {
  .pl-home { padding: 14px 16px 12px; }
  .pl-home-head { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: start; column-gap: 12px; row-gap: 8px; }
  .pl-home-head > .btn { grid-column: 2; justify-self: start; }
  .pl-home-text small { white-space: normal; }
}
.pl-spill { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--plan-late) 11%, transparent); color: var(--plan-late); font-size: 14px; font-weight: 650; text-decoration: none; }
.pl-spill span { flex: 1; min-width: 0; }

/* Plan page */
.pl-summary { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-top: 16px; }
.pl-summary .tr-today, .pl-summary .pl-track-tile { grid-column: span 2; }
.pl-summary .tr-stat .bar-track { margin-top: 8px; }
@media (max-width: 700px) { .pl-summary { grid-template-columns: 1fr 1fr; } .pl-summary .pl-track-tile { grid-column: span 1; } }
.pl-catchup { display: grid; gap: 12px; margin-bottom: 4px; }
.pl-catchup-head { display: grid; gap: 3px; }
.pl-catchup-head b { font-size: 15px; }
.pl-catchup-head span { font-size: 13.5px; line-height: 1.5; color: var(--text-soft); }
.pl-options { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.pl-opt { display: grid; align-content: start; gap: 2px; min-height: 72px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 13px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.pl-opt:active { background: var(--bg-inset); }
.pl-opt b { font-size: 15px; font-weight: 700; }
.pl-opt small { font-size: 12px; line-height: 1.35; color: var(--text-dim); }
.pl-opt small.heavy { color: var(--plan-late); }
.pl-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.pl-group { margin-top: 14px; }
.pl-group-head { display: flex; justify-content: space-between; margin: 0 4px 6px; font-size: 12.5px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.pl-days { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pl-day { display: grid; align-content: start; gap: 6px; padding: 14px 16px; }
.pl-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pl-day-head b { font-size: 15px; }
.pl-day-head span { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.pl-day.off { background: var(--bg-soft); }
.pl-weeks .pl-week { display: grid; grid-template-columns: 30px 1fr minmax(80px, 160px) 48px; align-items: center; gap: 12px; min-height: 58px; padding: 10px 16px; }
.pl-week-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-inset); font-size: 13px; font-weight: 800; }
.pl-week-text { min-width: 0; display: grid; gap: 1px; }
.pl-week-text b { font-size: 14.5px; font-weight: 650; }
.pl-week-text small { font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-week-bar .bar-track, .pl-week-bar .bar-fill { display: block; }
.pl-week-count { font-size: 13.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.pl-week.current { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.pl-week.current .pl-week-n { background: var(--accent); color: #fff; }
:root.dark .pl-week.current .pl-week-n { color: #04121c; }
.pl-week.complete .pl-week-n { background: var(--good); color: #fff; }
.pl-week.behind .pl-week-count { color: var(--plan-late); }
@media (max-width: 560px) { .pl-weeks .pl-week { grid-template-columns: 30px 1fr 48px; } .pl-week-bar { display: none; } }
.pl-row-btns { display: flex; flex: none; gap: 8px; }

/* item sheet */
.pl-sheet { position: fixed; inset: 0; z-index: 64; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: var(--scrim); opacity: 0; transition: opacity 0.18s; }
.pl-sheet[hidden] { display: none; }
.pl-sheet.show { opacity: 1; }
.pl-sheet-card { width: min(600px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 18px 22px 24px; border: 1px solid var(--border); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow-lg); transform: translateY(8px); transition: transform 0.2s var(--ease); }
.pl-sheet.show .pl-sheet-card { transform: none; }
:root.pl-sheet-open { overflow: hidden; }
.pl-sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pl-sheet-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.pl-sheet-card h2 { margin: 12px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.pl-when { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.pl-when .late { color: var(--plan-late); }
.pl-hint { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--bg-soft); font-size: 14px; color: var(--text-soft); }
.pl-sec { display: grid; gap: 8px; margin-top: 18px; }
.pl-toggle { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14.5px; cursor: pointer; }
.pl-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.pl-reads { display: grid; gap: 8px; }
.pl-read { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; color: inherit; text-decoration: none; }
.pl-read:active { background: var(--bg-inset); }
.pl-read > .ic { flex: none; color: var(--text-dim); }
.pl-read-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: color-mix(in srgb, var(--a) 15%, transparent); color: var(--a); }
.pl-read-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pl-read-text b { font-size: 15px; font-weight: 650; }
.pl-read-text small { font-size: 12.5px; color: var(--text-dim); }
.pl-ext { font-size: 14.5px; color: var(--accent-text); word-break: break-all; }
.pl-ext-note { font-size: 12px; color: var(--text-dim); }
.pl-time { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pl-time [data-timer] { font-variant-numeric: tabular-nums; }
.pl-min { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-dim); }
.pl-min input, .pl-sheet textarea { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font-sans); }
.pl-min input { width: 76px; height: 36px; padding: 0 10px; }
.pl-sheet textarea { width: 100%; padding: 10px 12px; resize: vertical; }
.pl-min input:focus, .pl-sheet textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.pl-move { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-date { position: relative; overflow: hidden; }
.pl-date input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* topic page */
.pl-chip { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 8px 10px 8px 14px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.pl-chip + .pl-chip { margin-top: 8px; }
.pl-chip-ico { flex: none; color: var(--accent-text); }
.pl-chip.done { border-color: var(--border); background: var(--bg-soft); }
.pl-chip.done .pl-chip-ico { color: var(--good); }
.pl-chip-text { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pl-chip-text b { font-size: 11.5px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); }
.pl-chip-text span { font-size: 14.5px; line-height: 1.4; color: var(--text); }
.pl-chip-text .pl-track { margin-right: 4px; vertical-align: 1px; }

/* ---------- recall: guess first, check yourself, review (recall.js) ---------- */

:root { --g1: #e11d48; --g2: #d97706; --g3: #059669; --g4: #2563eb; }
:root.dark { --g1: #fb7185; --g2: #fbbf24; --g3: #34d399; --g4: #60a5fa; }

/* guesses inside the Guess-first box */
.callout-predict li { margin-bottom: 0.7rem; }
.pg-guess {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border));
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: 15px/1.5 var(--font-sans);
  resize: none;
  overflow: hidden;
}
.pg-guess:focus { outline: 2px solid color-mix(in srgb, var(--c) 55%, transparent); outline-offset: 1px; }
.pg-note { margin: 0.2rem 0 0.9rem !important; font-size: 13.5px !important; color: var(--text-dim); font-family: var(--font-sans); }

/* cards on the topic page */
.rc-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin: 0 0 0.8rem; font-family: var(--font-sans); }
.rc-head-text { display: grid; gap: 1px; min-width: 0; }
.rc-head-text b { font-size: 15px; }
.rc-head-text span { font-size: 13px; color: var(--text-dim); }
.rc-guesses { flex-basis: 100%; border: 1px dashed color-mix(in srgb, #d946ef 45%, var(--border)); border-radius: 12px; padding: 0.6rem 0.9rem; background: color-mix(in srgb, #d946ef 5%, var(--panel)); }
.rc-guesses summary { cursor: pointer; font-size: 14px; font-weight: 650; color: color-mix(in srgb, #d946ef 70%, var(--text)); }
.rc-guesses ol { margin: 0.6rem 0 0.4rem; padding-left: 1.2rem; display: grid; gap: 0.5rem; font-size: 14.5px; }
.rc-guesses li span { display: block; }
.rc-guesses li em { display: block; font-style: normal; color: var(--text-soft); }
.rc-guesses p { margin: 0; font-size: 13px; color: var(--text-dim); }
.rc-chip { flex: none; align-self: center; padding: 1px 8px; border-radius: 999px; background: var(--bg-inset); color: var(--text-dim); font: 650 11.5px/1.6 var(--font-sans); white-space: nowrap; }
.rc-chip.new { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text); }
.rc-chip.due { background: color-mix(in srgb, var(--g2) 16%, transparent); color: var(--g2); }
.recall-card > summary { align-items: center; }
.recall-card .recall-q { flex: 1; min-width: 0; }
.rc-grade { display: grid; gap: 8px; margin: 0 var(--figure-pad); padding: 0 0 0.95rem; font-family: var(--font-sans); }
.rc-grade > span { font-size: 13px; color: var(--text-dim); }
.rc-gs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rc-g { display: grid; justify-items: center; gap: 1px; min-height: 52px; padding: 6px 4px; border: 1px solid color-mix(in srgb, var(--gc) 35%, var(--border)); border-radius: 11px; background: color-mix(in srgb, var(--gc) 7%, var(--panel)); color: var(--text); font-family: var(--font-sans); cursor: pointer; }
.rc-g b { font-size: 14.5px; font-weight: 700; color: var(--gc); }
.rc-g small { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rc-g:active { transform: scale(0.97); }
.rc-g.g1 { --gc: var(--g1); }
.rc-g.g2 { --gc: var(--g2); }
.rc-g.g3 { --gc: var(--g3); }
.rc-g.g4 { --gc: var(--g4); }
.rc-done { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--g3); }
.rc-grade .pl-link { justify-self: start; font-size: 13px; }

/* the review page */
.rv-top { display: grid; gap: 12px; margin-top: 12px; }
.rv-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); }
.rv-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rv-stats div { display: grid; gap: 1px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); }
.rv-stats b { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rv-stats span { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
@media (max-width: 560px) { .rv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rv-stage { margin-top: 18px; }
.rv-topic { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; font-weight: 650; color: var(--text-soft); text-decoration: none; }
.rv-topic i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--a); }
.rv-card { display: grid; gap: 16px; padding: 20px 22px 18px; }
.rv-card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.rv-count { font-size: 12.5px; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rv-count em { font-style: normal; color: var(--accent-text); }
.rv-q { font-family: var(--prose-face); font-size: calc(19px * var(--prose-scale)); line-height: 1.5; font-weight: 600; color: var(--text); }
.rv-a { padding-top: 14px; border-top: 1px dashed var(--border-strong); font-family: var(--prose-face); font-size: calc(17px * var(--prose-scale)); line-height: 1.62; color: var(--text-soft); }
.rv-q code, .rv-a code { font-family: var(--font-mono); font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--bg-inset); }
.rv-a a, .rv-q a { color: var(--accent-text); }
.rv-actions .rv-reveal { width: 100%; min-height: 52px; font-size: 16px; }
.rv-reveal kbd { margin-left: 8px; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.2); font: 600 11px var(--font-sans); }
.rv-grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rv-grades .rc-g { min-height: 62px; }
.rv-grades .rc-g b { font-size: 16px; }
.rv-undo { justify-self: start; font-size: 13px; }
.rv-empty, .rv-summary { display: grid; gap: 8px; padding: 22px; }
.rv-empty b, .rv-summary b { font-size: 19px; }
.rv-empty p, .rv-summary p { margin: 0; color: var(--text-soft); line-height: 1.55; }
.rv-summary-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.rv-settings { margin-top: 24px; }
.rv-settings > summary { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; font-weight: 650; color: var(--text-soft); margin-bottom: 10px; }
.rv-settings .set-row .seg { flex: none; }
@media (max-width: 640px) { .rv-settings .set-row { flex-direction: column; align-items: stretch; } }

/* home tile */
.rv-home { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 14px 18px; color: inherit; text-decoration: none; }
.rv-home.quiet { padding: 12px 16px; }
.rv-home > .ic { flex: none; color: var(--text-dim); }
.rv-home-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text); }
.rv-home-text, .rv-home > span:not(.btn):not(.rv-home-ico) { flex: 1; min-width: 0; display: grid; gap: 1px; }
.rv-home b { font-size: 16px; }
.rv-home small { font-size: 13px; color: var(--text-dim); }
.rv-home .btn { flex: none; }

/* progress: memory */
.rv-mem { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .rv-mem { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rv-forecast { display: grid; gap: 10px; margin-top: 12px; }
.rv-bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.rv-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.rv-bar i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 2px 2px; background: color-mix(in srgb, var(--accent) 45%, var(--bg-inset)); }
.rv-bar.today i { background: var(--accent); }
.rv-bar span { font-size: 10.5px; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; min-height: 13px; }

/* ---------- search: pages ---------- */

.sr-page .sr-title { align-items: center; gap: 10px; font-size: 15px; }
.sr-page .ic { color: var(--text-dim); }
.sr-kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
}
@media (hover: none) { .sr-kbd { display: none; } }

/* ---------- mouse and trackpad (Mac, laptops) ----------

   Everything above is sized for a fingertip: 44pt targets and press-only
   feedback, because a finger has no hover. A pointer is the opposite — it's
   precise, and without hover feedback a click target is indistinguishable
   from plain text. So with a fine pointer: smaller targets in a denser
   sidebar, every clickable thing lights up under the cursor, and the
   keyboard gets a visible focus ring. iPad with a trackpad matches too and
   gets the same treatment, which is what iPadOS itself does. */

@media (hover: hover) and (pointer: fine) {
  :root { --bar-h: 50px; --sb-w: 272px; }

  .icon-btn { width: 36px; height: 36px; border-radius: 9px; }
  .icon-btn:hover { background: var(--bg-inset); color: var(--text); }
  #atlas-bar { gap: 4px; }

  .sb-head { padding-top: calc(var(--safe-t) + 10px); }
  .sb-brand { height: 38px; font-size: 15.5px; }
  .sb-search { height: 34px; margin-top: 6px; border-radius: 9px; font-size: 13.5px; }
  .sb-search:hover { border-color: var(--border-strong); color: var(--text-soft); }
  .sb-search::after {
    content: '⌘K';
    margin-left: auto;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-dim);
  }
  .sb-main { margin-top: 8px; gap: 1px; }
  .sb-main a { height: 32px; gap: 10px; padding: 0 9px; border-radius: 8px; font-size: 14px; }
  .sb-main a .ic { width: 17px; height: 17px; }
  .sb-main a:hover:not(.active) { background: color-mix(in srgb, var(--bg-inset) 70%, transparent); color: var(--text); }

  .sb-group-title { padding: 14px 10px 4px; font-size: 10.5px; }
  .sb-sec-link { min-height: 32px; gap: 9px; border-radius: 8px; font-size: 14px; }
  .sb-sec-link .ic { width: 16px; height: 16px; }
  .sb-sec-link:hover:not(.active) { background: color-mix(in srgb, var(--bg-inset) 70%, transparent); }
  .sb-toggle { width: 30px; height: 32px; border-radius: 8px; }
  .sb-toggle:hover { background: var(--bg-inset); color: var(--text); }
  .sb-topics { margin: 1px 0 6px 17px; }
  .sb-topics a { padding: 5px 8px 5px 6px; font-size: 13.5px; border-radius: 7px; }
  .sb-topics a:hover:not(.active) { background: color-mix(in srgb, var(--bg-inset) 70%, transparent); color: var(--text); }
  .sb-dot { width: 12px; height: 12px; margin-top: 2.5px; }
  .sb-foot { padding-top: 8px; font-size: 12px; }
  .sb-foot a:hover { color: var(--text-soft); }

  .btn { min-height: 36px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
  .btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
  .btn:hover { border-color: var(--border-strong); background: var(--bg-soft); }
  .btn.primary:hover { background: color-mix(in srgb, var(--accent) 90%, var(--text)); border-color: transparent; }
  .btn:active { transform: none; }

  .row-link { min-height: 52px; padding: 10px 16px; }
  .row-link:hover { background: var(--bg-soft); }
  a.card:hover, a.rv-home:hover { border-color: var(--border-strong); }
  .sr-item:hover:not(.sel) { background: color-mix(in srgb, var(--bg-inset) 55%, transparent); }
  .toc-item:hover:not(.active) { background: var(--bg-inset); }
  .chip:hover { border-color: var(--border-strong); }
  .sb-toggle, .icon-btn, .sr-item, .row-link, .toc-item { transition: background 0.12s, color 0.12s; }
}

/* Keyboard focus: a visible ring only when the keyboard put it there. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-field input:focus-visible { outline: none; }
