/* Reader styles. Mobile first; wider screens add room. */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d1e24;
  --muted: #5f6170;
  --border: #e2ddd1;
  --accent: #6a5ae0;
  --code-bg: #f1eee6;
  --shadow: 0 1px 2px rgb(30 25 10 / 6%), 0 6px 20px rgb(30 25 10 / 7%);

  --c-principles: #6a5ae0;
  --c-practices: #0f9488;
  --c-architecture: #d97706;
  --c-leadership: #db2777;
  --c-technology: #65a30d;
  --c-coding-with-ai: #2563eb;
  --c-antipatterns: #dc2626;
  --good: #15803d;
  --bad: #b91c1c;

  --radius: 14px;
  --tabbar-h: 64px;
  --topbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151a;
    --surface: #1c1e25;
    --surface-2: #252832;
    --text: #e9e8ee;
    --muted: #a1a3b3;
    --border: #2f323d;
    --accent: #9d93ff;
    --code-bg: #22252e;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
    --c-principles: #9d93ff;
    --c-practices: #2dd4bf;
    --c-architecture: #fbbf24;
    --c-leadership: #f472b6;
    --c-technology: #a3e635;
    --c-coding-with-ai: #60a5fa;
    --c-antipatterns: #f87171;
  --good: #4ade80;
  --bad: #f87171;
    --good: #4ade80;
    --bad: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14151a;
  --surface: #1c1e25;
  --surface-2: #252832;
  --text: #e9e8ee;
  --muted: #a1a3b3;
  --border: #2f323d;
  --accent: #9d93ff;
  --code-bg: #22252e;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
  --c-principles: #9d93ff;
  --c-practices: #2dd4bf;
  --c-architecture: #fbbf24;
  --c-leadership: #f472b6;
  --c-technology: #a3e635;
  --c-coding-with-ai: #60a5fa;
  --c-antipatterns: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overflow-x: hidden;
}
a { color: inherit; }
/* Components set their own display; the hidden attribute must still win. */
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.visually-hidden, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -0.01em; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { position: relative; width: 26px; height: 26px; flex: none; }
.brand-mark i { position: absolute; border-radius: 50%; }
.brand-mark i:nth-child(1) { width: 11px; height: 11px; left: 0; top: 3px; background: var(--c-principles); }
.brand-mark i:nth-child(2) { width: 9px; height: 9px; right: 0; top: 0; background: var(--c-practices); }
.brand-mark i:nth-child(3) { width: 11px; height: 11px; left: 8px; bottom: 0; background: var(--c-architecture); }
.topbar-search { display: none; flex: 1; max-width: 420px; margin-left: auto; }
.topbar-search input {
  width: 100%; height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.icon-button {
  margin-left: auto; width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
}
.topbar-search + .icon-button { margin-left: 0; }
.icon-button:hover { background: var(--surface-2); }
.icon-button svg { width: 22px; height: 22px; }

/* ---------- Tab bar (bottom on phones) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; cursor: pointer;
  text-decoration: none; font-size: 12px; font-weight: 500; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.tabbar svg { width: 24px; height: 24px; transition: transform .2s; }
.tabbar [aria-current="page"] { color: var(--accent); }
.tabbar [aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }
.tabbar button:active svg { transform: rotate(90deg); }

/* ---------- Page scaffolding ---------- */
main { outline: none; }
.page { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }

/* ---------- Category colour helpers ---------- */
[data-cat="principles"] { --cat: var(--c-principles); }
[data-cat="practices"] { --cat: var(--c-practices); }
[data-cat="architecture"] { --cat: var(--c-architecture); }
[data-cat="leadership"] { --cat: var(--c-leadership); }
[data-cat="technology"] { --cat: var(--c-technology); }
[data-cat="coding-with-ai"] { --cat: var(--c-coding-with-ai); }
[data-cat="antipatterns"] { --cat: var(--c-antipatterns); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--cat, var(--accent));
  background: color-mix(in srgb, var(--cat, var(--accent)) 13%, transparent);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag { font-size: 13px; color: var(--muted); }

/* ---------- Home ---------- */
.hero { padding: 8px 0 4px; }
.hero h1 { font-size: clamp(30px, 8vw, 44px); margin: 0 0 10px; }
.hero p { margin: 0 0 18px; color: var(--muted); font-size: 18px; }

.progress-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.ring { --p: 0; width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.ring::before { content: attr(data-label); width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; }
.progress-card strong { display: block; }
.progress-card span { color: var(--muted); font-size: 15px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.section-title h2 { margin: 0; font-size: 22px; }
.section-title a { font-size: 15px; color: var(--accent); text-decoration: none; font-weight: 600; }

.path-strip {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 4px 16px 14px;
  scrollbar-width: none;
}
.path-strip::-webkit-scrollbar { display: none; }
.path-stop {
  scroll-snap-align: start; flex: 0 0 min(72%, 240px);
  position: relative; padding: 14px 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  text-decoration: none; border-top: 4px solid var(--cat);
  transition: transform .15s;
}
.path-stop:active { transform: scale(.98); }
.path-stop .num { font-size: 13px; font-weight: 700; color: var(--cat); }
.path-stop h3 { margin: 4px 0 6px; font-size: 16px; }
.path-stop p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.path-stop.seen .num::after { content: " ✓ read"; color: var(--muted); font-weight: 600; }

.category-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button {
  flex: none; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-size: 15px; font-weight: 600;
}
.category-tabs button[aria-pressed="true"] { background: var(--cat, var(--text)); border-color: transparent; color: var(--surface); }
.category-tabs button:not([data-cat]) { --cat: var(--text); }

.catalog h2 { font-size: 22px; margin: 28px 0 4px; display: flex; align-items: center; gap: 10px; }
.catalog h2::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--cat); }
.catalog h2 + p { margin: 0 0 8px; color: var(--muted); }
.catalog p > strong:only-child { display: block; margin: 18px 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.catalog.prose ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.catalog li {
  position: relative; padding: 12px 14px 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 15px; line-height: 1.45; color: var(--muted);
  border-left: 4px solid var(--cat, var(--border));
}
.catalog li > a.entry-title { background: none; padding: 0; display: block; font-size: 17px; font-weight: 650; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.catalog li > a.entry-title::after { content: ""; position: absolute; inset: 0; }
.catalog li.seen > a.entry-title::before { content: "✓ "; color: var(--cat); }
.catalog li:not(.entry) { background: transparent; border: 0; padding: 0 2px; }
.catalog [hidden] { display: none; }

/* ---------- Article ---------- */
.article-head { margin-bottom: 8px; }
.article-head h1 { font-size: clamp(28px, 7vw, 40px); margin: 12px 0 10px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: 14px; }

.prose h2 { font-size: 23px; margin: 36px 0 10px; padding-top: 4px; }
.prose h3 { font-size: 19px; margin: 24px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--cat, var(--accent)); }
.prose strong { font-weight: 650; }
.prose code { font: 0.86em/1.4 var(--mono); background: var(--code-bg); padding: 2px 5px; border-radius: 5px; }
.prose pre {
  margin: 0 -16px 16px; padding: 14px 16px; overflow-x: auto;
  background: var(--code-bg); border-block: 1px solid var(--border);
  font-size: 14px; line-height: 1.55;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose blockquote {
  margin: 18px 0 8px; padding: 14px 16px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--cat, var(--accent)) 30%, transparent);
  font-size: 18px; line-height: 1.5;
}
.prose blockquote p { margin: 0; }
.table-wrap { overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; }
.prose table { border-collapse: collapse; font-size: 15px; line-height: 1.45; min-width: 100%; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.prose th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.prose td:first-child { font-weight: 600; min-width: 8em; }

a.wikilink {
  --link: var(--c-principles);
  color: var(--link); font-weight: 600; text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1.5px no-repeat;
  padding-bottom: 1px;
}
a.wikilink[data-cat="practices"] { --link: var(--c-practices); }
a.wikilink[data-cat="architecture"] { --link: var(--c-architecture); }
a.wikilink[data-cat="leadership"] { --link: var(--c-leadership); }
a.wikilink[data-cat="technology"] { --link: var(--c-technology); }
a.wikilink[data-cat="coding-with-ai"] { --link: var(--c-coding-with-ai); }
a.wikilink[data-cat="antipatterns"] { --link: var(--c-antipatterns); }
a.wikilink.unseen { background-image: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px); }
a.wikilink:hover { background-size: 100% 100%; background-image: linear-gradient(color-mix(in srgb, currentColor 14%, transparent), color-mix(in srgb, currentColor 14%, transparent)); border-radius: 3px; }
.wikilink.broken { color: var(--muted); text-decoration: line-through; }

.path-banner {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 0;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px;
}
.path-banner .dots { display: flex; gap: 4px; flex: none; }
.path-banner .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.path-banner .dots i.on { background: var(--accent); }
.path-banner a { margin-left: auto; font-weight: 650; color: var(--accent); text-decoration: none; text-align: right; }

/* ---------- Connections ---------- */
.connections { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--border); }
.connections h2 { font-size: 22px; margin: 18px 0 4px; }
.connections > p { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.local-graph {
  display: block; width: 100%; height: auto; max-height: 420px;
  margin: 8px 0 4px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.local-graph line { stroke: var(--border); stroke-width: 1.5; }
.local-graph line.out { stroke: color-mix(in srgb, var(--muted) 60%, transparent); }
.local-graph a { cursor: pointer; }
.local-graph circle { stroke: var(--surface); stroke-width: 3; fill: var(--cat); transition: r .15s; }
.local-graph a:hover circle, .local-graph a:focus circle { r: 12; }
.local-graph a:hover text { fill: var(--cat); }
.local-graph text { fill: var(--text); stroke: var(--surface); stroke-width: 4; paint-order: stroke; font-size: 15px; font-weight: 600; }
.legend-line { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.legend-line span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line svg { width: 26px; height: 8px; }

.link-cards { display: grid; gap: 10px; margin: 6px 0 0; }
.link-cards h3 { margin: 18px 0 2px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.link-card {
  display: block; padding: 12px 14px; border-radius: 12px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--cat);
  transition: transform .15s, box-shadow .15s;
}
.link-card:hover { box-shadow: var(--shadow); }
.link-card:active { transform: scale(.985); }
.link-card strong { display: block; font-size: 16px; }
.link-card span { display: block; font-size: 14px; line-height: 1.45; color: var(--muted); }
.link-card.seen strong::after { content: " ✓"; color: var(--cat); }

.article-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer;
}
.button.primary { background: var(--accent); border-color: transparent; color: var(--surface); }
.button svg { width: 18px; height: 18px; }

/* ---------- Quiz ---------- */
.quiz-block { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--border); }
.quiz-block h2 { font-size: 22px; margin: 18px 0 4px; }
.quiz-block > p:not(.quiz-score) { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.quiz-list { display: grid; gap: 14px; }
.quiz-q {
  margin: 0; padding: 14px; border-radius: var(--radius); min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--cat, var(--accent));
}
.quiz-q legend { float: left; width: 100%; padding: 0; margin: 0 0 12px; font-weight: 650; font-size: 17px; line-height: 1.4; }
.quiz-label { margin: 0 0 8px; }
.quiz-options { clear: both; display: grid; gap: 8px; }
.quiz-option {
  display: block; width: 100%; text-align: left; padding: 11px 14px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg); font-size: 15px; line-height: 1.45;
  transition: border-color .15s, background .15s;
}
.quiz-option:hover:not(:disabled) { border-color: var(--cat, var(--accent)); }
.quiz-option:disabled { cursor: default; opacity: .75; }
.quiz-option.right { opacity: 1; border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.quiz-option.wrong { opacity: 1; border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.quiz-option.right::before { content: "✓ "; color: var(--good); font-weight: 700; }
.quiz-option.wrong::before { content: "✗ "; color: var(--bad); font-weight: 700; }
.quiz-option code, .quiz-q legend code, .quiz-why code { font-family: var(--mono); font-size: .9em; }
.quiz-why { margin-top: 12px; font-size: 15px; line-height: 1.5; }
.quiz-why a.wikilink { color: var(--link, var(--accent)); }
.quiz-score { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 0; }
.quiz-page h1 { font-size: clamp(28px, 7vw, 40px); margin: 0 0 6px; }
.quiz-topics { margin-bottom: 12px; }
.quiz-topics small { font-weight: 500; opacity: .7; margin-left: 2px; }
.quiz-best { color: var(--muted); font-size: 15px; min-height: 1.4em; margin: 4px 0 16px; }
.quiz-progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.quiz-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.quiz-status { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; font-weight: 600; margin: 10px 0 12px; }
.quiz-next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.quiz-source { color: var(--cat); font-weight: 600; font-size: 15px; text-decoration: none; }
.quiz-result { margin-bottom: 8px; }
.quiz-result .ring { font-size: 12px; }

/* ---------- Search ---------- */
.search-box input {
  width: 100%; height: 50px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 18px; box-shadow: var(--shadow);
}
.search-box input:focus { border-color: var(--accent); outline: none; }
.search-hint { color: var(--muted); font-size: 15px; margin: 14px 4px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; cursor: pointer; }
.results { display: grid; gap: 10px; margin-top: 16px; }
.results mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; }

/* ---------- Glossary ---------- */
.terms-page h1 { font-size: clamp(28px, 7vw, 40px); margin: 0 0 6px; }
.lede { color: var(--muted); margin: 0 0 16px; }
.letter-strip {
  position: sticky; top: var(--topbar-h); z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 12px -16px 0; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
}
.letter-strip::-webkit-scrollbar { display: none; }
.letter-strip a {
  flex: none; min-width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; text-decoration: none; font-weight: 700; font-size: 15px;
  background: var(--surface); border: 1px solid var(--border);
}
.glossary h2 { font-size: 22px; margin: 26px 0 8px; color: var(--accent); scroll-margin-top: calc(var(--topbar-h) + 60px); }
.glossary dl { margin: 0; display: grid; gap: 10px; }
.term { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); scroll-margin-top: calc(var(--topbar-h) + 60px); }
.term dt { font-weight: 700; font-size: 17px; }
.term dd { margin: 2px 0 0; color: var(--muted); font-size: 15.5px; line-height: 1.5; }
.term dd a.wikilink { font-weight: 600; }
.glossary-card {
  display: block; margin: 8px 0 0; padding: 14px 16px; border-radius: var(--radius); text-decoration: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
}
.glossary-card strong { display: block; font-size: 17px; }
.glossary-card strong::after { content: " →"; color: var(--accent); }
.glossary-card span { color: var(--muted); font-size: 15px; }
.results-label { grid-column: 1 / -1; margin: 8px 0 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.term-card { border-left: 4px solid var(--accent); }

/* ---------- Graph ---------- */
.graph-view {
  position: fixed; inset: var(--topbar-h) 0 calc(var(--tabbar-h) + var(--safe-bottom)) 0;
  background: radial-gradient(circle at 50% 40%, var(--surface) 0, var(--bg) 70%);
  overflow: hidden; touch-action: none;
}
.graph-view canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.graph-view canvas.dragging { cursor: grabbing; }
.graph-filters {
  position: absolute; top: 12px; left: 0; right: 0;
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scrollbar-width: none;
}
.graph-filters::-webkit-scrollbar { display: none; }
.graph-filters button {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 90%, transparent);
  font-size: 14px; font-weight: 600; backdrop-filter: blur(8px);
}
.graph-filters button::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--cat); }
.graph-filters button[aria-pressed="false"] { opacity: .45; }
.graph-filters button[aria-pressed="false"]::before { background: transparent; box-shadow: inset 0 0 0 2px var(--cat); }
.graph-hint {
  position: absolute; left: 12px; right: 64px; bottom: 16px; width: fit-content;
  font-size: 13px; color: var(--muted); background: var(--surface); padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); pointer-events: none; transition: opacity .4s;
}
.graph-zoom { position: absolute; right: 12px; bottom: 16px; display: grid; gap: 8px; }
.graph-zoom button {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-size: 20px; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}
.sheet {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  padding: 16px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  border-top: 4px solid var(--cat);
  transform: translateY(calc(100% + 24px)); transition: transform .25s cubic-bezier(.2,.9,.3,1.2);
}
.sheet.open { transform: none; }
.sheet h2 { margin: 6px 0 4px; font-size: 19px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.sheet .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet .close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }

/* ---------- Hover preview (mouse only) ---------- */
.preview {
  position: fixed; z-index: 50; width: 300px; max-width: calc(100vw - 32px);
  padding: 12px 14px; border-radius: 12px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-top: 4px solid var(--cat); font-size: 14px; line-height: 1.45;
}
.preview strong { display: block; font-size: 15px; margin: 4px 0 2px; }
.preview span { color: var(--muted); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 999px; font-size: 15px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
}
.toast .button { padding: 6px 12px; font-size: 14px; }
@media (min-width: 760px) { .toast { bottom: 16px; } }

.noscript, .empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Wider screens ---------- */
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .topbar { padding: 0 24px; }
  .topbar-search { display: block; }
  .tabbar {
    top: 0; bottom: auto; left: auto; right: 72px; height: var(--topbar-h); padding: 0;
    display: flex; gap: 4px; background: none; border: 0; backdrop-filter: none;
    grid-template-columns: none; z-index: 21;
  }
  .tabbar [data-tab="search"] { display: none; }
  .tabbar a, .tabbar button { flex-direction: row; gap: 6px; padding: 0 12px; font-size: 14px; }
  .tabbar svg { width: 20px; height: 20px; }
  .topbar-search { margin-right: 490px; }
  .graph-view { bottom: 0; }
  .page { padding: 36px 24px 72px; }
  .prose pre { margin: 0 0 18px; border: 1px solid var(--border); border-radius: 12px; }
  .table-wrap { margin: 0 0 18px; padding: 0; }
  .catalog ul { grid-template-columns: 1fr 1fr; }
  .link-cards { grid-template-columns: 1fr 1fr; }
  .link-cards h3 { grid-column: 1 / -1; }
  .results { grid-template-columns: 1fr 1fr; }
  .sheet { left: auto; right: 16px; bottom: 16px; width: 360px; }
  .graph-zoom { top: 12px; bottom: auto; right: 16px; }
  .letter-strip { flex-wrap: wrap; }
  .path-stop { flex-basis: 220px; }
}
@media (min-width: 760px) and (max-width: 1000px) {
  .topbar-search { margin-right: 470px; }
  .brand-name { display: none; }
}

body.graph-mode { overflow: hidden; }
