/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --bg: #0b0f14;
  --panel: #0f1620;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --accent: #6aa6ff;
  --accent2: #9ae6b4;
  --line: rgba(255,255,255,.09);
  --warn: #ffd27a;
  --danger: #ff7a7a;
  --card-bg: rgba(255,255,255,.03);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --panel: #f7f8fa;
    --text: #111827;
    --muted: #4b5563;
    --accent: #1d4ed8;
    --accent2: #0f766e;
    --line: rgba(17,24,39,.10);
    --warn: #9a6b00;
    --danger: #b91c1c;
    --card-bg: rgba(17,24,39,.03);
  }
}

/* ============================================================
   Reset and base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
img, svg { max-width: 100%; }

/* ============================================================
   Layout
   ============================================================ */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px;
}
.section {
  margin-top: 40px;
}
.section + .section {
  padding-top: 32px;
  border-top: 1px solid var(--line);
}
.section-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ============================================================
   Typography
   ============================================================ */
h1 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 8px;
}
h2 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 16px;
}
h3 {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  margin: 24px 0 8px;
}
h4 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 8px;
}
p {
  margin: 0 0 16px;
}
small {
  color: var(--muted);
  font-size: 14px;
}
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
}
pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
ul, ol {
  margin: 10px 0 10px 22px;
}
li {
  margin: 6px 0;
}

/* ============================================================
   Global navigation bar
   ============================================================ */
.global-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.global-nav .site-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.global-nav .site-name:hover {
  color: var(--accent);
  text-decoration: none;
}
.global-nav nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.global-nav nav a {
  font-size: 14px;
  color: var(--muted);
}
.global-nav nav a:hover {
  color: var(--accent);
}
@media (max-width: 600px) {
  .global-nav {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* ============================================================
   Color swatches
   ============================================================ */
.swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.swatch-block {
  width: 64px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.swatch-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   Callout boxes
   ============================================================ */
.callout {
  margin: 16px 0;
  padding: 16px;
  border-left: 4px solid var(--accent);
  background: rgba(106,166,255,.06);
  border-radius: 6px;
}
.callout.warn {
  border-left-color: var(--warn);
  background: rgba(255,210,122,.06);
}
.callout.danger {
  border-left-color: var(--danger);
  background: rgba(255,122,122,.06);
}
.callout.contract {
  border: 2px solid var(--accent);
  border-left-width: 4px;
  background: rgba(106,166,255,.08);
  border-radius: 6px;
  padding: 16px 20px;
}
@media (prefers-color-scheme: light) {
  .callout { background: rgba(29,78,216,.04); }
  .callout.warn { background: rgba(154,107,0,.06); }
  .callout.danger { background: rgba(185,28,28,.04); }
  .callout.contract { background: rgba(29,78,216,.05); }
}
.callout p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Cards
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 860px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}
.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
}
.card h4 {
  margin: 0 0 8px;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ============================================================
   Definition card
   ============================================================ */
.definition-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 24px;
  margin: 16px 0;
}
.definition-card .term {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}
.definition-card .definition {
  font-size: 17px;
  line-height: 1.65;
  margin: 0 0 16px;
}
.definition-card .meta-row {
  margin-bottom: 12px;
}
.definition-card .meta-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 4px;
}
.definition-card .meta-value {
  font-size: 15px;
  color: var(--text);
}
.definition-card .cross-links {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  display: inline-block;
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(106,166,255,.06);
  text-decoration: none;
}
.pill:hover {
  background: rgba(106,166,255,.12);
  text-decoration: none;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover {
  background: rgba(255,255,255,.06);
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  border-color: var(--accent);
  background: rgba(106,166,255,.12);
  color: var(--accent);
}
.btn.primary:hover {
  background: rgba(106,166,255,.2);
}
@media (prefers-color-scheme: light) {
  .btn:hover { background: rgba(17,24,39,.04); }
  .btn.primary { background: rgba(29,78,216,.08); color: var(--accent); }
  .btn.primary:hover { background: rgba(29,78,216,.14); }
}

/* ============================================================
   Panel sequence (3-panel comic)
   ============================================================ */
.panel-sequence {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 860px) {
  .panel-sequence {
    grid-template-columns: 1fr;
  }
}
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 16px;
  text-align: center;
}
.panel svg {
  display: block;
  margin: 0 auto 12px;
}
.panel .caption {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Spotlight panel
   ============================================================ */
.panel-spotlight {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 32px;
  margin: 16px 0;
  text-align: center;
}
.panel-spotlight svg {
  display: block;
  margin: 0 auto 16px;
}
.panel-spotlight .faded {
  opacity: 0.25;
}
.panel-spotlight .caption {
  font-size: 15px;
  color: var(--muted);
  font-style: italic;
  max-width: 480px;
  margin: 0 auto;
}

/* ============================================================
   Branching outcomes
   ============================================================ */
.branch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 860px) {
  .branch-grid {
    grid-template-columns: 1fr;
  }
}
.panel-branch {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 16px;
  text-align: center;
}
.panel-branch.met {
  border-top: 3px solid var(--accent2);
}
.panel-branch.not-met {
  border-top: 3px solid var(--danger);
}
.panel-branch svg {
  display: block;
  margin: 0 auto 12px;
}
.panel-branch .branch-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.panel-branch.met .branch-label {
  color: var(--accent2);
}
.panel-branch.not-met .branch-label {
  color: var(--danger);
}
.panel-branch .caption {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Page navigation (prev / next)
   ============================================================ */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin: 32px 0 0;
  border-top: 1px solid var(--line);
}
.page-nav a {
  font-size: 15px;
  color: var(--accent);
}
.page-nav .prev::before {
  content: "\2190\00a0";
}
.page-nav .next::after {
  content: "\00a0\2192";
}
@media (max-width: 600px) {
  .page-nav {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* ============================================================
   Spacing grid reference
   ============================================================ */
.spacing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 16px 0;
}
.spacing-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.spacing-block {
  background: var(--accent);
  opacity: 0.4;
  border-radius: 4px;
  height: 40px;
}
.spacing-box .spacing-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
}

