/* Reading layer for the atlas.
 *
 * The shell in hud.css is an instrumentation panel: small monospace labels,
 * square corners, cyan-on-graphite. It still works for the live overview and
 * for canvas readouts, but it is tiring for long-form reading. This layer
 * keeps the identity and changes the things that affect reading:
 *
 *   - a warmer, higher-contrast palette in light mode;
 *   - a serif measure for chapter prose and a larger sans for UI;
 *   - sentence-case labels, 12 px minimum for secondary text;
 *   - fewer ornamental borders, no scanline texture, no panel brackets;
 *   - a single-column article below 1100 px, with no horizontal clipping.
 *
 * Loaded after hud.css. Colours remain CSS custom properties so the canvas
 * laboratories pick them up through assets/js/theme.js.
 */

:root {
  --bg: #0e1316;
  --bg-2: #0b1013;
  --panel: #141b1f;
  --panel-2: #192227;
  --line: rgba(203, 224, 228, 0.14);
  --line-strong: rgba(203, 224, 228, 0.34);
  --cyan: #7bdde4;
  --cyan-dim: #4d9ba3;
  --amber: #efb978;
  --red: #ff8f93;
  --green: #85dfae;
  --violet: #bda9ff;
  --text: #e4ebee;
  --text-dim: #a9b9bf;
  --text-faint: #7d9097;
  --canvas-bg: #0b1013;
  --canvas-bg-2: #10171b;
  --hover: rgba(123, 221, 228, 0.07);
  --grid: rgba(203, 224, 228, 0.14);
  --grid-faint: rgba(203, 224, 228, 0.07);
  --node-closed: #1d292e;
  --paper: #ffffff;
  --radius: 6px;
  --sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua",
    Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas,
    monospace;
}

[data-theme="light"] {
  --bg: #f6f2e9;
  --bg-2: #efe9dc;
  --panel: #fffdf8;
  --panel-2: #f4eee2;
  --line: rgba(26, 67, 77, 0.16);
  --line-strong: rgba(12, 88, 100, 0.38);
  --cyan: #0a6672;
  --cyan-dim: #3a7f88;
  --amber: #8a5200;
  --red: #a8323e;
  --green: #186b43;
  --violet: #5d3fa8;
  --text: #1b2a2f;
  --text-dim: #465a61;
  --text-faint: #5c7077;
  --canvas-bg: #fffdf8;
  --canvas-bg-2: #f0eadc;
  --hover: rgba(10, 102, 114, 0.07);
  --grid: rgba(20, 90, 105, 0.17);
  --grid-faint: rgba(20, 90, 105, 0.08);
  --node-closed: #d8d0c1;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
}

body::before {
  background: none;
}

#app {
  grid-template-rows: 64px 1fr 34px;
  grid-template-columns: 236px 1fr;
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  gap: 26px;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
}

.brand {
  min-width: 236px;
  gap: 12px;
  align-items: center;
}

.brand .mark {
  width: 20px;
  height: 20px;
  border-color: var(--cyan);
  box-shadow: none;
}

.brand .mark::after {
  inset: 6px;
  opacity: 0.75;
}

.brand h1 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}

.brand span {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-faint);
}

.topnav {
  gap: 4px;
}

.topnav a {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
}

.topnav a:hover {
  color: var(--text);
  background: var(--hover);
}

.topnav a.active {
  color: var(--text);
  background: var(--panel-2);
  border: 0;
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.themebtn {
  border-color: var(--line);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.langswitch button {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 6px 10px;
}

/* ---------------------------------------------------------------- rail */
.rail {
  padding: 22px 0 42px;
  background: transparent;
}

.rail .rail-title {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 22px 10px;
}

.rail .group {
  margin-top: 16px;
  padding: 14px 22px 5px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-top: 0;
}

.rail a {
  gap: 9px;
  padding: 7px 22px;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text-dim);
  border-left: 2px solid transparent;
}

.rail a:hover {
  color: var(--text);
  background: var(--hover);
}

.rail a.active {
  color: var(--text);
  border-left-color: var(--cyan);
  background: var(--hover);
}

.rail a .num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- main */
main {
  padding: 34px 40px 80px;
}

.view-head {
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 16px;
  margin-bottom: 28px;
}

.view-head .kicker {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--cyan);
}

