/* Adjoint: a cool slate study app where blue is "computing forward" and orange is "flowing back".
   Layout: one narrow reading column (≤ 66ch prose), sticky top bar on desktop, bottom tab bar on phones. */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #e7ecf4; --ink: #141c2e; --ink-2: #39435c; --muted: #5b6680;
  --line: #d0d7e5; --fw: #2459c4; --bw: #c2560b; --ok: #13774f; --bad: #bf3131;
  --ok-bg: #dcefe5; --bad-bg: #f6dfdd; --bw-bg: #f8e7d8; --fw-bg: #dfe8fa;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 12px; --fs: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121b; --surface: #161c29; --surface-2: #212a3b; --ink: #e8ecf4; --ink-2: #c4cbda; --muted: #9aa4ba;
    --line: #2d374c; --fw: #7aa7ff; --bw: #ffa25c; --ok: #4ad196; --bad: #ff7b7b;
    --ok-bg: #173327; --bad-bg: #3a1f22; --bw-bg: #3a2717; --fw-bg: #1b2a4a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121b; --surface: #161c29; --surface-2: #212a3b; --ink: #e8ecf4; --ink-2: #c4cbda; --muted: #9aa4ba;
  --line: #2d374c; --fw: #7aa7ff; --bw: #ffa25c; --ok: #4ad196; --bad: #ff7b7b;
  --ok-bg: #173327; --bad-bg: #3a1f22; --bw-bg: #3a2717; --fw-bg: #1b2a4a; color-scheme: dark;
}
:root[data-size="s"] { --fs: 16px; } :root[data-size="l"] { --fs: 20px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.6 var(--body); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--fw); }
:focus-visible { outline: 2px solid var(--fw); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 760px; margin: 0 auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar-in { display: flex; align-items: center; gap: 14px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 800 1.25rem var(--display); margin-right: auto; }
.brand svg { width: 26px; height: 26px; }
.brand-a { fill: none; stroke: var(--fw); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-b { fill: none; stroke: var(--bw); stroke-width: 3.2; stroke-linecap: round; }
.tabs { display: flex; gap: 2px; }
.tabs a { text-decoration: none; color: var(--muted); font-weight: 700; font-size: .9rem; padding: 7px 10px; border-radius: 8px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.clock { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font: 500 .82rem var(--mono); color: var(--ink-2); cursor: pointer; }
.clock.warn { border-color: var(--bw); color: var(--bw); }
.bottom { display: none; }
main { padding-block: 24px 120px; outline: none; }
@media (max-width: 760px) {
  .tabs { display: none; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: .72rem; font-weight: 700; color: var(--muted); text-decoration: none; min-height: 52px; }
  .bottom a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .bottom a[aria-current="page"] { color: var(--fw); }
  body.reading .bottom { display: none; }
  main { padding-block: 16px 110px; }
}

/* type */
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
.h1 { font: 800 clamp(1.7rem, 5vw, 2.3rem)/1.1 var(--display); letter-spacing: -.01em; }
.h2 { font: 800 1.3rem/1.2 var(--display); }
.eyebrow { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.lede { color: var(--ink-2); max-width: 62ch; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* surfaces and controls */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .92; }
.btn.ghost { background: none; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="password"], textarea, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label.field { display: grid; gap: 6px; font-weight: 700; font-size: .92rem; }
label.field span.muted { font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.bar-meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-meter > i { display: block; height: 100%; background: var(--fw); border-radius: 99px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bw { background: var(--bw-bg); color: var(--bw); } .pill.fw { background: var(--fw-bg); color: var(--fw); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 520px); font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.18); }

/* today */
.hero { display: grid; gap: 10px; }
.next { display: grid; gap: 12px; padding: 22px; border-radius: 16px; background: var(--surface); border: 2px solid var(--ink); }
.next .what { font: 800 1.35rem/1.2 var(--display); }
.secondary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.secondary a { text-decoration: none; color: var(--ink); }
.secondary .card { display: grid; gap: 4px; height: 100%; }
.secondary .card:hover { border-color: var(--ink-2); }
.week { display: flex; gap: 8px; align-items: flex-end; }
.week .d { display: grid; justify-items: center; gap: 4px; font-size: .74rem; color: var(--muted); font-weight: 700; }
.week .d i { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: block; }
.week .d.on i { background: var(--ok); }
.week .d.today i { outline: 2px solid var(--ink); outline-offset: 2px; }
.tracks-mini { display: grid; gap: 10px; }
.tracks-mini .tr { display: grid; grid-template-columns: minmax(0, 10rem) 1fr 3.2rem; gap: 10px; align-items: center; font-size: .92rem; }
.tracks-mini .tr span:last-child { text-align: right; font-family: var(--mono); font-size: .82rem; color: var(--muted); }

/* map */
.track { display: grid; gap: 10px; }
.track-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.track-h .h2 { flex: 1; min-width: 12rem; }
.lessons { display: grid; gap: 2px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.lrow { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); text-decoration: none; color: var(--ink); min-height: 52px; }
.lrow:hover { background: var(--surface-2); }
.lrow .st { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.lrow .st.done { background: var(--ok); border-color: var(--ok); }
.lrow .st.done::after { content: ''; width: 9px; height: 5px; border: 2.5px solid var(--surface); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.lrow .st.part { border-color: var(--bw); background: conic-gradient(var(--bw) var(--p, 50%), transparent 0); }
.lrow .ti { min-width: 0; }
.lrow .ti b { display: block; font-weight: 700; }
.lrow .ti small { color: var(--muted); font-size: .82rem; }
.lrow .mn { font: 500 .8rem var(--mono); color: var(--muted); white-space: nowrap; }
.lrow.next { box-shadow: inset 4px 0 0 var(--fw); }
.search { position: relative; }
.results { display: grid; gap: 8px; }

/* lesson reader */
body.reading .bar { display: none; }
.rd-top { position: sticky; top: 0; z-index: 9; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line); }
.rd-top .wrap { display: flex; align-items: center; gap: 12px; min-height: 54px; }
.rd-top .x { border: 0; background: none; cursor: pointer; padding: 8px; margin-left: -8px; color: var(--ink-2); display: grid; place-items: center; min-width: 44px; min-height: 44px; }
.rd-top .x svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.dots { display: flex; gap: 4px; flex: 1; }
.dots i { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); }
.dots i.on { background: var(--fw); }
.dots i.cur { background: var(--bw); }
.rd-meta { font: 500 .8rem var(--mono); color: var(--muted); white-space: nowrap; }
.lesson { padding-block: 22px 140px; }
.lesson .intro { display: grid; gap: 10px; margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.lesson .intro ul { margin: 0; padding-left: 1.2em; color: var(--ink-2); }
.lesson .step-h { font: 800 clamp(1.4rem, 4.4vw, 1.85rem)/1.15 var(--display); margin: 0 0 14px; }
.prose { max-width: 66ch; }
.prose > * + * { margin-top: .9em; }
.prose p, .prose li { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; margin-block: .6em; }
.prose li + li { margin-top: .3em; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: .08em .35em; border-radius: 4px; }
.prose h3 { font: 800 1.15rem var(--display); margin-top: 1.4em; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92em; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { font-size: .85em; color: var(--muted); }
.prose .math { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.prose .katex { font-size: 1.06em; }
.prose blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--ink-2); }
.fig { margin: 1.2em 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow-x: auto; max-width: none; }
.fig svg { display: block; width: 100%; height: auto; min-width: 480px; }
.fig figcaption { font-size: .88rem; color: var(--muted); margin-top: 8px; }
.code { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.code-h { font: 700 .72rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 400 .84rem/1.55 var(--mono); }
.code.out pre { color: var(--ok); }
.blk { border-radius: 10px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); }
.blk > * + * { margin-top: .6em; }
.blk-h { font: 700 .74rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.blk p:first-of-type { margin-top: .3em; }
.blk.analogy { background: var(--fw-bg); border-color: transparent; }
.blk.analogy .blk-h { color: var(--fw); }
.blk.example { background: var(--surface); }
.blk.check { border: 2px solid var(--bw); }
.blk.check .blk-h { color: var(--bw); }
.blk.trap { border: 2px solid var(--bad); }
.blk.trap .blk-h { color: var(--bad); }
.blk.fr { background: var(--ok-bg); border-color: transparent; }
.blk.fr .blk-h { color: var(--ok); }
.blk.note .blk-h { color: var(--ink-2); }
details.reveal { margin-top: .6em; }
details.reveal summary, details.deep > summary { cursor: pointer; font-weight: 700; color: var(--bw); list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
details.reveal summary::before { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; }
details.reveal[open] summary { color: var(--muted); }
details.reveal[open] summary::before { background: currentColor; }
details.reveal .a { padding: 10px 12px; border-radius: 8px; background: var(--bw-bg); }
details.deep { background: var(--surface-2); border-color: transparent; }
details.deep > summary { color: var(--ink); }
details.deep > summary::before { content: '+'; font: 700 1.1rem var(--mono); width: 24px; height: 24px; border-radius: 6px; background: var(--surface); display: grid; place-items: center; }
details.deep[open] > summary::before { content: '−'; }
.deep-b > * + * { margin-top: .8em; }
.rd-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.rd-foot .wrap { display: flex; gap: 10px; padding-block: 10px; }
.rd-foot .btn.primary { flex: 1; }

/* quiz / review */
.qcard { display: grid; gap: 14px; }
.qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qprompt { font-size: 1.08rem; }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; cursor: pointer; min-height: 50px; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.choice:hover:not(:disabled) { border-color: var(--ink-2); }
.choice .k { font: 700 .8rem var(--mono); width: 24px; height: 24px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; }
.choice.right { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice:disabled { cursor: default; }
.fb { border-radius: 10px; padding: 12px 14px; }
.fb.ok { background: var(--ok-bg); } .fb.bad { background: var(--bad-bg); } .fb.neutral { background: var(--surface-2); }
.fb > * + * { margin-top: .5em; }
.fb .verdict { font-weight: 800; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades .btn { min-height: 56px; flex-direction: column; gap: 0; font-size: .92rem; }
.grades .btn small { font: 500 .72rem var(--mono); color: var(--muted); }
.grades .btn.g1 { border-color: var(--bad); } .grades .btn.g4 { border-color: var(--ok); }
.kp { display: grid; gap: 6px; }
.kp label { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; cursor: pointer; }
.kp input { width: 20px; height: 20px; margin-top: 3px; }
.timer-ring { font: 500 1.6rem var(--mono); }
.progress-line { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--bw); }

/* glossary */
.gl { display: grid; gap: 8px; }
.gl .card { display: grid; gap: 6px; }
.gl .term { font: 800 1.08rem var(--display); }
.gl .fr { font-style: italic; color: var(--muted); font-size: .9rem; }

/* progress */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; }
.stat b { font: 800 1.7rem var(--display); }
.stat span { font-size: .85rem; color: var(--muted); }
.load svg { width: 100%; height: auto; display: block; }
.load .lb { fill: var(--fw); } .load .lb.today { fill: var(--bw); }
.load text { fill: var(--muted); font: 12px var(--body); }
.load line { stroke: var(--line); }

/* lesson figure vocabulary (classes used inside lesson SVGs) */
.fig .t, .t { fill: var(--ink); font: 600 17px var(--body); }
.fig .tb, .tb { fill: var(--ink); font: 800 21px var(--display); }
.fig .tB, .tB { fill: var(--ink); font: 800 30px var(--display); }
.fig .ts, .ts { fill: var(--muted); font: 400 15px var(--body); }
.fig .tm, .tm { fill: var(--ink); font: 500 15px var(--mono); }
.tfw { fill: var(--fw) !important; } .tbw { fill: var(--bw) !important; } .tok { fill: var(--ok) !important; } .tbad { fill: var(--bad) !important; } .tmute { fill: var(--muted) !important; }
.box { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2; }
.boxc { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.ln { stroke: var(--ink); stroke-width: 2; fill: none; }
.fw { stroke: var(--fw); stroke-width: 3; fill: none; }
.bw { stroke: var(--bw); stroke-width: 3; fill: none; }
.ok { stroke: var(--ok); stroke-width: 3; fill: none; }
.bad { stroke: var(--bad); stroke-width: 3; fill: none; }
.grid { stroke: var(--line); stroke-width: 1; fill: none; }
.dash { stroke-dasharray: 7 5; }
.ffw { fill: var(--fw); } .fbw { fill: var(--bw); } .fok { fill: var(--ok); } .fbad { fill: var(--bad); } .fink { fill: var(--ink); }
.fsoft { fill: var(--surface-2); } .fline { fill: var(--line); } .fcard { fill: var(--surface); }
/* text classes combined with shape classes: keep text readable */
text.fw, text.bw, text.ok, text.bad { stroke: none; }
text.fw { fill: var(--fw); } text.bw { fill: var(--bw); } text.ok { fill: var(--ok); } text.bad { fill: var(--bad); }

/* highlight.js tokens */
.hljs-keyword, .hljs-built_in, .hljs-type { color: var(--fw); }
.hljs-string, .hljs-char { color: var(--ok); }
.hljs-number, .hljs-literal { color: var(--bw); }
.hljs-comment { color: var(--muted); font-style: italic; }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--bad); }
.hljs-title, .hljs-title.function_ { color: var(--ink); font-weight: 500; }

/* code: no per-span background inside blocks, no programming ligatures (>= must stay >=) */
.prose pre code, .code pre code { background: none; padding: 0; font-size: 1em; }
code, pre, .tm, .num { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
a.pill { text-decoration: none; }
