/* ============================================================
   THE HIDDEN FORGE — design system
   Iron and parchment. Forge gold for what is earned,
   ember red for what is contested.
   ============================================================ */

/* Font loading moved to <link rel="preconnect"/stylesheet"> tags in each
   page's <head> — @import here would block the parser from discovering
   the font request until after this whole file is fetched and parsed. */

:root {
  --ink:          #100e0b;
  --ink-soft:     #1a160f;
  --ink-card:     #201b13;
  --parchment:    #ece2c6;
  --parchment-70: rgba(236, 226, 198, 0.72);
  --parchment-45: rgba(236, 226, 198, 0.45);
  --gold:         #b8894a;
  --gold-bright:  #d9a45c;
  --red:          #7a2420;
  --red-bright:   #a5382b;
  --iron-line:    #3a352a;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Source Serif 4', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  --col: 42rem;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--iron-line);
  background: var(--ink-soft);
  padding: 1.1rem 0;
}

.site-header .shell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  color: var(--parchment);
  text-decoration: none;
}
.wordmark span { color: var(--gold-bright); }

.site-nav {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.site-nav a {
  color: var(--parchment-70);
  text-decoration: none;
  padding: 0.15rem 0.1rem;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover,
.site-nav a:focus-visible { color: var(--gold-bright); border-bottom-color: var(--gold); }
.site-nav a[aria-current="page"] { color: var(--gold-bright); border-bottom-color: var(--gold); }
.site-nav .sep { color: var(--iron-line); margin: 0 0.4rem; }

.nav-account {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--parchment-45);
}
.account .btn.quiet, .account .btn.danger { padding: 0.3rem 0.7rem; font-size: 0.72rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.account-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.account-form[hidden] { display: none; }
.account-form input {
  width: 11rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
}
.account-form .btn { padding: 0.35rem 0.7rem; font-size: 0.72rem; }

/* ---------- hero ---------- */

.hero {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--iron-line);
  background:
    radial-gradient(70% 130% at 12% 0%, rgba(184, 137, 74, 0.13), transparent 60%),
    var(--ink);
}

.kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--gold);
  margin-bottom: 1.1rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 7vw, 3.35rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
}

.lede {
  font-size: 1.16rem;
  color: var(--parchment-70);
  margin: 0;
  max-width: 34rem;
}

/* ---------- body type ---------- */

main { padding: 3rem 0 4rem; }

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 0.9rem;
}

h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  line-height: 1.25;
  margin: 0 0 0.7rem;
}

p { margin: 0 0 1.15rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--gold-bright); text-decoration-thickness: 1px; text-underline-offset: 2px; }

strong { color: var(--parchment); font-weight: 600; }
em { color: var(--parchment); }

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--ink-soft);
  border: 1px solid var(--iron-line);
  padding: 0.08em 0.32em;
  color: var(--gold-bright);
}

.section { margin-bottom: 3rem; }
.section:last-child { margin-bottom: 0; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 3rem 0;
  color: var(--gold);
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--iron-line);
}
.divider .mark { font-size: 0.7rem; }

blockquote {
  margin: 0 0 1.15rem;
  padding-left: 1.1rem;
  border-left: 2px solid var(--red);
  font-style: italic;
  color: var(--parchment-70);
}

/* ---------- surfaces ---------- */

.card {
  background: var(--ink-card);
  border: 1px solid var(--iron-line);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card:last-child { margin-bottom: 0; }

.callout {
  border-left: 3px solid var(--gold);
  background: var(--ink-soft);
  padding: 1rem 1.2rem;
  font-size: 0.97rem;
  color: var(--parchment-70);
}
.callout strong { color: var(--gold-bright); }

.pillar {
  border-top: 1px solid var(--iron-line);
  padding-top: 1.5rem;
  margin-bottom: 2.5rem;
}
.pillar-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--red-bright);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