.view-head h2 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.16;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--text);
}

.view-head .meta {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  text-align: right;
  line-height: 1.55;
  padding-top: 6px;
}

.muted {
  color: var(--text-dim);
  font-size: 16px;
}

.hint {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.6;
  color: var(--text-faint);
}

.mono {
  font-family: var(--mono);
}

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: none;
}

.panel::before,
.panel::after {
  content: none;
}

.panel h3 {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin: 0 0 12px;
}

/* ---------------------------------------------------------------- article */
.reader-grid {
  grid-template-columns: minmax(0, 720px) 200px;
  gap: 56px;
  justify-content: center;
}

.article {
  max-width: 720px;
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.78;
  color: var(--text);
}

.article h1 {
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--text);
  margin: 0 0 10px;
}

.article .subtitle {
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--text-dim);
  margin-bottom: 30px;
  padding-bottom: 22px;
}

.article h2 {
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 46px 0 14px;
}

.article h2::before {
  content: none;
}

.article h3 {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin: 30px 0 10px;
}

.article p {
  margin: 0 0 18px;
}

.article li {
  margin-bottom: 8px;
}

.article ul,
.article ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.article a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-bottom: 0;
}

.article a:hover {
  text-decoration-thickness: 2px;
}

.article strong {
  color: var(--text);
  font-weight: 650;
}

.article em {
  color: var(--text);
}

.article blockquote {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  margin: 24px 0;
  padding: 12px 18px;
  background: var(--panel-2);
  border-left: 3px solid var(--amber);
}

.article code {
  font-size: 0.82em;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cyan);
  padding: 1px 5px;
  border-radius: 3px;
}

.article pre {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.article pre code {
  background: none;
  border: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}

.article table {
  font-family: var(--sans);
  font-size: 14px;
  border-collapse: collapse;
  margin: 8px 0 24px;
}

.article th {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line-strong);
  padding: 9px 12px;
  vertical-align: bottom;
}

.article td {
  padding: 9px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.article tr:hover td {
  background: var(--hover);
}

.article .katex {
  font-size: 1.03em;
}

.article .katex-display {
  margin: 22px 0;
  padding: 2px 0;
}

.article hr {
  margin: 38px 0;
}

.doc-meta {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-transform: none;
  gap: 14px;
  margin-bottom: 18px;
}

.doc-meta span b {
  color: var(--text-dim);
  font-weight: 600;
}

.toc {
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.45;
  top: 6px;
}

.toc .rail-title {
  font-size: 11px;
  letter-spacing: 0.06em;
}

.toc a {
  padding: 5px 0 5px 12px;
  border-left-color: var(--line);
  color: var(--text-faint);
}

.toc a:hover,
.toc a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
}

.pager a {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 11px 14px;
  border-radius: 4px;
  color: var(--text-dim);
}

.pager a:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.chapter-sources {
  margin-top: 48px;
  padding-top: 24px;
}

.sources-head h2 {
  font-family: var(--serif);
  font-size: 22px;
}

.chapter-source-list li {
  font-size: 13.5px;
  line-height: 1.6;
}

.source-cite {
  font-family: var(--sans);
  color: var(--text);
}

