/* Substrate viz — base stylesheet. Adapted from walkthrough/styles.css. */

:root {
  --bg:          #f8f6f1;
  --fg:          #1c1a17;
  --fg-muted:    #6a6660;
  --fg-dim:      #a29d96;
  --border:      #d9d4c9;
  --border-soft: #e8e3d7;
  --panel:       #ffffff;
  --accent:      #2a5d8a;

  --accent-lens:    #8aa0b8;
  --accent-cluster: #e6a95b;
  --accent-cascade: #7fc3b5;
  --accent-ne:      #b899d6;
  --accent-cf:      #8fc38a;
  --accent-flag:    #d87a6a;

  --accent-B6:  #b899d6;
  --accent-B11: #e59aa8;
  --accent-S2:  #7fc3b5;
  --accent-E1:  #e6a95b;
  --accent-P2:  #8fc38a;

  --accent-foundational:  #8aa0b8;
  --accent-procedural:    #e6a95b;
  --accent-social:        #7fc3b5;
  --accent-psychological: #b899d6;
  --accent-material:      #8fc38a;
  --accent-event:         #e59aa8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px 120px;
}

h1, h2, h3, h4, h5 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

/* ——— hero ——— */

.hero { margin-bottom: 32px; position: relative; }

/* ——— lang toggle ——— */
.nav-lang-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.lang-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.5;
}
.lang-btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.lang-btn.lang-active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 600;
}
.hero .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0 0 8px;
}
.hero h1 {
  font-size: 36px;
  font-weight: 500;
  line-height: 1.15;
  margin: 0 0 16px;
}
.hero .lede {
  font-size: 16px;
  color: var(--fg-muted);
  max-width: 72ch;
  margin: 0 0 24px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-lens);
  border-radius: 6px;
  padding: 12px 14px;
}
.stat-card.s-lens     { border-left-color: var(--accent-lens); }
.stat-card.s-cluster  { border-left-color: var(--accent-cluster); }
.stat-card.s-cascade  { border-left-color: var(--accent-cascade); }
.stat-card.s-ne       { border-left-color: var(--accent-ne); }
.stat-card.s-cf       { border-left-color: var(--accent-cf); }
.stat-card.s-flag     { border-left-color: var(--accent-flag); }
.stat-num { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 500; }
.stat-lbl { font-size: 11px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ——— substrate toggle ——— */

.substrate-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.substrate-toggle button {
  border: 0;
  background: transparent;
  font: inherit;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--fg-muted);
  font-weight: 500;
  transition: all 0.15s;
}
.substrate-toggle button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

/* ——— filter bar ——— */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--fg-muted);
  transition: all 0.12s;
}
.chip:hover { border-color: var(--fg-dim); color: var(--fg); }
.chip[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.chip .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  opacity: 0.6;
  margin-left: 4px;
}
.chip.flag-chip[aria-pressed="true"] {
  background: var(--accent-flag);
  border-color: var(--accent-flag);
}
.chip-spacer { flex: 1; }

/* ——— candidate lens space ——— */

.candidate-space {
  margin: 0 0 28px;
  padding: 16px 18px 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.candidate-space-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.candidate-space-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.candidate-space-tally {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-dim);
}
.candidate-space-blurb {
  flex-basis: 100%;
  font-size: 12.5px;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 4px 0 0;
  max-width: 78ch;
}
.candidate-families {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.candidate-family {
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 12px;
}
.candidate-family.fam-behavioral        { border-left-color: var(--accent-B6); }
.candidate-family.fam-social-structural { border-left-color: var(--accent-S2); }
.candidate-family.fam-environmental     { border-left-color: var(--accent-E1); }
.candidate-family.fam-event-proximity   { border-left-color: var(--accent-P2); }

.candidate-family-head {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.candidate-family-tally {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--fg-dim);
  letter-spacing: 0;
  text-transform: none;
}
.candidate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cand-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.5;
  letter-spacing: 0;
}
.cand-chip:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}
.cand-chip.is-picked {
  font-weight: 600;
  color: var(--bg);
  background: var(--chip-bg, var(--fg));
  border-color: var(--chip-bg, var(--fg));
}
.cand-chip.is-picked:hover {
  filter: brightness(1.08);
}
.cand-chip.is-retired {
  color: var(--fg-dim);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--fg-dim);
  border-style: dashed;
  opacity: 0.65;
}
.cand-chip.is-retired:hover { opacity: 0.9; }

/* ——— lens super-sections (trait vs state) ——— */