/* ---------- controls ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--gold); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.btn.quiet { border-color: var(--iron-line); color: var(--parchment-45); }
.btn.quiet:hover { background: var(--iron-line); color: var(--parchment); }
.btn.danger { border-color: var(--red); color: var(--red-bright); }
.btn.danger:hover { background: var(--red); color: var(--parchment); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.1rem;
}

textarea, input[type="text"], input[type="email"] {
  width: 100%;
  background: var(--ink);
  color: var(--parchment);
  border: 1px solid var(--iron-line);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.7rem 0.85rem;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus, input[type="email"]:focus {
  outline: none;
  border-color: var(--gold);
}

label.field {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--gold);
  margin: 1.2rem 0 0.4rem;
}
label.field:first-child { margin-top: 0; }

.hint {
  font-size: 0.88rem;
  color: var(--parchment-45);
  margin: 0.4rem 0 0;
}

.status {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--parchment-45);
}

/* ---------- creed audit ---------- */

.audit-item {
  border-top: 1px solid var(--iron-line);
  padding: 1.1rem 0;
}
.audit-item p { margin: 0 0 0.7rem; font-size: 1rem; }

.scale {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.scale-legend {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--parchment-45);
}
.scale input { position: absolute; opacity: 0; width: 0; height: 0; }
.scale label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--iron-line);
  color: var(--parchment-45);
  cursor: pointer;
}
.scale label:hover { border-color: var(--gold); color: var(--gold-bright); }
.scale input:checked + label {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}
.scale input:focus-visible + label { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

.verdict {
  border: 1px solid var(--gold);
  background: var(--ink-card);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.verdict .score {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1;
  display: block;
  margin-bottom: 0.5rem;
}

/* ---------- anvil ---------- */

.step {
  border-left: 2px solid var(--iron-line);
  padding: 0 0 1.6rem 1.3rem;
  position: relative;
}
.step:last-of-type { padding-bottom: 0; }
.step::before {
  content: attr(data-step);
  position: absolute;
  left: -0.72rem;
  top: 0.1rem;
  width: 1.35rem;
  height: 1.35rem;
  background: var(--ink);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}
.step h3 { font-size: 1.08rem; margin-bottom: 0.35rem; }

/* ---------- decoder ---------- */

.decoder-list { border: 1px solid var(--iron-line); background: var(--ink-card); }

.subject { border-top: 1px solid var(--iron-line); }
.subject:first-child { border-top: none; }

.subject > summary {
  cursor: pointer;
  list-style: none;
  padding: 1.1rem 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  color: var(--parchment);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.subject > summary::-webkit-details-marker { display: none; }
.subject > summary::after { content: '+'; color: var(--gold); font-size: 1.1rem; line-height: 1; }
.subject[open] > summary::after { content: '\2212'; }
.subject > summary:hover { color: var(--gold-bright); }
.subject > summary:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: -2px; }

.subject-body { padding: 0 1.4rem 1.3rem; }

.decode-entry { border-top: 1px solid var(--iron-line); padding: 1.2rem 0; }
.decode-entry:first-child { border-top: none; padding-top: 0; }
.decode-entry .surface {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--red-bright);
  margin: 0 0 0.6rem;
}
.decode-entry .beneath { margin: 0; }
.decode-entry .btn-row { margin-top: 0.9rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: transparent;
  border: 1px solid var(--iron-line);
  color: var(--parchment-45);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--gold); color: var(--gold-bright); }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); }

/* ---------- manifesto excerpts ---------- */

.excerpt {
  border: 1px solid transparent;
  border-left: 2px solid var(--iron-line);
  padding: 0.7rem 0.9rem;
  margin: 0 0 0.9rem;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.excerpt:hover { border-left-color: var(--gold); background: var(--ink-soft); }
.excerpt:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.excerpt.captured { border-left-color: var(--red-bright); background: var(--ink-card); }

.excerpt.protocol {
  border-left: 3px solid var(--gold);
  background: var(--ink-soft);
}
.excerpt.protocol::before {
  content: 'Protocol';
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin-bottom: 0.4rem;
}
.excerpt.protocol.captured { border-left-color: var(--red-bright); background: var(--ink-card); }

.drawer {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
}
.drawer[hidden] { display: none; }

.drawer-badge {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  border: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  transition: background 120ms ease, transform 120ms ease;
}
.drawer-badge:hover { background: var(--gold-bright); transform: scale(1.06); }
.drawer-badge:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

.drawer-panel {
  position: absolute;
  right: 0;
  bottom: 3.75rem;
  width: min(22rem, calc(100vw - 2.5rem));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--ink-card);
  border: 1px solid var(--gold);
  padding: 1.1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.drawer-panel[hidden] { display: none; }
.drawer-panel ol { margin: 0.6rem 0 0; padding-left: 1.3rem; font-size: 0.9rem; }
.drawer-panel li { margin-bottom: 0.4rem; }

/* ---------- journal ---------- */

.entry {
  border-top: 1px solid var(--iron-line);
  padding: 1.3rem 0;
}
.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--parchment-45);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.55rem;
}
.entry-meta .src { color: var(--gold); }
.entry-body { white-space: pre-wrap; margin: 0 0 0.7rem; }