.source-year {
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- cards */
.cards {
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px 20px 18px;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
  transform: none;
}

.card .tag {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.card h4 {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.35;
  font-weight: 600;
  margin: 7px 0 7px;
  color: var(--text);
}

.card p {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
}

.card .idx {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.section-head h3 {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- controls */
.control {
  margin-bottom: 16px;
}

.control label {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.control label b {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.control .help {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: 5px;
}

input[type="range"] {
  height: 22px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line-strong);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--cyan);
  box-shadow: none;
}

select,
.btn {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 11px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
}

select {
  width: 100%;
}

.btn {
  width: 100%;
}

.btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn.primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #ffffff;
}

[data-theme="dark"] .btn.primary {
  color: #0c1417;
}

.btn.ghost {
  border-color: var(--line);
  color: var(--text-dim);
}

.btn-row {
  gap: 8px;
}

/* ---------------------------------------------------------------- readouts */
.readout {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.readout b {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0;
}

.readout.alert b {
  color: var(--red);
}

.readout.ok b {
  color: var(--green);
}

.legend {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-dim);
  gap: 16px;
}

.legend i {
  height: 3px;
  width: 12px;
}

.canvas-wrap {
  border-radius: var(--radius);
  background: var(--canvas-bg);
  border-color: var(--line);
}

.canvas-wrap .corner {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- guide */
.guide {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin: 18px 0 24px;
}

.guide summary {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text);
  padding: 13px 16px;
}

.guide summary::after {
  color: var(--text-faint);
}

.guide-body {
  padding: 4px 16px 16px;
}

.guide-tabs button {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
  padding: 6px 10px;
  border-radius: 3px;
}

.guide-pane {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.72;
  color: var(--text-dim);
}

.guide-pane h4 {
  color: var(--text);
  font-size: 14px;
}

.guide-key dt {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  padding-top: 3px;
}

.guide-key dd {
  color: var(--text-dim);
}

.guide-key {
  grid-template-columns: minmax(120px, 0.3fr) 1fr;
  gap: 6px 18px;
}

.guide-try {
  border-left: 2px solid var(--amber);
  font-size: 14px;
}

.explain {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-dim);
}

.figure-note,
.hud-note {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
}

.lab-toolbar {
  gap: 8px;
  margin: 12px 0 2px;
}

.lab-toolbar .btn {
  width: auto;
}

/* ---------------------------------------------------------------- tables */
.data-table {
  font-family: var(--sans);
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 9px;
}

.data-table th {
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.hud-table th {
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.hud-table td {
  font-size: 12.5px;
}

.stat-strip > div {
  border-radius: var(--radius);
  background: var(--panel);
}

.stat-strip span {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.stat-strip b {
  font-family: var(--mono);
  font-size: 19px;
  color: var(--text);
}

/* ---------------------------------------------------------------- cards used by sources and search */
.searchbox {
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px 14px;
}

.searchbox input {
  font-family: var(--sans);
  font-size: 14px;
}

.searchbox kbd {
  font-family: var(--sans);
  font-size: 10px;
}

.chip {
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}

.source-card {
  border-radius: 8px;
  background: var(--panel);
  padding: 18px 20px;
}

.source-card h3 {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
}

.source-authors,
.source-venue {
  font-family: var(--sans);
  font-size: 12.5px;
}

.source-venue {
  color: var(--text-faint);
}

.source-used,
.source-used a {
  font-size: 11.5px;
}

.result a {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
}

.result .path {
  font-family: var(--sans);
  font-size: 11.5px;
}

.result .snippet {
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- entry / guide page */
.entry-hero {
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.65fr);
  gap: 40px;
  padding-bottom: 30px;
}

.entry-lead {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.55;
  color: var(--text);
  max-width: 760px;
}

.entry-key {
  border-left: 3px solid var(--amber);
  padding-left: 18px;
}

.entry-key b {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--amber);
}

.entry-key p {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-dim);
}

.entry-grid {
  gap: 16px;
  margin-top: 28px;
}

.entry-card {
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  min-height: 200px;
  border-color: var(--line);
}

.entry-card:hover {
  border-color: var(--line-strong);
  transform: none;
  background: var(--panel-2);
}

.entry-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.entry-card h3 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  margin: 10px 0 8px;
  color: var(--text);
}

.entry-card p {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

.entry-arrow {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--cyan);
}

.entry-list {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-dim);
}

.entry-foot {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-dim);
}

.path-grid b {
  font-size: 14px;
}