/* ============================================================
   Scroll reveal
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    transform: none;
    transition: opacity 0.3s ease;
  }
  .btn {
    transition: none;
  }
}

/* ============================================================
   SVG defaults
   ============================================================ */
svg text {
  font-family: var(--sans);
}

/* ============================================================
   Utility
   ============================================================ */
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}
hr.tile-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

/* ============================================================
   Page header (spec pages)
   ============================================================ */
.page-header {
  margin-bottom: 32px;
}
.page-header .kicker {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.page-intro {
  font-size: 18px;
  color: var(--muted);
  max-width: 65ch;
  margin: 8px 0 0;
  line-height: 1.55;
}

/* ============================================================
   Section navigation (on-page anchors)
   ============================================================ */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.section-nav a {
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--card-bg);
}
.section-nav a:hover {
  color: var(--accent);
  background: rgba(106,166,255,.06);
  text-decoration: none;
}
@media (prefers-color-scheme: light) {
  .section-nav a:hover {
    background: rgba(29,78,216,.04);
  }
}

/* ============================================================
   Index page: section cards
   ============================================================ */
.page-index .section {
  margin-top: 26px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.02);
}
.page-index .section + .section {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.page-index .section h2 {
  margin: 0 0 10px;
  font-size: 22px;
}
.page-index .section h3 {
  margin: 18px 0 8px;
  font-size: 18px;
}
.page-index p {
  margin: 10px 0;
}
.page-index h1 {
  margin: 10px 0 6px;
  font-size: 38px;
  line-height: 1.15;
}

/* ============================================================
   Index page: hero header card
   ============================================================ */
.header {
  padding: 26px 26px 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(106,166,255,.14), rgba(0,0,0,0));
  border-radius: 18px;
}
.kicker {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  max-width: 78ch;
}
.badges {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.badge {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   Index page: section navigation
   ============================================================ */
.nav {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.nav a {
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255,255,255,.03);
}
.nav a:hover {
  background: rgba(255,255,255,.06);
  text-decoration: none;
}
.nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Index page: call-to-action group
   ============================================================ */
.cta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============================================================
   Index page: grid layouts
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0;
}

/* ============================================================
   Index page: failure mode cards
   ============================================================ */
.failure-mode {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-bg);
}
.failure-mode h4 {
  margin: 0 0 8px;
  font-size: 16px;
}
.failure-mode dl {
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 14px;
}
.failure-mode dt {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.failure-mode dd {
  margin: 0;
}

/* ============================================================
   Index page: diagram caption
   ============================================================ */
.diagram-caption {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  margin-bottom: 10px;
}

/* ============================================================
   Index page: footer text
   ============================================================ */
.footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   Back to top button
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  font-size: 20px;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  background: rgba(106,166,255,.12);
  text-decoration: none;
}
.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-color-scheme: light) {
  .back-to-top {
    box-shadow: 0 2px 8px rgba(0,0,0,.10);
  }
  .back-to-top:hover {
    background: rgba(29,78,216,.08);
  }
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: opacity 0.15s ease;
    transform: none;
  }
  .back-to-top.visible { transform: none; }
}

/* ============================================================
   Light mode overrides
   ============================================================ */
