/*
 * Ezkey Method · Local Explorer — styles
 * Palette aligned with product-docs/methodology/view/index.html.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --blue: #2563eb;
  --cyan: #0891b2;
  --amber: #d97706;
  --violet: #7c3aed;
  --indigo: #4f46e5;
  --teal: #0d9488;
  --green: #16a34a;
  --red: #dc2626;
  --slate: #475569;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --topbar-h: 52px;
  --rail-w: 280px;
  --rail-w-right: 240px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.brand:hover .brand-mark {
  text-decoration: underline;
}

.topbar-link {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.topbar-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.brand-mark {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--blue);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.personae {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.persona-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.55;
}

.persona-btn:not([disabled]):hover {
  background: var(--surface-alt);
  color: var(--text);
}

.topbar-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--rail-w-right);
  min-height: 0;
}

.rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 14px;
}

.rail-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.rail-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 6px 12px;
}

/* ── Tree ───────────────────────────────────────────────────────────────── */

.tree ul {
  list-style: none;
}

.tree li {
  margin: 1px 0;
}

.tree .node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  line-height: 1.3;
}

.tree .node:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.tree .node.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue);
  font-weight: 500;
}

.tree .toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.tree .toggle.open {
  transform: rotate(90deg);
}

.tree .toggle.leaf {
  visibility: hidden;
}

.tree .icon {
  font-size: 0.75rem;
  flex-shrink: 0;
  width: 14px;
  display: inline-flex;
  justify-content: center;
  color: var(--text-muted);
}

.tree .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree ul ul {
  margin-left: 14px;
  border-left: 1px solid var(--border);
  padding-left: 4px;
}

.tree .collapsed {
  display: none;
}

.tree .root > .node {
  font-weight: 600;
  color: var(--text);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 8px 6px;
}

.tree .root > .node:hover {
  background: transparent;
}

/* ── Content / breadcrumb / doc ─────────────────────────────────────────── */

.content {
  overflow-y: auto;
  padding: 24px 40px 80px;
  min-width: 0;
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb .crumb {
  color: var(--text-secondary);
}

.breadcrumb .sep {
  color: var(--text-muted);
}

.doc {
  max-width: 820px;
}

.doc h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
  line-height: 1.25;
}

.doc h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 36px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.doc h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 24px 0 8px;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.doc h4 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 18px 0 6px;
  color: var(--text-secondary);
}

.doc p, .doc ul, .doc ol, .doc blockquote, .doc table, .doc pre, .doc figure {
  margin: 0 0 14px;
}

.doc ul, .doc ol {
  padding-left: 24px;
}

.doc li {
  margin: 4px 0;
}

.doc a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 99, 235, 0.25);
}

.doc a:hover {
  border-bottom-color: var(--blue);
}

.doc code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

.doc pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
}

.doc pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.doc blockquote {
  border-left: 3px solid var(--cyan);
  padding: 4px 0 4px 14px;
  color: var(--text-secondary);
  background: rgba(8, 145, 178, 0.04);
}

.doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
}

.doc th, .doc td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.doc th {
  background: var(--surface-alt);
  font-weight: 600;
}

.doc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.doc img {
  max-width: 100%;
  height: auto;
}

/* Mermaid placeholder */
.diagram-placeholder {
  border: 1px dashed var(--violet);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(124, 58, 237, 0.04);
}

.diagram-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--violet);
  margin-bottom: 8px;
}

.diagram-placeholder pre {
  margin: 0;
  background: var(--surface);
}

/* ── Home page ──────────────────────────────────────────────────────────── */

.home {
  padding: 8px 0;
}

.home .lede {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 28px;
}

.persona-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 20px 0 28px;
}

.persona-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.persona-card[data-track] {
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.persona-card[data-track]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.persona-card[data-track="discover"]:hover { border-color: var(--cyan); }
.persona-card[data-track="apply"]:hover    { border-color: var(--blue); }
.persona-card[data-track="present"]:hover  { border-color: var(--violet); }

.persona-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.persona-card:nth-child(1) h3 { color: var(--cyan); }
.persona-card:nth-child(2) h3 { color: var(--blue); }
.persona-card:nth-child(3) h3 { color: var(--violet); }

.persona-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.card-status {
  font-size: 0.7rem !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 !important;
}

.home-shortcut {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.home-shortcut a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 99, 235, 0.25);
}

/* ── TOC ────────────────────────────────────────────────────────────────── */

.toc {
  font-size: 0.83rem;
  line-height: 1.45;
}

.toc ul {
  list-style: none;
  padding: 0;
}

.toc a {
  display: block;
  padding: 4px 8px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.toc a:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.toc a.active {
  color: var(--blue);
  border-left-color: var(--blue);
  background: rgba(37, 99, 235, 0.05);
}

.toc .lvl-3 a {
  padding-left: 22px;
  font-size: 0.78rem;
}

.toc-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  padding: 4px 8px;
}