.path-grid p {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- overview */
body[data-view="overview"] main {
  padding: 22px 28px 24px;
}

.dash {
  height: calc(100vh - 132px);
  min-height: 600px;
  gap: 14px;
}

.dash-head {
  align-items: flex-start;
  padding: 0 2px 14px;
}

.dash-head h2 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.012em;
  text-shadow: none;
}

.dash-head p {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 820px;
}

.dash-head .kicker {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--cyan);
}

.dash-head-right {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
}

.panel-tag {
  display: none;
}

.dash-panel {
  padding: 16px;
}

.dash-panel h3 {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text);
}

.big-readout b {
  font-family: var(--mono);
  font-size: 42px;
  color: var(--text);
}

.big-readout span {
  font-family: var(--sans);
  font-size: 12px;
}

.phase-line {
  font-family: var(--sans);
  font-size: 12px;
}

.dash-panel .hint {
  font-size: 10.5px;
  line-height: 1.55;
}

.stage-head {
  padding: 10px 14px;
}

.stage-kicker {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.stage-head b {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.stage-meta {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.01em;
}

.stage-meta span {
  text-transform: none;
}

.stage-canvas {
  background: var(--canvas-bg);
}

.stage-corner {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.stage-legend {
  font-family: var(--sans);
  font-size: 10.5px;
}

.stage-foot {
  padding: 0;
}

.stage-foot span {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.stage-foot b {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
}

.instrument-list a {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 5px 2px;
}

.instrument-list .idx {
  font-family: var(--mono);
  font-size: 9.5px;
}

.instrument-list b {
  white-space: normal;
}

.dash-foot {
  font-family: var(--sans);
}

.module-links a {
  font-family: var(--sans);
}

.module-links span {
  font-size: 11px;
}

.module-links em {
  font-family: var(--mono);
  font-size: 11px;
}

.dash-foot-note {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- status bar */
.statusbar {
  padding: 0 22px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-faint);
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.statusbar .dot {
  box-shadow: none;
  animation: none;
}

.statusbar a {
  color: var(--text-dim);
}

.statusbar .right {
  display: flex;
  gap: 7px;
  align-items: center;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1240px) {
  .reader-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .toc {
    display: none;
  }

  .topnav a {
    padding: 7px 8px;
    font-size: 13px;
  }
}

@media (max-width: 1100px) {
  #app {
    grid-template-columns: 212px 1fr;
  }

  .brand {
    min-width: 212px;
  }

  main {
    padding: 28px 28px 64px;
  }

  .grid-lab,
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .dash {
    height: auto;
    min-height: 0;
  }

  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-hero,
  .entry-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: minmax(0, 100vw);
    grid-template-rows: auto 1fr 34px;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
  }

  .rail {
    display: none;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 8px 12px 6px;
    gap: 4px 8px;
  }

  .brand h1 {
    font-family: var(--serif);
    font-size: 16px;
    letter-spacing: -0.01em;
  }

  .brand .mark {
    width: 18px;
    height: 18px;
  }

  .topnav {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 3px;
  }

  .topnav a {
    font-size: 12.5px;
    padding: 7px 9px;
    flex: none;
  }

  main,
  body[data-view="overview"] main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 22px 18px 56px;
    overflow-x: hidden;
  }

  .reader-grid {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .article {
    max-width: 100%;
    font-family: var(--serif);
    font-size: 17.5px;
    line-height: 1.75;
  }

  .article h1 {
    font-size: 32px;
  }

  .article h2 {
    font-size: 23px;
    margin-top: 36px;
  }

  .view-head {
    display: block;
    margin-bottom: 22px;
  }

  .view-head h2 {
    font-size: 27px;
  }

  .view-head .meta {
    display: none;
  }

  .entry-lead {
    font-size: 19px;
  }

  .entry-hero {
    display: block;
    padding-bottom: 22px;
  }

  .entry-key {
    margin-top: 20px;
  }

  .dash-head {
    display: block;
  }

  .dash-head-right {
    margin-top: 10px;
  }

  .guide-key {
    grid-template-columns: 1fr;
  }

  .statusbar {
    padding: 0 14px;
    font-size: 10px;
  }

  .statusbar .right {
    display: flex;
    margin-left: auto;
  }

  .statusbar .right a,
  .statusbar .right .sep {
    display: none;
  }

  .data-table {
    font-size: 12px;
  }

  .source-card {
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .topnav {
    gap: 0;
  }

  .topnav a {
    font-size: 11.5px;
    padding: 6px 8px;
  }

  .entry-grid,
  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-card {
    min-height: 0;
  }

  .article h1 {
    font-size: 29px;
  }

  .article h2 {
    font-size: 21px;
  }

  .view-head h2 {
    font-size: 25px;
  }

  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }
}

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

/* Language-specific reading choices. Chinese prose needs a larger
   line-height and a sans heading; German compounds need slightly more
   word spacing. */
:lang(zh) .article {
  font-family: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: 18px;
  line-height: 1.9;
}

:lang(zh) .article h1,
:lang(zh) .article h2,
:lang(zh) .article h3 {
  font-family: var(--sans);
  letter-spacing: 0;
}

:lang(zh) .view-head h2,
:lang(zh) .dash-head h2,
:lang(zh) .entry-lead {
  font-family: var(--sans);
}

:lang(de) .article {
  word-spacing: 0.01em;
}

/* ---------------------------------------------------------------- start page extras */
.guide-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 26px 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.guide-facts > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg);
}

.guide-facts b {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.guide-facts span {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
}

.entry-card {
  display: flex;
  flex-direction: column;
}

.entry-card p {
  margin-bottom: 0;
}

.entry-meta {
  display: block;
  margin-top: auto;
  padding-top: 16px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
}

.entry-card .entry-arrow {
  position: static;
  display: block;
  margin-top: 8px;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cyan);
}

.label-key {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin: 14px 0 0;
  align-items: baseline;
}

.label-key dt {
  margin: 0;
}

.label-key dd {
  margin: 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
}

.path-grid b {
  display: block;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.path-grid p {
  margin: 0;
}

@media (max-width: 860px) {
  .guide-facts {
    grid-template-columns: 1fr 1fr;
  }

  .path-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* ---------------------------------------------------------------- residual uppercase labels */
.stage-head b,
.stage-foot span,
.phase-line b,
.algo-list em,
.algo-cols h3,
.algo-article > section h3 {
  text-transform: none;
  letter-spacing: 0.02em;
}

.themebtn .theme-text {
  text-transform: none;
  letter-spacing: 0.02em;
}

.algo-head .tag {
  text-transform: none;
  letter-spacing: 0.04em;
}

.card .tag {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: none;
}

.doc-meta span,
.source-top .badge {
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- notebook */
.status-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}

.status-link:hover {
  color: var(--cyan);
}

.status-link span {
  display: inline-block;
  min-width: 16px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.notebook-dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.notebook-dialog::backdrop {
  background: rgba(10, 14, 17, 0.55);
  backdrop-filter: blur(2px);
}

.notebook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}

.notebook-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
}

.notebook-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}


.notebook-dialog .notebook-lead {
  padding: 8px 22px 0;
  margin: 0;
}

.notebook-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 22px;
}