@media (prefers-color-scheme: light) {
  pre {
    background: rgba(17,24,39,.04);
  }
}

/* ============================================================
   Responsive: medium screens
   ============================================================ */
@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 30px;
  }
}

/* ── Lifecycle page ────────────────────────────── */
.transition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 16px 0;
}
.transition-table th, .transition-table td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.transition-table th {
  background: var(--card-bg);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.transition-table tr:hover td {
  background: var(--card-bg);
}
.state-diagram-wrap {
  overflow-x: auto;
  margin: 16px 0;
  -webkit-overflow-scrolling: touch;
}
.state-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
@media (max-width: 860px) {
  .state-list {
    grid-template-columns: 1fr;
  }
}
.state-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  border-left-width: 4px;
}
.state-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
}
.state-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.state-card.phase-alive { border-left-color: var(--accent); }
.state-card.phase-verify { border-left-color: var(--warn); }
.state-card.phase-transition { border-left-color: var(--muted); }
.state-card.phase-active { border-left-color: var(--accent2); }
.state-card.phase-protect { border-left-color: var(--danger); }
.state-card.phase-terminal { border-left-color: var(--muted); opacity: 0.85; }
.phase-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 20px;
  font-size: 13px;
}
.phase-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.phase-dot.alive { background: var(--accent); }
.phase-dot.verify { background: var(--warn); }
.phase-dot.trans { background: var(--muted); }
.phase-dot.active { background: var(--accent2); }
.phase-dot.protect { background: var(--danger); }
.phase-dot.terminal { background: var(--muted); opacity: 0.5; }
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Scroll highlight ──────────────────────────── */
.highlighted {
  box-shadow: 0 0 0 3px var(--accent);
  transition: box-shadow 0.4s ease;
}

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

@media (prefers-color-scheme: light) {
  .highlighted {
    box-shadow: 0 0 0 3px var(--accent);
  }
}

/* ── Print ─────────────────────────────────────── */
@media print {
  .global-nav,
  .back-to-top {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
  }

  nav a[href]::after {
    content: none;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ── Graph page ───────────────────────────────── */
.graph-page-header {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 0;
}
.graph-page-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px;
}
.graph-page-header .page-intro {
  margin: 0 0 4px;
}
.graph-tip {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.graph-controls {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 20px;
  position: sticky;
  top: 49px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.graph-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 140px;
}
.graph-search label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.graph-search input {
  flex: 1;
  padding: 6px 10px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}
.graph-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(106,166,255,.2);
}
.graph-search input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}
.graph-search .clear-btn {
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.graph-search .clear-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,.06);
}
.graph-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.graph-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(106,166,255,.06);
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.15s ease;
}
.graph-chip:hover {
  background: rgba(106,166,255,.12);
}
.graph-chip[aria-pressed="false"] {
  opacity: 0.4;
}
.graph-chip[aria-pressed="false"] .chip-dot {
  background: var(--muted) !important;
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.graph-reset-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--accent);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.graph-reset-btn:hover {
  background: rgba(106,166,255,.12);
}
.graph-container {
  width: 100%;
  min-height: 400px;
  height: calc(100vh - 200px);
  background: var(--bg);
  position: relative;
}
#sigma-canvas {
  width: 100%;
  height: 100%;
}
.graph-fallback {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.graph-error {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  color: var(--danger);
  font-size: 15px;
}
.graph-tooltip {
  position: absolute;
  z-index: 60;
  max-width: 240px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.graph-tooltip.visible {
  opacity: 1;
}
.graph-list-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.graph-list-wrap summary {
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  padding: 8px 0;
}
.graph-list-wrap summary:hover {
  text-decoration: underline;
}
.graph-list-group h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
}
.graph-list-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.graph-list-group li {
  margin: 6px 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
}
.graph-list-group li a {
  font-weight: 600;
  font-size: 15px;
}
.graph-list-group li .list-desc {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.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;
}

@media (prefers-color-scheme: light) {
  .graph-search .clear-btn:hover { background: rgba(17,24,39,.04); }
  .graph-chip { background: rgba(29,78,216,.04); }
  .graph-chip:hover { background: rgba(29,78,216,.08); }
  .graph-reset-btn:hover { background: rgba(29,78,216,.08); }
  .graph-tooltip { box-shadow: 0 2px 8px rgba(0,0,0,.10); }
  .graph-search input:focus { box-shadow: 0 0 0 2px rgba(29,78,216,.15); }
}

@media (max-width: 860px) {
  .graph-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .graph-container {
    height: calc(100vh - 280px);
    min-height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .graph-chip { transition: none; }
  .graph-tooltip { transition: none; }
}