/* ── Error / loading states ─────────────────────────────────────────────── */

.error {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--red);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.loading {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 12px 0;
}

/* ── Responsive (minimal) ───────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }
  .rail-right {
    display: none;
  }
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .rail-left {
    display: none;
  }
  .content {
    padding: 20px;
  }
}

/* ── Persona buttons (active state, P2) ─────────────────────────────────── */

.persona-btn {
  cursor: pointer;
  opacity: 1;
}

.persona-btn[data-track="discover"]      { --pcolor: var(--cyan); }
.persona-btn[data-track="apply"]         { --pcolor: var(--blue); }
.persona-btn[data-track="present"]       { --pcolor: var(--violet); }

.persona-btn:not([disabled]):hover {
  border-color: var(--pcolor);
  color: var(--pcolor);
  background: var(--surface);
}

.persona-btn.active {
  background: var(--pcolor);
  color: #fff;
  border-color: var(--pcolor);
  font-weight: 600;
}

.persona-btn.active:hover {
  background: var(--pcolor);
  color: #fff;
  opacity: 0.92;
}

/* ── Phase ribbon ───────────────────────────────────────────────────────── */

.phase-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--phase-color-bg, rgba(37, 99, 235, 0.08));
  color: var(--phase-color, var(--blue));
  border: 1px solid var(--phase-color-border, rgba(37, 99, 235, 0.25));
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
  width: fit-content;
}

.phase-ribbon .phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--phase-color, var(--blue));
}

.phase-ribbon .phase-desc {
  color: var(--text-secondary);
  font-weight: 400;
  border-left: 1px solid var(--phase-color-border, rgba(37, 99, 235, 0.25));
  padding-left: 10px;
  font-size: 0.74rem;
}

/* ── Tree pastilles (track membership) ──────────────────────────────────── */

.tree .node {
  position: relative;
}

.tree .node .track-pastille {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--track-color, var(--blue));
  display: inline-block;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.85;
  box-shadow: 0 0 0 2px var(--surface);
}

.tree .node .track-pastille.is-current {
  width: 9px;
  height: 9px;
  outline: 1.5px solid var(--track-color, var(--blue));
  outline-offset: 1px;
  opacity: 1;
}

/* ── Wizard footer ──────────────────────────────────────────────────────── */

body.has-wizard .content {
  padding-bottom: 120px;
}

.wizard-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 2px solid var(--track-color, var(--blue));
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.04);
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  z-index: 20;
}

.wizard-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wizard-track-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--track-color, var(--blue));
}