.lens-super { margin-bottom: 48px; }
.lens-super-head {
  margin: 0 0 18px 0;
  padding: 12px 16px 14px 16px;
  border-left: 3px solid var(--fg-dim);
  background: var(--panel);
  border-radius: 0 6px 6px 0;
}
.lens-super-trait .lens-super-head { border-left-color: var(--accent-S2, #7fc3b5); }
.lens-super-state .lens-super-head { border-left-color: var(--accent-B6, #b899d6); }
.lens-super-title {
  font-size: 18px;
  margin: 0 0 4px 0;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--fg);
}
.lens-super-sub { margin: 0; color: var(--fg-muted); font-size: 13px; }

/* ——— cluster sections ——— */

.cluster-section { margin-bottom: 40px; transition: background 0.3s ease; }
.cluster-section[aria-hidden="true"] { display: none; }
.cluster-section[data-flash="1"] {
  background: var(--panel);
  box-shadow: 0 0 0 2px var(--fg-dim);
  border-radius: 6px;
}
.empty-hint {
  color: var(--fg-dim);
  font-size: 13px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px dashed var(--border-soft);
  border-radius: 6px;
  font-style: italic;
}

.cluster-head {
  display: grid;
  grid-template-columns: 4px auto 1fr;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 16px;
  padding-left: 4px;
}
.cluster-bar {
  width: 4px;
  height: 100%;
  min-height: 28px;
  background: var(--accent-lens);
  border-radius: 2px;
}
.cluster-bar.b-B6  { background: var(--accent-B6); }
.cluster-bar.b-B11 { background: var(--accent-B11); }
.cluster-bar.b-S2  { background: var(--accent-S2); }
.cluster-bar.b-E1  { background: var(--accent-E1); }
.cluster-bar.b-P2  { background: var(--accent-P2); }
.cluster-bar.b-foundational   { background: var(--accent-foundational); }
.cluster-bar.b-procedural     { background: var(--accent-procedural); }
.cluster-bar.b-social         { background: var(--accent-social); }
.cluster-bar.b-psychological  { background: var(--accent-psychological); }
.cluster-bar.b-material       { background: var(--accent-material); }
.cluster-bar.b-event          { background: var(--accent-event); }
.cluster-head h2 { font-size: 22px; margin: 0; }
.cluster-intro { color: var(--fg-muted); font-size: 14px; grid-column: 3; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border); }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.card-name { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 500; }
.card-tagline { font-size: 12px; color: var(--fg-muted); font-family: 'JetBrains Mono', monospace; }
.card-body { font-size: 13px; color: var(--fg-muted); line-height: 1.5; }
.card-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-dim);
  font-family: 'JetBrains Mono', monospace;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.flag-badge {
  display: inline-block;
  background: var(--accent-flag);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ——— flow-map ——— */

.flow-map {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-soft);
}
.flow-title { font-size: 22px; margin-bottom: 8px; }
.flow-sub { color: var(--fg-muted); font-size: 14px; margin: 0 0 20px; max-width: 72ch; }
.cascade-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.cascade-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-cascade);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  transition: all 0.12s;
}
.cascade-card:hover { box-shadow: var(--shadow-md); }
.cascade-card h4 { font-size: 15px; margin: 0 0 4px; }
.cascade-card .cascade-meta { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--fg-dim); margin-bottom: 6px; }
.cascade-card .cascade-mech { font-size: 13px; color: var(--fg-muted); line-height: 1.45; }

/* ——— counterfactuals ——— */

.counterfactuals {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-soft);
}
.cf-sub { color: var(--fg-muted); font-size: 14px; margin: 0 0 20px; max-width: 72ch; }
.cf-subsection { margin-bottom: 32px; }
.cf-subsection h4 { font-size: 16px; margin-bottom: 12px; color: var(--fg-muted); font-family: 'Inter', sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; font-size: 12px; }

.cf-grid, .ne-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.cf-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-cf);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  transition: all 0.12s;
}
.ne-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-ne);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  transition: all 0.12s;
}
.cf-card:hover, .ne-card:hover { box-shadow: var(--shadow-md); }
.cf-card h4, .ne-card h4 { font-size: 15px; margin: 0 0 4px; }
.cf-meta, .ne-meta { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--fg-dim); margin-bottom: 6px; }
.cf-desc, .ne-desc { font-size: 13px; color: var(--fg-muted); line-height: 1.45; }