.empty {
  border: 1px dashed var(--iron-line);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--parchment-45);
}

.search-row { margin: 0 0 1.1rem; }

/* ---------- audit trend ---------- */

.trend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.trend-label {
  width: 5.5rem;
  flex-shrink: 0;
  color: var(--parchment-45);
}
.trend-track {
  flex: 1;
  min-width: 6rem;
  height: 0.55rem;
  background: var(--ink-soft);
  border: 1px solid var(--iron-line);
}
.trend-bar { height: 100%; background: var(--gold); }
.trend-score {
  flex-shrink: 0;
  color: var(--parchment-70);
  white-space: nowrap;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--iron-line);
  background: var(--ink-soft);
  padding: 2rem 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--parchment-45);
}

/* ---------- index cards ---------- */

.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px;
  background: var(--iron-line);
  border: 1px solid var(--iron-line);
}

.room {
  display: block;
  background: var(--ink-card);
  border-top: 2px solid transparent;
  padding: 1.5rem 1.4rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease;
}
.room:hover, .room:focus-visible { border-top-color: var(--gold); }
.room:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: -2px; }
.room:hover h3 { color: var(--gold-bright); }
.room-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.7rem;
}
.room h3 { margin-bottom: 0.4rem; transition: color 120ms ease; }
.room p { color: var(--parchment-70); font-size: 0.96rem; margin: 0; }

/* ---------- homepage record widget ---------- */

.record {
  border: 1px solid var(--iron-line);
  background: var(--ink-card);
  padding: 1.25rem 1.4rem;
}
.record .status { display: block; margin-bottom: 0.6rem; }
.record .status .streak { color: var(--gold-bright); }
.record blockquote { border-left-color: var(--gold); margin: 0 0 0.9rem; }
.record p:last-child { margin: 0; }
.record .empty-lede { color: var(--parchment); margin-bottom: 0.6rem; }

/* ---------- private vault dashboard (vault.html) ---------- */

:root {
  --col-wide: 68rem;
  /* heat steps: one hue (forge gold), dim to bright, on the iron surface */
  --heat-0: var(--ink-soft);
  --heat-1: rgba(184, 137, 74, 0.28);
  --heat-2: rgba(184, 137, 74, 0.52);
  --heat-3: rgba(217, 164, 92, 0.78);
  --heat-4: var(--gold-bright);
}

.shell.wide { max-width: var(--col-wide); }
.btn-row[hidden] { display: none; }
.vault-fresh { display: block; margin-top: 1.2rem; }
.vault-fresh .stale { color: var(--red-bright); }

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.vault-grid .card { margin: 0; }
.vault-panel { margin-bottom: 3rem; }
.vault-panel > h2 { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.vault-panel > h2 .panel-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1px;
  background: var(--iron-line);
  border: 1px solid var(--iron-line);
  margin-bottom: 1.25rem;
}
.tile { background: var(--ink-card); padding: 1rem 1.1rem; }
.tile .label, .mini-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--parchment-45);
  letter-spacing: 0.04em;
}
.tile .value {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.15;
  color: var(--parchment);
  font-variant-numeric: tabular-nums;
}
.tile .value.warn { color: var(--red-bright); }
.tile .sub { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--parchment-45); }