.wizard-step-counter {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.wizard-center {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.wizard-narration {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wizard-step-nav {
  display: flex;
  gap: 4px;
}

.wizard-dot {
  width: 22px;
  height: 5px;
  border-radius: 2px;
  border: none;
  background: var(--border-strong);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}

.wizard-dot:hover {
  background: var(--text-muted);
}

.wizard-dot.active {
  background: var(--track-color, var(--blue));
}

.wizard-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.wizard-btn {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
}

.wizard-btn:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border-strong);
}

.wizard-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wizard-btn.primary {
  background: var(--track-color, var(--blue));
  color: #fff;
  border-color: var(--track-color, var(--blue));
}

.wizard-btn.primary:hover:not(:disabled) {
  opacity: 0.9;
  color: #fff;
  background: var(--track-color, var(--blue));
}

.wizard-btn.subtle {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-color: transparent;
}

.wizard-btn.subtle:hover {
  color: var(--text-secondary);
  background: var(--surface-alt);
}

@media (max-width: 900px) {
  .wizard-footer {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }
  .wizard-left { display: none; }
}

/* ── Mermaid rendered ───────────────────────────────────────────────────── */

.diagram-rendered {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  text-align: center;
  margin: 0 0 14px;
}

.diagram-rendered svg {
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 10px;
}

.diagram-error {
  margin-top: 10px;
  color: var(--red);
  font-size: 0.8rem;
  background: rgba(220, 38, 38, 0.06);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

/* ── Glossary terms ─────────────────────────────────────────────────────── */

.glossary-term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  outline: none;
}

.glossary-term:hover,
.glossary-term:focus {
  background: rgba(37, 99, 235, 0.08);
  border-bottom-color: var(--blue);
  border-bottom-style: solid;
}

.glossary-tooltip {
  position: fixed;
  z-index: 100;
  max-width: 360px;
  background: var(--text);
  color: #f8fafc;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  pointer-events: auto;
}

.glossary-tooltip-header {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: #fff;
}

.glossary-tooltip-body {
  color: #cbd5e1;
  margin-bottom: 8px;
}

.glossary-tooltip-link {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.76rem;
  border-bottom: 1px dotted #93c5fd;
}

.glossary-tooltip-link:hover {
  color: #bfdbfe;
}

/* ════════════════════════════════════════════════════════════════════════
 * Phase 3 — Polish
 * Search palette, presentation mode, cognitive map, permaliens, dark mode,
 * backlinks panel, mtime badge, topbar tool buttons.
 * ════════════════════════════════════════════════════════════════════════ */

/* ── Topbar tool buttons ───────────────────────────────────────────────── */

.topbar-tools {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  color: var(--text);
}

.icon-glyph {
  font-size: 1rem;
  line-height: 1;
}

.icon-kbd {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topbar-meta {
  margin-left: 0;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Search palette ────────────────────────────────────────────────────── */

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 9000;
  padding-top: 12vh;
}

.search-overlay.is-open { display: flex; }

.search-palette {
  width: min(640px, 92vw);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
}

.search-input {
  border: none;
  outline: none;
  padding: 16px 20px;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.search-results {
  overflow-y: auto;
  max-height: 60vh;
}

.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--surface-alt);
  cursor: pointer;
}

.search-result.is-active,
.search-result:hover {
  background: var(--surface-alt);
}

.search-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.kind-doc {
  background: rgba(37, 99, 235, 0.10);
  color: var(--blue);
}

.kind-heading {
  background: rgba(124, 58, 237, 0.10);
  color: var(--violet);
}

.search-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-primary {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-secondary {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Permalink copy hint feedback (uses .wizard-btn) ───────────────────── */

/* ── Cognitive map ─────────────────────────────────────────────────────── */

.map-wrap {
  padding: 8px 4px 24px;
}

.map-wrap h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.map-lead {
  color: var(--text-secondary);
  margin-bottom: 18px;
  max-width: 640px;
}

.map-svg {
  width: 100%;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.map-node:hover rect {
  fill: var(--surface-alt);
}

.map-node:focus rect {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.map-legend {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Backlinks panel + mtime badge ─────────────────────────────────────── */

.backlinks {
  margin-top: 36px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--indigo);
  border-radius: var(--radius-sm);
}

.backlinks h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.backlinks ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.backlinks li {
  padding: 3px 0;
  font-size: 0.9rem;
}

.backlinks a {
  color: var(--blue);
  text-decoration: none;
}

.backlinks a:hover {
  text-decoration: underline;
}

.backlink-ctx {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.84rem;
}

.mtime-badge {
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Presentation mode ─────────────────────────────────────────────────── */

body.is-presentation .topbar,
body.is-presentation .rail,
body.is-presentation .breadcrumb {
  display: none;
}

body.is-presentation .layout {
  grid-template-columns: 1fr;
}

body.is-presentation .content {
  padding: 60px 10vw 160px;
  max-width: 1100px;
  margin: 0 auto;
}

body.is-presentation .doc {
  font-size: 1.18rem;
  line-height: 1.65;
}

body.is-presentation .doc h1 { font-size: 2.6rem; }
body.is-presentation .doc h2 { font-size: 1.9rem; }
body.is-presentation .doc h3 { font-size: 1.45rem; }
body.is-presentation .doc p,
body.is-presentation .doc li { font-size: 1.05em; }

body.is-presentation .phase-ribbon {
  font-size: 0.95rem;
  padding: 10px 14px;
}

body.is-presentation .wizard-footer {
  font-size: 1rem;
}

body.is-presentation .wizard-narration {
  font-size: 1.05rem;
  -webkit-line-clamp: 3;
}

/* ── Dark mode ─────────────────────────────────────────────────────────── */

body.is-dark {
  --bg: #0b1220;
  --surface: #111827;
  --surface-alt: #1f2937;
  --border: #1f2937;
  --border-strong: #334155;
  --text: #e5e7eb;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.is-dark .doc code:not(.hljs) {
  background: #1f2937;
  color: #e5e7eb;
}

body.is-dark .doc pre {
  background: #0f172a;
}

body.is-dark .hljs {
  background: #0f172a;
  color: #e5e7eb;
}

body.is-dark .map-svg {
  background: #0f172a;
}

body.is-dark .map-node rect {
  fill: #111827;
}

body.is-dark .map-node text {
  fill: #e5e7eb;
}

body.is-dark .map-node:hover rect {
  fill: #1f2937;
}

body.is-dark .search-palette {
  background: #111827;
  color: var(--text);
}

body.is-dark .search-overlay {
  background: rgba(0, 0, 0, 0.6);
}

body.is-dark .kind-doc { background: rgba(96, 165, 250, 0.15); color: #93c5fd; }
body.is-dark .kind-heading { background: rgba(167, 139, 250, 0.18); color: #c4b5fd; }