.notebook-actions .btn {
  width: auto;
}

.notebook-list {
  max-height: 480px;
  overflow: auto;
  padding: 0 22px 22px;
}

.notebook-empty {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-dim);
}

.notebook-entry {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.notebook-entry header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.notebook-entry header b {
  font-family: var(--sans);
  font-size: 14px;
}

.notebook-entry time {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-faint);
}

.notebook-meta {
  margin: 4px 0 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.notebook-entry details summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--cyan);
}

.notebook-entry pre {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
}

@media (max-width: 640px) {
  .notebook-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 24px);
  }

  .notebook-head,
  .notebook-dialog .notebook-lead,
  .notebook-actions,
  .notebook-list {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ---------------------------------------------------------------- guided recipes */
.recipe-band {
  margin: 24px 0 30px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
}

.recipe-card:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.recipe-meta {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0.02em;
}

.recipe-card h4 {
  margin: 9px 0 7px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
}

.recipe-card p {
  margin: 0 0 16px;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.recipe-card .entry-arrow {
  position: static;
  margin-top: auto;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cyan);
}

.recipe-banner {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px 20px;
  margin: 0 0 20px;
}

.recipe-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--amber);
}

.recipe-banner h3 {
  margin: 8px 0 10px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.recipe-banner p {
  margin: 0 0 7px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

.recipe-banner p b {
  color: var(--text);
  font-weight: 600;
}

.run-record {
  margin-top: 20px;
  padding: 0;
  overflow: hidden;
}

.run-record summary {
  cursor: pointer;
  padding: 15px 20px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.run-record[open] summary {
  border-bottom: 1px solid var(--line);
}

.run-record > details > .hint {
  padding: 14px 20px 0;
  margin: 0;
}

.run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
}

.run-actions .btn {
  width: auto;
}

.run-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 0 20px 16px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-faint);
}