.chart-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--gold);
  margin: 0 0 0.7rem;
}
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-mono); font-size: 10px; fill: var(--parchment-45); }
.chart .grid { stroke: var(--iron-line); stroke-width: 1; }
.chart .base { stroke: var(--parchment-45); stroke-width: 1; }
.chart .bar-pos { fill: var(--gold); }
.chart .bar-neg { fill: var(--red-bright); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar-pos, .chart .hit:hover + .bar-neg { fill: var(--gold-bright); }
.chart .line { stroke: var(--gold); stroke-width: 2; fill: none; }
.chart .dot { fill: var(--gold-bright); stroke: var(--ink-card); stroke-width: 2; }
.chart .dot:hover, .chart .dot:focus { stroke: var(--parchment); outline: none; }
.chart .cell { stroke: var(--ink-card); stroke-width: 2; }
.chart .cell:hover, .chart .cell:focus { stroke: var(--parchment); outline: none; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--parchment-45);
  margin-top: 0.6rem;
}
.heat-legend i { width: 0.8rem; height: 0.8rem; display: inline-block; border: 1px solid var(--iron-line); }

.vault-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--ink);
  border: 1px solid var(--gold);
  color: var(--parchment);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 0.4rem 0.6rem;
  max-width: 16rem;
}
.vault-tip[hidden] { display: none; }

.hbar { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr auto; gap: 0.35rem 0.7rem; align-items: center; }
.hbar .name { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 0.55rem; background: var(--ink-soft); }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .num { font-family: var(--font-mono); font-size: 0.74rem; color: var(--parchment-70); text-align: right; font-variant-numeric: tabular-nums; }

.project { border-top: 2px solid var(--iron-line); }
.project h3 { margin-bottom: 0.2rem; }
.project .meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--parchment-45); margin: 0 0 0.9rem; }
.project .meta .up { color: var(--gold-bright); }
.project .meta .down { color: var(--red-bright); }
.project.recent { border-top-color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.2rem 0 0.9rem; }
.chip-s {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  border: 1px solid var(--iron-line);
  color: var(--parchment-70);
  padding: 0.1rem 0.45rem;
}
.chip-s.open { border-color: var(--red); color: var(--red-bright); }
.chip-s.done { border-color: var(--gold); color: var(--gold-bright); }

.vlist { list-style: none; margin: 0; padding: 0; font-size: 0.93rem; }
.vlist li {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--iron-line);
}
.vlist li:last-child { border-bottom: 0; }
.vlist .t { min-width: 0; overflow-wrap: anywhere; }
.vlist .t small { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--parchment-45); }
.vlist .r { flex: none; font-family: var(--font-mono); font-size: 0.72rem; color: var(--parchment-45); text-align: right; white-space: nowrap; }
.vlist .task::before { content: '\25A1'; color: var(--red-bright); margin-right: 0.45rem; }
.vlist .empty { color: var(--parchment-45); font-style: italic; }

.vault-panel details { margin-top: 0.8rem; }
.vault-panel summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--gold);
}
.vault-panel summary:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.vtable { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.72rem; margin-top: 0.5rem; }
.vtable th, .vtable td { text-align: left; padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--iron-line); }
.vtable td.n { text-align: right; font-variant-numeric: tabular-nums; }
.vtable th { color: var(--gold); font-weight: 500; }

@media (max-width: 34rem) {
  .hbar { grid-template-columns: minmax(5rem, 8rem) 1fr auto; }
  .tile .value { font-size: 1.55rem; }
}

/* ---------- private Third Brain map (third-brain.html) ---------- */

:root {
  /* domain hues — desaturated, sit on the iron ground without fighting gold/red */
  --dom-philosophical: #7e93a8;
  --dom-political:     var(--gold-bright);
  --dom-epistemic:     #9a86b8;
  --dom-personal:      #b9836f;
  --dom-biblical:       #b89a4d;
  --tb-work:            var(--gold);
  --tb-work-glow:        #e0b567;

  --rel-supports:    #7b9270;
  --rel-extends:     #6f93ad;
  --rel-qualifies:   var(--gold-bright);
  --rel-contradicts: var(--red-bright);
}

.tb-wrap {
  position: relative;
  height: calc(100vh - var(--tb-header-h, 4.4rem));
  min-height: 26rem;
  background: var(--ink);
  overflow: hidden;
}
.tb-wrap svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }

.tb-gate {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.tb-gate[hidden] { display: none; }
.tb-gate .card { max-width: 26rem; text-align: center; }

.tb-hud { position: absolute; z-index: 5; pointer-events: none; }
.tb-hud a, .tb-hud button, .tb-hud input { pointer-events: auto; }
.tb-detail { pointer-events: auto; }

.tb-title {
  top: 1rem; left: 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--parchment);
  max-width: 55vw;
}
.tb-title .sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--parchment-45);
  margin-top: 0.15rem;
}

.tb-search-wrap { top: 1rem; right: 1rem; width: 13.5rem; max-width: 40vw; }
.tb-search {
  width: 100%;
  background: var(--ink-card);
  border: 1px solid var(--iron-line);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  outline: none;
}
.tb-search::placeholder { color: var(--parchment-45); }
.tb-search:focus { border-color: var(--gold-bright); }
.tb-search-count { font-family: var(--font-mono); font-size: 0.65rem; color: var(--parchment-45); margin-top: 0.3rem; text-align: right; }

.tb-legend {
  bottom: 1rem; left: 1rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--parchment-45);
  line-height: 1.6;
  max-width: 15rem;
  background: var(--ink-card);
  border: 1px solid var(--iron-line);
  padding: 0.65rem 0.75rem;
}
.tb-legend .grp { margin-bottom: 0.4rem; }
.tb-legend .grp:last-child { margin-bottom: 0; }
.tb-legend .hd { color: var(--gold); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.2rem; }
.tb-legend .row { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.15rem; }
.tb-legend .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; flex-shrink: 0; }
.tb-legend .line { width: 0.9rem; height: 0; border-top: 2px solid; flex-shrink: 0; }
.tb-legend .dia { width: 0.5rem; height: 0.5rem; flex-shrink: 0; transform: rotate(45deg); }

.tb-detail {
  top: 4.6rem; right: 1rem;
  width: 19rem; max-width: 48vw; max-height: 68vh;
  overflow-y: auto;
  background: var(--ink-card);
  border: 1px solid var(--iron-line);
  padding: 0.9rem 1.05rem;
  opacity: 0; transform: translateX(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.tb-detail.show { opacity: 1; transform: translateX(0); }
.tb-detail .kicker { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.3rem; }
.tb-detail .label { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; color: var(--parchment); line-height: 1.3; }
.tb-detail .statement { font-family: var(--font-body); font-size: 0.86rem; color: var(--parchment); line-height: 1.6; margin-top: 0.6rem; }
.tb-detail .context { font-family: var(--font-body); font-style: italic; font-size: 0.8rem; color: var(--parchment-70); line-height: 1.55; margin-top: 0.5rem; }
.tb-detail .rels { margin-top: 0.75rem; border-top: 1px solid var(--iron-line); padding-top: 0.6rem; }
.tb-detail .rel-item { margin-bottom: 0.6rem; font-size: 0.8rem; line-height: 1.5; cursor: pointer; }
.tb-detail .rel-item:hover .rel-target { text-decoration: underline; }
.tb-detail .rel-type {
  display: inline-block; font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.05rem 0.4rem; margin-right: 0.3rem;
}
.tb-detail .rel-target { color: var(--parchment); font-weight: 600; }
.tb-detail .rel-note { color: var(--parchment-45); margin-top: 0.15rem; }
.tb-detail .plink { display: block; font-family: var(--font-body); font-size: 0.8rem; color: var(--dom-philosophical); margin-top: 0.35rem; cursor: pointer; }
.tb-detail .plink:hover { color: var(--gold-bright); }
.tb-detail .meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--parchment-45); margin-top: 0.25rem; }

.tb-reset-hint { bottom: 1rem; right: 1rem; font-family: var(--font-mono); font-size: 0.65rem; color: var(--parchment-45); }

.tb-node-label, .tb-work-label, .tb-dom-label { fill: var(--parchment); pointer-events: none; user-select: none; }
.tb-node-label { font-family: var(--font-mono); }
#tb-stage:not(.tb-zoomed) .tb-node:not(.lit):not(:hover) .tb-node-label { display: none; }
.tb-work-label, .tb-dom-label { font-family: var(--font-display); font-weight: 700; }

@media (max-width: 40rem) {
  .tb-legend { display: none; }
  .tb-detail { width: 15rem; }
  .tb-title { font-size: 0.95rem; max-width: 50vw; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