.ne-card.is-actual { border-left-color: var(--fg); background: #faf7f0; }
.ne-card.is-actual .actual-tag {
  display: inline-block;
  font-size: 10px;
  background: var(--fg);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}

.flag-end-matrix {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  overflow-x: auto;
}
.flag-end-matrix table { border-collapse: collapse; width: 100%; }
.flag-end-matrix th, .flag-end-matrix td { padding: 4px 8px; text-align: center; border: 1px solid var(--border-soft); }
.flag-end-matrix th { background: var(--bg); font-weight: 500; }
.flag-end-matrix td.has { background: var(--accent-cf); color: white; }

/* ——— slideover ——— */

.slideover {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.slideover.is-open { pointer-events: auto; }
.slideover-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30,26,22,0);
  transition: background 0.2s;
}
.slideover.is-open .slideover-backdrop { background: rgba(30,26,22,0.3); }
.slideover-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(680px, 92vw);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px 60px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.slideover.is-open .slideover-panel { transform: translateX(0); }

.slideover-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 0;
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  line-height: 1;
  color: var(--fg-muted);
}

.slideover-breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 12px;
}
.slideover-breadcrumb button {
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline dotted;
}
.slideover-breadcrumb .sep { margin: 0 6px; color: var(--fg-dim); }

.so-eyebrow { font-size: 12px; color: var(--fg-muted); margin: 0 0 8px; font-family: 'JetBrains Mono', monospace; }
.so-name { font-size: 24px; margin: 0 0 6px; }
.so-path { font-size: 12px; color: var(--fg-dim); font-family: 'JetBrains Mono', monospace; margin-bottom: 20px; }
.so-desc { color: var(--fg); max-width: 64ch; margin-bottom: 20px; }
.so-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px dashed var(--border-soft);
}
.so-section p {
  white-space: pre-line;
}
.so-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  margin-bottom: 10px;
}

.trajectory-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.traj-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.traj-row .w-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--fg-muted);
}
.traj-row .w-state { font-size: 14px; color: var(--fg); line-height: 1.5; }
.traj-row .w-source {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  text-decoration: underline dotted;
}

.cf-branches { display: grid; gap: 10px; }
.cf-branch {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 12px 14px;
}
.cf-branch.is-modal {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(42,93,138,0.15);
}
.cf-branch-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.cf-branch-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--fg-muted);
}
.cf-branch-label { font-weight: 500; }
.cf-modal-tag {
  font-size: 10px;
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}
.cf-rule { font-size: 13px; color: var(--fg-muted); line-height: 1.5; }

.involved-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.involved-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
}
.involved-chip:hover { background: var(--panel); border-color: var(--fg-dim); }

.flag-inline {
  font-size: 12px;
  background: rgba(216,122,106,0.1);
  border-left: 2px solid var(--accent-flag);
  padding: 6px 10px;
  margin-top: 6px;
  border-radius: 0 4px 4px 0;
  color: var(--fg);
}

/* ——— mdviewer ——— */

.mdviewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,26,22,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.mdviewer-panel {
  background: var(--bg);
  border-radius: 8px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px 40px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.mdviewer-panel pre { overflow-x: auto; background: var(--panel); padding: 12px; border-radius: 4px; font-size: 13px; }
.mdviewer-panel table { border-collapse: collapse; font-size: 13px; }
.mdviewer-panel th, .mdviewer-panel td { border: 1px solid var(--border-soft); padding: 6px 10px; }
.mdviewer-flag-banner {
  background: var(--accent-flag);
  color: white;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 500;
}
.mdviewer-flag-line { background: rgba(216,122,106,0.15); padding: 2px 6px; border-radius: 2px; }
.mdviewer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 0;
  font-size: 24px;
  cursor: pointer;
}

/* ——— cross-substrate handshake (Scenario 7) ——— */

.handshake { margin-top: 56px; }
.handshake .flow-title { margin-bottom: 12px; }

.handshake-card {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(127,195,181,0.05), rgba(184,153,214,0.05));
}
.handshake-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 12px;
}
.handshake-right { text-align: right; }
.handshake-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.handshake-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.handshake-arrow { font-size: 28px; color: #7fc3b5; font-weight: 300; text-align: center; }
.handshake-body {
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 8px 0 14px;
}
.handshake-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.handshake-jump {
  background: #7fc3b5;
  color: #fff;
  border-color: transparent;
}
.handshake-jump:hover { opacity: 0.9; }
.handshake-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.handshake-stat { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.hs-num { font-weight: 600; font-size: 15px; }
.hs-lbl { color: var(--fg-dim); }

/* ——— footer ——— */

footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  color: var(--fg-dim);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
}

.error-banner {
  background: rgba(216,122,106,0.1);
  border: 1px solid var(--accent-flag);
  border-radius: 6px;
  padding: 20px 24px;
  font-size: 14px;
}
.mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* ——— audit overlay ——— */

.audit { margin-top: 56px; }
.audit .flow-title { font-size: 22px; }
.audit-sub {
  color: var(--fg-muted);
  max-width: 76ch;
  margin: 0 0 12px;
}
.audit-source { margin: 0 0 16px; }

.audit-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.audit-window-row { margin-bottom: 20px; }
.audit-filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-right: 4px;
}