.run-sources > span {
  margin-right: 4px;
}

.source-chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11.5px;
}

.source-chip:hover {
  color: var(--cyan);
  border-color: var(--line-strong);
}

.run-json {
  margin: 0;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow: auto;
  max-height: 360px;
}

@media (max-width: 900px) {
  .recipe-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- crossing estimate */
.estimate-panel {
  margin-top: 18px;
}

.estimate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.estimate-head h3 {
  margin-bottom: 5px;
}

.estimate-head .hint {
  margin: 0;
  max-width: 620px;
}

.estimate-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.estimate-form label {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
}

.estimate-form select {
  width: auto;
  min-width: 90px;
}

.estimate-form .btn {
  width: auto;
}

.estimate-readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 24px;
  margin: 16px 0 10px;
}

.estimate-readouts .readout {
  border-bottom: 1px solid var(--line);
}

.preset-row {
  margin: 0 0 14px;
}

.preset-row .chip {
  font-family: var(--sans);
  font-size: 11.5px;
  padding: 4px 9px;
}

@media (max-width: 720px) {
  .estimate-readouts {
    grid-template-columns: 1fr;
  }
}

.chip {
  text-transform: none;
  letter-spacing: 0.01em;
}

.preset-row .chip {
  border-radius: 4px;
}

.run-summary {
  margin: 10px 20px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.run-cli {
  margin: 0 20px 12px;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-faint);
}

.run-cli span {
  display: inline-block;
  margin-right: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.run-cli code {
  color: var(--text-dim);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- algorithm reader */
.algo-coverage {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-faint);
}

.algo-source {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

.algo-source:hover {
  color: var(--cyan);
}

.algo-lang {
  min-width: 74px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.algo-source .mono {
  font-size: 11px;
  overflow-wrap: anywhere;
}

.algo-test {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------------------------------------------------------------- chart interaction */
.canvas-wrap canvas {
  cursor: default;
}

.canvas-wrap.is-interactive canvas {
  cursor: crosshair;
}

.canvas-wrap canvas:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.canvas-wrap.has-chart-save {
  padding-bottom: 24px;
}

.canvas-wrap.has-chart-save .corner.bl,
.canvas-wrap.has-chart-save .corner.br {
  bottom: 24px;
}

.chart-save {
  position: absolute;
  right: 7px;
  bottom: 3px;
  z-index: 3;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0.5;
}

.chart-save:hover,
.chart-save:focus-visible {
  opacity: 1;
  color: var(--text);
  border-color: var(--line-strong);
}

@media (prefers-reduced-motion: reduce) {
  .chart-save {
    transition: none;
  }
}

.algo-summary {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 12px 0 16px;
  max-width: 760px;
}

/* Visually hidden but available to assistive technology and the live region. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stat-strip small {
  display: block;
  margin-top: 3px;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 400;
}
