/* Astronotes tokens. The only colour and type source for the site and the graph.
   Dark is the fallback. Light is paper, not pure white. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #090a0c;
  --panel: #0d1015;
  --panel-2: #11151c;
  --line: #1c222d;
  --line-strong: #2a3342;
  --ink: #e8eaef;
  --muted: #8b93a7;
  --dim: #6d7588;
  --accent: #8fb4ff;
  --accent-ink: #090a0c;
  --accent-2: #b4a7ff;
  --link: #8fb4ff;
  --live: #86e0b0;
  --warn: #e2b15a;
  --danger: #f0958a;
  --supported: #86e0b0;
  --uncertain: #e2b15a;
  --contradicted: #f0958a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --header-h: 48px;
  --radius: 4px;
  --font: "Geist", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "Geist Mono", "SFMono-Regular", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --content: 40rem;
  --page: min(67.5rem, calc(100% - 2rem));
}

[data-theme="light"] {
  color-scheme: light;
  --canvas: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f7f7f8;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --ink: #15181e;
  --muted: #5f6573;
  --dim: #71717a;
  --accent: #3b6fd4;
  --accent-ink: #ffffff;
  --accent-2: #6d5bd0;
  --link: #2a5bb8;
  --live: #146b42;
  --warn: #8a5600;
  --danger: #b4332c;
  --supported: #146b42;
  --uncertain: #8a5600;
  --contradicted: #b4332c;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.04);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: -0.011em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, canvas, svg { max-width: 100%; }

button, input { font: inherit; color: inherit; }

a { color: var(--link); text-underline-offset: 0.18em; }

a:hover { text-decoration-thickness: 1.5px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius);
  z-index: 50;
}

.skip:focus { top: 8px; }

.frame { width: var(--page); margin-inline: auto; }

html, body { max-width: 100%; overflow-x: clip; }

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  grid-template-rows: auto 1fr auto;
  column-gap: 5px;
  row-gap: 5px;
  align-items: start;
  width: min(1500px, 100%);
  margin-inline: auto;
  min-height: 100vh;
}

.side-left { grid-column: 1; grid-row: 1 / span 3; }
.reading { grid-column: 2; grid-row: 2; }
.side-right { grid-column: 3; grid-row: 1 / span 3; }
.site-footer { grid-column: 2; grid-row: 3; border-top: 1px solid var(--line); }

.reading { min-width: 0; }

.reading .frame,
.reading .page,
.reading .home {
  width: min(40rem, calc(100% - 3.5rem));
  margin-inline: auto;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 6rem 2rem 2rem;
}

.side-left { background: var(--panel); }

.side-right { background: var(--canvas); }

.article h1 { font-size: 2rem; }

.side-right h3 {
  font-size: 1rem;
  font-weight: 450;
  letter-spacing: -0.02em;
  margin: 0;
}

.side-tools { display: flex; gap: 8px; align-items: center; }

.side-tools .side-search { flex: 1; margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.graph-outer {
  position: relative;
  height: 250px;
  margin: 0.5em 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  box-sizing: border-box;
}

.graph-container, .force-canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.global-graph-icon {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  margin: 0.3rem;
  padding: 0.2rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  opacity: 0.5;
  cursor: pointer;
}

.global-graph-icon svg { width: 100%; height: 100%; fill: currentColor; }

.global-graph-icon:hover { background: var(--panel-2); opacity: 1; }

.global-graph-outer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  backdrop-filter: blur(4px);
}

.global-graph-outer.active { display: block; background: var(--canvas); }

.global-graph-container {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 80vw;
  height: 80vh;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--canvas);
  box-sizing: border-box;
}

.toc { display: flex; flex-direction: column; min-height: 1.4rem; }

.toc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.toc-header .fold {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.8;
  transition: transform 0.3s ease;
}

.toc-header.collapsed .fold { transform: rotate(-90deg); }

.toc-content {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  overflow: auto;
}

.toc-header.collapsed + .toc-content { display: none; }

.toc-content a {
  display: block;
  color: var(--ink);
  opacity: 0.35;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: opacity 0.5s ease, color 0.3s ease;
}

.toc-content a.in-view { opacity: 0.75; }

.toc-content .depth-0 { padding-left: 0; }
.toc-content .depth-1 { padding-left: 1rem; }
.toc-content .depth-2 { padding-left: 2rem; }
.toc-content .depth-3 { padding-left: 3rem; }

.backlinks h3 { margin-bottom: 0; }

.backlink-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }

.side-right .local-graph,
.graph-outer .local-graph { display: contents; }

.side-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.side-search { display: grid; gap: 6px; margin-bottom: 18px; }

.side-search input, .side-search input:focus {
  width: 100%;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--canvas);
  padding: 0 10px;
  font-size: 14px;
}

.side-sections { display: grid; gap: 2px; margin-bottom: 18px; }

.side-sections a {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: var(--radius);
}

.side-sections a:hover,
.side-sections a[aria-current="page"] { background: var(--panel-2); }

.side-recent { margin-bottom: 18px; }

.side-recent ul, .tree, .tree ul { list-style: none; margin: 8px 0 0; padding: 0; }

.side-recent a, .tree a, .tree summary {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.tree summary { padding-left: 4px; }

.tree details { margin-left: 8px; }

.side-recent a:hover, .tree a:hover, .tree summary:hover { color: var(--ink); }

.tree a[aria-current="page"] {
  color: var(--ink);
  background: var(--panel-2);
}

.explorer .kicker, .side-recent .kicker, .toc .kicker, .rail-head .kicker { margin-bottom: 4px; }

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 25;
  height: var(--header-h);
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 8px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar .wordmark { margin-right: auto; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
}

.scrim[hidden] { display: none; }

.rail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

.rail-head a { font-size: 13px; }

.rail-note { font-size: 14px; margin: 8px 0 0; }

.toc-list { list-style: none; margin: 8px 0 0; padding: 0; }

.toc-list a {
  display: block;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
}

.toc-d3 { padding-left: 12px; }

.toc-list a.is-active, .toc-list a:hover { color: var(--ink); }

.prose h2, .prose h3, .ledger-entry { scroll-margin-top: 72px; }

.side-right .local-graph {
  max-width: none;
  margin: 8px 0 18px;
  border: 0;
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.side-right .graph-outer { width: 100%; }

@media (min-width: 1100px) {
  .rail-disclosure > summary { display: none; }
}

.kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 450;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3, h4 {
  font-weight: 450;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 0;
}

h1 { font-size: clamp(2rem, 4vw, 2.75rem); }

.lede, .deck {
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-row {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.wordmark {
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  flex: none;
}

.nav {
  display: flex;
  gap: 18px;
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

.header-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn, .text-btn, .btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.text-btn {
  height: 36px;
  padding: 0 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.menu-btn { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-color: var(--line-strong);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  background: transparent;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover { filter: brightness(1.05); }

.home { padding: 64px 0 80px; }

.home h1 { max-width: 12ch; margin: 14px 0 16px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 36px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 48px;
}

.stats div { background: var(--panel); padding: 14px 16px 12px; }

.stats dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 6px 0 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.section-head a { font-size: 14px; }

.block { margin-top: 48px; }

.rows, .log, .todo-list { list-style: none; margin: 0; padding: 0; }

.row, .log-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.log-row { grid-template-columns: 7.5rem 1fr auto; }

.log-row a, .row span:first-child { color: var(--ink); text-decoration: none; }

.row:hover span:first-child, .log-row:hover a { color: var(--link); }

.meta, .muted { color: var(--muted); font-size: 13px; }

.empty {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel);
}

.page { padding: 40px 0 72px; }

.page > h1, .article h1 { margin: 10px 0 12px; max-width: 18ch; }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
}

.crumbs a { color: var(--muted); text-decoration: none; }

.article { max-width: var(--content); }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--tag, var(--muted));
  border: 1px solid color-mix(in srgb, var(--tag, var(--line)) 55%, transparent);
  background: color-mix(in srgb, var(--tag, transparent) 16%, transparent);
  border-radius: var(--radius);
  padding: 3px 7px;
}

.prose { margin-top: 8px; }

.prose > * + * { margin-top: 0.9em; }

.prose h2 { font-size: 1.35rem; margin-top: 1.6em; }

.prose h3 { font-size: 1.1rem; margin-top: 1.4em; }

.prose ul, .prose ol { padding-left: 1.2em; }

.prose li:has(> .task-box) { list-style: none; }

.prose li + li { margin-top: 0.3em; }

.prose blockquote {
  margin: 0;
  padding-left: 14px;
  border-left: 1px solid var(--accent);
  color: var(--muted);
}

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }

.prose img, .prose video, .prose iframe, .an-embed, .an-frame, .an-player, .an-map, .an-gallery, .an-html, .mermaid-view, .codeblock {
  max-width: 100%;
}
.prose img, .prose video { height: auto; }
.codeblock, .codeblock pre, .prose pre { max-width: 100%; overflow-x: auto; }

.prose li > label { display: flex; gap: 10px; align-items: flex-start; }
.prose .task-box { width: 1.1em; height: 1.1em; margin-top: 0.3em; flex: none; }
.prose li.is-done:not(:has(ul)):not(:has(ol)),
.prose li.is-done > label,
.task-row.is-done .block-text {
  text-decoration: line-through;
  color: var(--dim);
  opacity: 0.7;
  transition: color 180ms ease, opacity 180ms ease;
}
.an-html-frame { width: 100%; min-height: 88px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--canvas); display: block; }

.prose table, .an-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: var(--panel);
}

.prose th, .an-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 450;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--panel-2);
  border-bottom: 2px solid var(--accent);
}

.prose td, .an-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose tbody tr:nth-child(even), .an-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--panel-2) 55%, var(--canvas));
}

.prose tbody tr:hover, .an-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }

.wikilink { text-decoration-thickness: 1px; }

.wikilink.broken {
  color: var(--danger);
  text-decoration: underline dotted;
}

.fnref a { text-decoration: none; font-variant-numeric: tabular-nums; }

.footnotes { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.footnotes ol { padding-left: 1.2em; }

.footnotes li { color: var(--muted); font-size: 14px; }

.fn-back { margin-left: 6px; text-decoration: none; }

.callout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.callout-kicker {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.callout-warning { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.callout-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.callout-tip { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); }

.toggle {
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 8px 12px;
}

.toggle summary {
  cursor: pointer;
  font-weight: 450;
  letter-spacing: -0.02em;
}

.toggle summary:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.codeblock {
  margin: 1.2em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
}

.codeblock figcaption, .chart-block figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dots { display: inline-flex; gap: 5px; }

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  display: block;
}

.codeblock pre { margin: 0; padding: 14px 16px 16px; overflow: auto; }

.codeblock code, .prose code, code {
  font-family: var(--mono);
  font-size: 0.86em;
}

.chart-block {
  margin: 1.4em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.chart-mount { padding: 8px 8px 14px; }
.chart-mount svg { width: 100%; height: auto; display: block; }
.chart-error { color: var(--warn); padding: 12px; }

.cite-card, .transclude, .missing-embed {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel);
}

.cite-card blockquote { margin: 8px 0 0; }

.embed { border-radius: var(--radius); border: 1px solid var(--line); }

.ledger-day { margin-top: 12px; }

.ledger-entry {
  position: relative;
  padding: 18px 0 8px 16px;
  border-top: 1px solid var(--line);
}

.ledger-entry::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--live);
  position: absolute;
  left: 0;
  top: 26px;
}

.entry-head { display: flex; justify-content: space-between; gap: 12px; }

.corrects { color: var(--warn); font-size: 14px; }

.todo-list { border-top: 1px solid var(--line); }

.todo {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.todo.is-done a, .todo.is-done span { color: var(--muted); text-decoration: line-through; }

.task-box { width: 1rem; height: 1rem; margin-top: 0.35rem; accent-color: var(--accent); }

.backlinks { max-width: var(--content); margin-top: 48px; }

.backlinks-bar { display: flex; justify-content: space-between; align-items: center; }

.backlink-list { list-style: none; margin: 8px 0 0; padding: 0; }

.backlink-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.backlink-list .edge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.local-graph {
  max-width: var(--content);
  margin: 28px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.local-graph canvas {
  width: 100%;
  height: 280px;
  display: block;
  touch-action: none;
  cursor: grab;
}

.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; }

.footer-row { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }

.footer-row p { margin: 0; color: var(--muted); font-size: 14px; }

.is-graph { overflow: hidden; height: 100vh; }
.is-graph .app { height: 100vh; min-height: 0; }
.is-graph .reading { height: 100vh; display: flex; flex-direction: column; min-height: 0; }
.is-graph .site-footer { display: none; }
.is-graph .side { height: 100vh; }

.graph-app {
  flex: 1;
  min-height: 0;
  height: 100%;
  position: relative;
}

.graph-stage { position: absolute; inset: 0; min-width: 0; background: var(--canvas); }

.graph-canvas { position: absolute; inset: 0; }

.graph-status {
  position: absolute;
  z-index: 2;
  margin: 0;
  left: 16px;
  bottom: 16px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.graph-card {
  position: absolute;
  z-index: 3;
  left: 16px;
  top: 16px;
  width: min(320px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.graph-card h2 { font-size: 1.25rem; margin: 6px 0 8px; }

.graph-card p { color: var(--muted); font-size: 14px; }

.graph-sheet {
  background: var(--panel);
  overflow: auto;
}

.sheet-handle { display: none; }

.sheet-body { padding: 18px 16px 28px; display: grid; gap: 12px; }

.sheet-search, .palette input, #search input {
  width: 100%;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--canvas);
  padding: 0 12px;
}

.filters { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }

.check-row { display: flex; gap: 8px; align-items: center; font-size: 14px; }

.legend-note { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.graph-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.graph-legend li { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.graph-legend i { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }

.swatch { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }
.swatch-accent { background: var(--accent); }
.swatch-live { background: var(--live); }
.swatch-warn { background: var(--warn); }
.swatch-accent-2 { background: var(--accent-2); }

.node-list ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 40dvh; overflow: auto; }
.node-list a { display: block; padding: 6px 0; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); font-size: 14px; }

.palette {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 14px;
  box-shadow: var(--shadow);
}

.palette::backdrop { background: rgba(0, 0, 0, 0.45); }

.palette-form { display: grid; gap: 8px; }

.palette-results { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50dvh; overflow: auto; }

.palette-results a {
  display: block;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.palette-results .meta { display: block; }

.palette-hint { color: var(--dim); font-size: 12px; margin: 10px 0 0; }

#search { margin-top: 20px; }

.pagefind-ui { --pagefind-ui-primary: var(--accent); --pagefind-ui-text: var(--ink); --pagefind-ui-background: var(--panel); --pagefind-ui-border: var(--line); --pagefind-ui-border-width: 1px; --pagefind-ui-border-radius: 4px; --pagefind-ui-font: var(--font); }

@media (max-width: 1199px) {
  .toc-header.collapsed + .toc-content { display: none; }
}

.global-graph-close {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.toc, .backlinks, .toc-header { width: 100%; box-sizing: border-box; }
.toc-header { justify-content: space-between; }
.graph-outer, .graph-container { width: 100%; max-width: 100%; }

@media (max-width: 1099px) {
  .app { display: flex; flex-direction: column; align-items: stretch; width: 100%; }
  .app > * { width: 100%; max-width: 100%; box-sizing: border-box; }
  .side-left, .reading, .side-right, .site-footer { grid-column: auto; grid-row: auto; }
  .topbar { display: flex; align-items: center; z-index: 50; }
  .topbar .text-btn { position: relative; z-index: 1; min-width: 44px; min-height: 44px; pointer-events: auto; }
  .side-left:not(.is-open) { pointer-events: none; }
  .menu-btn { display: grid; width: 44px; height: 44px; }
  .side-left {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 200ms var(--ease);
    box-shadow: var(--shadow);
  }
  .side-left.is-open { transform: none; }
  .side-right {
    position: static;
    height: auto;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
    order: 3;
    padding: 12px 16px 28px;
    overflow: hidden;
  }
  .reading { order: 2; padding-top: 8px; }
  .reading .frame, .reading .page, .reading .home { width: min(40rem, calc(100% - 32px)); }
  .page { padding: 16px 0 40px; }
  .article h1 { font-size: 1.7rem; }
  .prose { font-size: 16px; line-height: 1.55; }
  .toc-header, .backlinks .toc-header { min-height: 44px; }
  .backlinks-body { display: block; }
  .toc-header.collapsed + .backlinks-body { display: none; }
  .app > .side-left { width: min(320px, 88vw); max-width: 88vw; }
  .app > .site-footer { order: 4; width: min(40rem, calc(100% - 2rem)); max-width: calc(100% - 2rem); margin-inline: auto; border-top: 0; }
  .global-graph-outer.active { background: var(--canvas); }
  .global-graph-container {
    inset: 0;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    transform: none;
    border: 0;
    border-radius: 0;
  }
  .stats { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; gap: 32px; }
  .home { padding-top: 28px; }
  .log-row { grid-template-columns: 1fr auto; }
  .log-row .kicker { grid-column: 1 / -1; }
  body.is-graph { height: 100dvh; }
  body.is-graph .app { height: 100dvh; display: flex; }
  body.is-graph .reading { flex: 1; height: auto; min-height: 0; }
  body.is-graph .graph-app { flex: 1; min-height: 0; height: auto; }
  body.is-graph .side-right {
    flex: none;
    height: auto;
    max-height: none;
    overflow: auto;
    border-top: 1px solid var(--line);
  }
  .sheet-handle {
    display: flex;
    width: 100%;
    height: 48px;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .sheet-body { display: none; padding-top: 0; }
  .graph-sheet.is-open .sheet-body { display: grid; max-height: 46dvh; overflow: auto; }
  .backlinks-panel {
    display: none;
  }
  .backlinks.is-open .backlinks-panel {
    display: block;
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70dvh;
    overflow: auto;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 8px 20px 28px;
  }
  .footer-row { flex-direction: column; }
}

@media (min-width: 801px) {
  .backlinks [data-backlinks-open] { display: none; }
}

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

.edit-bar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.edit-bar button {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
}
.edit-bar button:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.db-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 8px 0 16px; }
.db-title { font-size: 1.25rem; font-weight: 450; letter-spacing: -0.03em; }
.db-tabs { display: flex; gap: 4px; }
.db-tab { border: 1px solid var(--line); background: transparent; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.db-tab.is-active { border-color: var(--accent); color: var(--ink); }
.db-filter, .db-sort { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: grid; gap: 4px; }
.db-filter input, .db-sort select { height: 34px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--canvas); padding: 0 8px; font-family: var(--font); letter-spacing: 0; text-transform: none; font-size: 14px; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kanban-column { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; min-height: 180px; padding: 10px; }
.kanban-column header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.kanban-cards { display: grid; gap: 8px; min-height: 40px; }
.kanban-card { border: 1px solid var(--line-strong); border-radius: 4px; padding: 10px 12px; background: var(--canvas); cursor: grab; touch-action: none; }
.kanban-card a { color: var(--ink); text-decoration: none; font-weight: 450; }
.kanban-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.kanban-prop { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.kanban-column.is-drop { outline: 1px solid var(--accent); }
.db-list { list-style: none; margin: 0; padding: 0; }
.db-list li { border-top: 1px solid var(--line); padding: 10px 0; }
.calendar .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-grid > span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cal-day { min-height: 72px; border: 1px solid var(--line); border-radius: 4px; padding: 4px; background: var(--panel); }
.cal-day a { display: block; font-size: 12px; text-decoration: none; }
.cal-num { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.math-block { font-family: "Iowan Old Style", Palatino, serif; font-style: italic; border-left: 2px solid var(--accent); padding: 8px 12px; margin: 1rem 0; overflow-x: auto; }
@media (max-width: 800px) {
  .kanban { display: flex; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 8px; }
  .kanban-column { flex: 0 0 min(78vw, 260px); scroll-snap-align: start; }
  .an-columns { grid-template-columns: 1fr !important; }
  .db-toolbar { align-items: stretch; }
  .db-filter, .db-sort, .db-filter input, .db-sort select { width: 100%; }
  .editor-toolbar, .edit-bar { gap: 8px; }
  .edit-bar button, .db-tab, .side-sections a, .toc-content a, .backlink-list a { min-height: 44px; }
  .global-graph-icon { width: 44px; height: 44px; }
  .an-gantt-row { grid-template-columns: 1fr; }
}

.an-embed, .an-player, .bookmark, .an-file, .an-sketch-wrap, .an-preview, .an-widget {
  margin: 1rem 0;
}
.an-frame { border: 1px solid var(--line-strong); border-radius: 4px; overflow: auto; resize: vertical; min-height: 120px; background: var(--panel); }
.an-frame iframe, .an-preview-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--canvas); }
.an-preview-frame { min-height: 160px; border: 1px solid var(--line); border-radius: 4px; }
.an-embed figcaption, .an-player figcaption, .an-sketch-wrap figcaption, .an-preview figcaption {
  display: flex; gap: 8px; align-items: center; margin-bottom: 6px;
}
.an-open { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.an-player video, .an-player audio { width: 100%; border-radius: 4px; background: var(--panel); }
.bookmark, .an-file {
  display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent); border-radius: 4px; text-decoration: none; color: var(--ink); background: var(--panel);
}
.bookmark strong, .an-file strong { font-weight: 450; letter-spacing: -0.02em; }
.bookmark p { margin: 0; color: var(--muted); font-size: 14px; }
.an-gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.an-gallery img { height: 180px; width: auto; scroll-snap-align: start; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.an-columns { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; }
.an-col { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; background: var(--panel); min-width: 0; }
.an-tabs { display: grid; grid-template-columns: repeat(4, max-content); gap: 6px 8px; }
.an-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.an-tabs label { border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.an-tabs input:checked + label { border-color: var(--accent); color: var(--ink); }
.an-tabs input:focus-visible + label { outline: 1px solid var(--accent); outline-offset: 2px; }
.an-tabs .an-tab { display: none; grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 8px; }
.an-tabs input:nth-of-type(1):checked ~ .an-tab:nth-of-type(1),
.an-tabs input:nth-of-type(2):checked ~ .an-tab:nth-of-type(2),
.an-tabs input:nth-of-type(3):checked ~ .an-tab:nth-of-type(3),
.an-tabs input:nth-of-type(4):checked ~ .an-tab:nth-of-type(4) { display: block; }
.an-toc-block, .an-breadcrumb { margin: 1rem 0; }
.an-toc-block ol { list-style: none; padding: 0; margin: 8px 0 0; }
.an-toc-block li { border-top: 1px solid var(--line); padding: 6px 0; }
.an-toc-block .is-h3 { padding-left: 12px; }
.an-breadcrumb { font-size: 14px; color: var(--muted); }
.an-map { height: 320px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--panel); overflow: hidden; }
.an-map-fallback { margin: 0; padding: 12px 14px; }
.an-sketch { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 4px; }
.mermaid-src, .mermaid-view { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.an-mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--ink); padding: 0 0.15em; }
.an-mark.is-live { background: color-mix(in srgb, var(--live) 35%, transparent); }
.an-mark.is-warn { background: color-mix(in srgb, var(--warn) 35%, transparent); }
.an-color.is-accent { color: var(--accent); }
.an-color.is-live { color: var(--live); }
.an-color.is-warn { color: var(--warn); }
.an-color.is-danger { color: var(--danger); }
.an-comment { border-bottom: 1px dashed var(--accent); cursor: help; font-size: 0.85em; }
.an-comment:hover::after, .an-comment:focus::after {
  content: attr(data-note); display: block; position: absolute; z-index: 5; max-width: 240px;
  margin-top: 4px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 4px; color: var(--ink); font-size: 13px;
}
.an-date { font-family: var(--mono); font-size: 0.92em; color: var(--accent); }
.an-button { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 450; }
.an-button.is-dead { background: var(--panel); color: var(--muted); }
.an-progress { margin: 1rem 0; }
.an-progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; }
.an-progress-track { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.an-progress-track span { display: block; height: 100%; background: var(--accent); }
.an-timeline { list-style: none; margin: 1rem 0; padding: 0 0 0 14px; border-left: 2px solid var(--accent); }
.an-timeline li { padding: 0 0 14px 12px; }
.an-timeline p { margin: 2px 0 0; }
.an-gantt { display: grid; gap: 8px; margin: 1rem 0; }
.an-gantt-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr; gap: 8px; align-items: center; }
.an-gantt-track { position: relative; height: 22px; background: var(--panel-2); border-radius: 4px; }
.an-gantt-bar { position: absolute; top: 4px; height: 14px; background: var(--accent); border-radius: 4px; }
.transclude-body { margin-top: 8px; color: var(--muted); }
.an-pin { background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 4px; }
.math-inline { font-family: "Iowan Old Style", Palatino, serif; font-style: italic; }