.audit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  padding: 5px 12px 5px 10px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
}
.audit-chip.is-off { opacity: 0.35; }
.audit-chip.is-active { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.audit-chip:hover { border-color: var(--fg-muted); }
.audit-chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.audit-chip-label { font-weight: 500; }
.audit-chip-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: 2px;
}
.audit-chip.is-active .audit-chip-count { color: var(--bg); }

.audit-matrix {
  margin: 16px 0 24px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
}
.audit-matrix-hint {
  margin: 0 0 10px;
  color: var(--fg-muted);
  font-size: 12px;
}
.audit-matrix table { border-collapse: collapse; width: 100%; }
.audit-matrix th, .audit-matrix td {
  border: 1px solid var(--border-soft);
  padding: 6px 10px;
  font-size: 13px;
  text-align: center;
}
.audit-matrix thead th {
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}
.audit-matrix tbody th {
  text-align: left;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--fg);
}
.audit-matrix td.has:hover { filter: brightness(0.92); }
.audit-matrix th.audit-matrix-wcol,
.audit-matrix th.audit-matrix-crow {
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.audit-matrix th.audit-matrix-wcol:hover,
.audit-matrix th.audit-matrix-crow:hover {
  background: var(--bg-elevated, rgba(255,255,255,0.04));
  color: var(--fg);
}
.audit-matrix th.audit-matrix-wcol.is-active,
.audit-matrix th.audit-matrix-crow.is-active {
  background: var(--accent, #7fc3b5)22;
  color: var(--fg);
  font-weight: 600;
}
.audit-matrix-drift-cell {
  display: table-cell;
  vertical-align: middle;
}
.audit-matrix-drift-cell .drift-side {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.audit-matrix-drift-cell .drift-s {
  margin-right: 3px;
}
.audit-matrix-drift-cell .drift-t {
  opacity: 0.65;
}

.audit-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}
.audit-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.08s;
}
.audit-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.audit-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.audit-card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}
.audit-card-cat {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.audit-card-title {
  font-family: 'Fraunces', serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
}
.audit-card-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.audit-card-body {
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
}
.audit-card-body-drift {
  display: flex;
  flex-direction: column;
  gap: 6px;
  white-space: normal;
}
.audit-card-body-drift .drift-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  align-items: start;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12.5px;
  line-height: 1.45;
}
.audit-card-body-drift .drift-row-s {
  background: rgba(127, 195, 181, 0.08);
  border-left: 2px solid #7fc3b5;
}
.audit-card-body-drift .drift-row-t {
  background: rgba(230, 169, 91, 0.08);
  border-left: 2px solid #e6a95b;
  opacity: 0.92;
}
.audit-card-body-drift .drift-row-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.02em;
}
.audit-card-body-drift .drift-row-text {
  color: var(--fg-muted);
}
.audit-card-body-drift .drift-row.drift-row-active {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  font-weight: 500;
}
.audit-card-body-drift .drift-row.drift-row-dim {
  opacity: 0.42;
}
.audit-card-body-drift .drift-row-marker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.04em;
  align-self: start;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.audit-card-body-drift .drift-row {
  grid-template-columns: 130px 1fr auto;
}

/* mechanism legend */
.mechanism-legend {
  margin: 10px 0 18px;
  font-size: 13px;
  color: var(--fg-muted);
}
.mechanism-legend summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--fg);
  font-size: 13px;
}
.mechanism-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.mechanism-card {
  padding: 10px 13px 11px;
  border-radius: 6px;
  background: var(--bg-elevated, rgba(255,255,255,0.02));
  border: 1px solid var(--border-soft);
}
.mechanism-card-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 5px;
}
.mech-id {
  font-weight: 700;
  color: var(--fg);
  font-size: 14px;
}
.mech-clock {
  font-family: 'JetBrains Mono', monospace;
  color: var(--fg-dim);
  font-size: 12px;
}
.mech-dominant {
  color: var(--fg);
  font-size: 13px;
  font-style: italic;
}
.mechanism-card-body {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg-muted);
}
.mechanism-card-body li {
  margin-bottom: 4px;
}
.mechanism-card-body li:last-child {
  margin-bottom: 0;
}

/* audit badge on cluster cards */
.audit-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0,0,0,0.04);
}
.audit-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.audit-badge-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--fg-muted);
  margin-left: 3px;
}

/* slideover — audit category pill */
.audit-panel-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  margin-bottom: 12px;
}

.finding-chip { font-size: 12px; }
