/* ==========================================================================
   leanre static site styles
   Calm editorial layout: hairline borders, generous rhythm, readable prose
   columns. Dark default with a matching light theme.
   ========================================================================== */

:root {
  --bg:         #101318;
  --bg-chrome:  rgba(16, 19, 24, 0.92);
  --bg-panel:   #14181e;
  --bg-elev:    #1a1f27;
  --bg-hover:   #1f2530;
  --bg-code:    #0c0f13;
  --border:     #252b35;
  --border-hi:  #3a4352;

  --text-hi:    #eceff3;
  --text-body:  #c5ccd6;
  --text-muted: #9ba7b8;
  --text-dim:   #8a95a6;

  --accent:     #7cc4e4;
  --accent-bg:  rgba(124, 196, 228, 0.10);

  --emerald:    #6fcf9f;
  --emerald-bg: rgba(111, 207, 159, 0.10);
  --emerald-bd: rgba(111, 207, 159, 0.30);

  --cyan:       #7cc4e4;
  --cyan-bg:    rgba(124, 196, 228, 0.10);
  --cyan-bd:    rgba(124, 196, 228, 0.32);

  --teal:       #66c6b8;
  --amber:      #e0a95a;
  --amber-bg:   rgba(224, 169, 90, 0.10);
  --amber-bd:   rgba(224, 169, 90, 0.32);

  --crimson:    #e2777a;
  --crimson-bg: rgba(226, 119, 122, 0.10);
  --crimson-bd: rgba(226, 119, 122, 0.32);

  --blue:       #8fb3ea;
  --slate:      #9aa4b2;
  --shadow:     0 18px 48px rgba(0, 0, 0, 0.45);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --serif-math: Georgia, "Times New Roman", "Cambria Math", serif;

  /* Lean source tokens */
  --tok-kw:    #c7a6f5;
  --tok-tac:   #8ec9e8;
  --tok-name:  #f0f3f6;
  --tok-com:   #6f7a8a;
  --tok-str:   #a6d4a0;
  --tok-num:   #e8b27d;
  --tok-attr:  #d7b46a;
  --tok-punct: #8c96a5;
  --tok-sorry: #ff8a8a;
  --src-hl:    rgba(124, 196, 228, 0.12);
}

html[data-theme="light"] {
  --bg:         #fbfbf9;
  --bg-chrome:  rgba(251, 251, 249, 0.94);
  --bg-panel:   #ffffff;
  --bg-elev:    #f4f4f1;
  --bg-hover:   #ecece8;
  --bg-code:    #f6f6f3;
  --border:     #e3e3de;
  --border-hi:  #c3c3bc;

  --text-hi:    #17191c;
  --text-body:  #3b4048;
  --text-muted: #4d5664;
  --text-dim:   #5b626d;

  --accent:     #1f6f96;
  --accent-bg:  rgba(31, 111, 150, 0.08);

  --emerald:    #18794e;
  --emerald-bg: rgba(24, 121, 78, 0.08);
  --emerald-bd: rgba(24, 121, 78, 0.28);

  --cyan:       #1f6f96;
  --cyan-bg:    rgba(31, 111, 150, 0.08);
  --cyan-bd:    rgba(31, 111, 150, 0.28);

  --teal:       #0f766e;
  --amber:      #9a5b0b;
  --amber-bg:   rgba(154, 91, 11, 0.08);
  --amber-bd:   rgba(154, 91, 11, 0.28);

  --crimson:    #b42d34;
  --crimson-bg: rgba(180, 45, 52, 0.07);
  --crimson-bd: rgba(180, 45, 52, 0.26);

  --blue:       #2f5fb3;
  --slate:      #66707c;
  --shadow:     0 18px 48px rgba(23, 25, 28, 0.14);

  --tok-kw:    #6d3fc0;
  --tok-tac:   #1f6f96;
  --tok-name:  #111316;
  --tok-com:   #7b828c;
  --tok-str:   #2f7a35;
  --tok-num:   #a35a12;
  --tok-attr:  #8a6410;
  --tok-punct: #6a707a;
  --tok-sorry: #c0262d;
  --src-hl:    rgba(31, 111, 150, 0.10);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.src-open { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, pre, kbd, .mono { font-family: var(--mono); }
button, input, select { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ---------- Layout Shell ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(10px);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text-hi);
}
.brand-repo {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-repo:empty, .brand-repo.hidden { display: none; }

.main-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
  align-self: stretch;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 450;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--text-hi); }
.nav-tab.active {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
  font-weight: 550;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 12px;
  min-width: 96px;
  justify-content: space-between;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.search-trigger:hover { border-color: var(--border-hi); color: var(--text-hi); }
.search-trigger kbd {
  font-size: 11px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-body);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--border-hi); background: var(--bg-elev); }

.repo-link {
  font-size: 12.5px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  color: var(--text-body);
  white-space: nowrap;
}
.repo-link:hover { border-color: var(--border-hi); color: var(--text-hi); text-decoration: none; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 36px 24px 72px;
}
.app-main.full-bleed {
  max-width: 100%;
  padding: 14px 18px 18px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  text-align: center;
}
.footer-inner .sep { color: var(--border-hi); }
.footer-inner a { color: var(--text-muted); }

/* ---------- Common Components ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--border-hi); background: var(--bg-elev); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.primary {
  background: var(--text-hi);
  border-color: var(--text-hi);
  color: var(--bg);
  font-weight: 550;
}
.btn.primary:hover { background: var(--text-body); border-color: var(--text-body); }
.btn.emerald { color: var(--emerald); }

.input, .select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 13px;
  color: var(--text-hi);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, .select:focus { border-color: var(--border-hi); }
.input::placeholder { color: var(--text-dim); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.seg button {
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 450;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text-hi); background: var(--bg-elev); }
.seg button.active { background: var(--bg-elev); color: var(--text-hi); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
}
.pill.emerald { color: var(--emerald); }
.pill.cyan    { color: var(--cyan); }
.pill.amber   { color: var(--amber); }
.pill.crimson { color: var(--crimson); }
.pill.blue    { color: var(--blue); }
.pill.slate   { color: var(--slate); }

.panel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
}

.section-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 52px 0 14px;
}
.section-hdr h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-hi);
}
.section-hdr .sub { font-size: 13px; color: var(--text-muted); }
.section-lede {
  margin: -4px 0 18px;
  max-width: 72ch;
  color: var(--text-muted);
  font-size: 14px;
}

.page-head { margin: 0 0 28px; max-width: 78ch; }
.page-head h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--text-hi);
}
.page-lede { margin: 0; font-size: 16px; line-height: 1.65; color: var(--text-body); max-width: 72ch; }
.quiet-note {
  margin: 14px 0 0;
  max-width: 78ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}
.page-head + .quiet-note { margin: -12px 0 24px; }

.toolbar-count { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.loading-card, .empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
}
.empty-card h3 { margin: 0; color: var(--text-hi); font-size: 16px; font-weight: 600; }
.empty-card p { margin: 0; max-width: 520px; font-size: 13.5px; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Overview ---------- */
.hero {
  padding: 28px 0 40px;
  margin-bottom: 8px;
  max-width: 80ch;
}
.hero h1 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.hero-sub {
  margin: 0;
  color: var(--text-body);
  max-width: 68ch;
  font-size: 17.5px;
  line-height: 1.65;
}
.hero-note {
  margin: 18px 0 0;
  max-width: 72ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}
.hero-note code { font-size: 12.5px; color: var(--text-body); }
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 28px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
  margin: 0 0 28px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi-card {
  padding: 18px 20px 18px 0;
  margin-right: 20px;
}
.kpi-val {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-hi);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi-val.emerald, .kpi-val.cyan, .kpi-val.amber, .kpi-val.crimson { color: var(--text-hi); }
.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  margin-top: 4px;
}
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Legacy banner class: kept quiet if any old markup still uses it. */
.scope-banner {
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border-hi);
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-muted);
}
.scope-banner .scope-tag { display: none; }

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 12px;
}
.overview-grid .section-hdr { margin-bottom: 10px; }
.overview-grid .section-lede { margin: 0 0 18px; font-size: 13.5px; }

.dom-tree {
  display: flex;
  flex-direction: column;
}
.dom-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(100px, 1fr) 100px;
  align-items: center;
  gap: 14px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.dom-row:last-child { border-bottom: 0; }
.dom-row.clickable { cursor: pointer; }
.dom-row.clickable:hover { background: var(--bg-elev); }
.dom-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.dom-name .indent {
  color: var(--text-dim);
  font-family: var(--mono);
  flex-shrink: 0;
}
.dom-name .lbl {
  color: var(--text-hi);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dom-name .sub-note {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dom-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev);
  overflow: hidden;
}
.dom-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.75;
}
.dom-bar-fill.emerald { background: var(--accent); }
.dom-bar-fill.amber   { background: var(--amber); }
.dom-bar-fill.teal    { background: var(--teal); }
.dom-count {
  text-align: right;
  font-size: 12.5px;
  color: var(--text-body);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.showcase-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0 18px;
}
.showcase-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 2px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.showcase-btn:hover .sc-title { color: var(--accent); }
.showcase-btn .sc-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.showcase-btn .sc-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.showcase-btn .sc-tag { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.showcase-btn .sc-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.findings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0 28px;
}
.finding-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.finding-card:hover .fc-title { color: var(--accent); }
.finding-card .fc-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-hi);
  line-height: 1.3;
  transition: color 0.15s;
}
.finding-card .fc-sum {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Proof Circuit Viewer ---------- */
.circuit-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 122px);
  min-height: 540px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-panel);
}

.cir-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cir-toolbar .spacer { flex: 1; }

.cir-crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11.5px;
}
.cir-crumb {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}
.cir-crumb:hover { border-color: var(--cyan-bd); color: var(--text-hi); }
.cir-crumb.cur { border-color: var(--cyan-bd); color: var(--cyan); background: var(--cyan-bg); font-weight: 600; }
.cir-crumb-sep { color: var(--text-dim); }

.cir-selector-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.cir-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cir-chips-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 3px;
  max-height: 74px;
  flex-wrap: wrap;
  overflow-y: auto;
}
.cir-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.cir-chip:hover { border-color: var(--cyan-bd); color: var(--text-hi); }
.cir-chip.active {
  background: var(--cyan-bg);
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 600;
}
.cir-chip .chip-tag {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
  border-radius: 4px;
  background: var(--bg-code);
}
.cir-chip.active .chip-tag { color: var(--cyan); }

.cir-legend-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: var(--bg-code);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  flex-wrap: wrap;
}
.cir-leg-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
}
.cir-leg-pill i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.cir-leg-pill.emerald i { background: var(--emerald); }
.cir-leg-pill.cyan    i { background: var(--cyan); }
.cir-leg-pill.amber   i { background: var(--amber); }
.cir-leg-pill.crimson i { background: var(--crimson); }
.cir-leg-pill.slate   i { background: var(--slate); }
.cir-leg-pill.blue    i { background: var(--blue); }

.cir-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.cir-stage-wrap {
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: var(--bg);
}
.cir-stage-wrap.dragging { cursor: grabbing; }
.cir-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
.cir-stage svg {
  display: block;
  user-select: none;
}
.cir-stage .circuit-node,
.cir-stage .circuit-pin {
  cursor: pointer;
  transition: opacity 0.14s;
}
.cir-stage .circuit-node:hover rect,
.cir-stage .circuit-pin:hover rect {
  filter: brightness(1.14);
}
.cir-stage .circuit-node.dim,
.cir-stage .circuit-pin.dim {
  opacity: 0.18;
}
.cir-stage .circuit-node.hl rect,
.cir-stage .circuit-pin.hl rect,
.cir-stage .circuit-node.selected rect,
.cir-stage .circuit-pin.selected rect {
  stroke-width: 2.8 !important;
}

.cir-inspector {
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cir-ins-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.cir-ins-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
  overflow-wrap: anywhere;
}
.cir-ins-kv {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 5px 8px;
  font-size: 12px;
}
.cir-ins-kv .k { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.cir-ins-kv .v { color: var(--text-hi); overflow-wrap: anywhere; font-family: var(--mono); font-size: 11.5px; }
.cir-ins-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cir-ins-note { font-size: 12px; color: var(--text-muted); line-height: 1.45; }

.circuit-tip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  display: none;
  max-width: 420px;
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--bg-chrome);
  border: 1px solid var(--cyan-bd);
  color: var(--text-hi);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  word-break: break-word;
}

/* ---------- Split Document Reader (Findings & Dossiers) ---------- */
.doc-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.doc-sidebar {
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 88px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.doc-sidebar-top {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-chrome);
}
.doc-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.doc-cat-hdr {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 8px 3px;
}
.doc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-body);
}
.doc-item:hover { background: var(--bg-elev); color: var(--text-hi); }
.doc-item.active {
  background: var(--cyan-bg);
  border-color: var(--cyan-bd);
  color: var(--cyan);
}
.doc-item .di-title { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.doc-item .di-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-article-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  min-width: 0;
}
.doc-article-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---------- Safe Markdown Typography ---------- */
.md-body {
  max-width: 900px;
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: break-word;
}
.md-body h1 {
  margin: 0 0 14px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.md-body h2 {
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 17.5px;
  color: var(--text-hi);
}
.md-body h3 { margin: 18px 0 8px; font-size: 15px; color: var(--text-hi); }
.md-body h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text-hi); }
.md-body p { margin: 0 0 12px; }
.md-body ul, .md-body ol { margin: 0 0 12px; padding-left: 22px; }
.md-body li { margin-bottom: 5px; }
.md-body blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--cyan);
  background: var(--bg-elev);
  border-radius: 0 6px 6px 0;
  color: var(--text-body);
}
.md-body blockquote p:last-child { margin-bottom: 0; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md-body code {
  font-size: 12.2px;
  padding: 1.5px 5px;
  border-radius: 4px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  color: var(--text-hi);
}
.md-body pre {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.48;
}
.md-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
}
.md-body .md-table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}
.md-body th, .md-body td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.md-body th {
  background: var(--bg-elev);
  color: var(--text-hi);
  font-weight: 600;
  white-space: nowrap;
}
.md-body tr:last-child td { border-bottom: 0; }
.md-body details {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  padding: 8px 12px;
}
.md-body summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-hi);
  user-select: none;
}
.md-body details[open] summary { margin-bottom: 10px; }

.md-body .md-quiet { color: var(--text-muted); font-size: 13.5px; margin: 8px 0 10px; }
.md-body details.verify-note { border-style: dashed; }
.md-body details.verify-note summary { color: var(--text-muted); font-weight: 500; }

.math-inline {
  font-family: var(--serif-math);
  font-style: italic;
  color: var(--text-hi);
  padding: 0 2px;
}
.math-block {
  font-family: var(--serif-math);
  font-style: italic;
  text-align: center;
  color: var(--text-hi);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0;
  overflow-x: auto;
}
/* TeX layout (fractions, stacked limits, accents, aligned rows). */
.math-display { display: block; text-align: center; font-style: italic; }
li .math-display, td .math-display, blockquote .math-display { margin: 8px 0; }
.math-inline .tx-rm, .math-inline .tx-op, .math-inline .tx-text, .math-inline .tx-tt,
.math-block .tx-rm, .math-block .tx-op, .math-block .tx-text, .math-block .tx-tt { font-style: normal; }
.math-inline .tx-tt, .math-block .tx-tt { font-family: var(--mono); font-size: .9em; }
.math-inline .tx-it, .math-block .tx-it { font-style: italic; }
.tx-frac { display: inline-flex; flex-direction: column; align-items: stretch; vertical-align: middle; text-align: center; margin: 0 .1em; line-height: 1.15; font-style: inherit; }
.tx-frac > .tx-num { border-bottom: 1px solid currentColor; padding: 0 .2em .08em; }
.tx-frac > .tx-den { padding: .08em .2em 0; }
.tx-frac.tx-nobar > .tx-num { border-bottom: 0; }
.tx-frac-t { font-size: .82em; }
.tx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.tx-ss { display: inline-grid; grid-template-rows: 1fr 1fr; vertical-align: middle; line-height: 1; font-size: .78em; margin-left: .05em; }
.tx-ss > sup, .tx-ss > sub { vertical-align: baseline; font-size: inherit; line-height: 1.05; position: static; }
.tx-v3 { display: inline-grid; grid-template-rows: 1fr auto 1fr; justify-items: center; vertical-align: middle; line-height: 1.1; }
.tx-v3 > .tx-v3-hi, .tx-v3 > .tx-v3-lo { font-size: .72em; white-space: nowrap; }
.tx-v3 > .tx-v3-hi { align-self: end; }
.tx-v3 > .tx-v3-lo { align-self: start; }
.tx-lim { margin: 0 .1em; }
.tx-lim-op, .tx-bigop { font-size: 1.35em; line-height: 1; font-style: normal; }
.tx-lim-op .tx-op { font-size: .74em; }
.tx-acc-mark { line-height: .6; font-style: normal; }
.tx-stack { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; line-height: 1.1; }
.tx-sqrt, .tx-ovl { border-top: 1px solid currentColor; padding-top: .06em; }
.tx-sqrt { margin-left: .04em; padding-left: .06em; }
.tx-unl { border-bottom: 1px solid currentColor; }
.tx-ub { border-bottom: 2px solid currentColor; border-radius: 0 0 6px 6px; padding: 0 .1em .1em; }
.tx-ob { border-top: 2px solid currentColor; border-radius: 6px 6px 0 0; padding: .1em .1em 0; }
.tx-root { font-size: .65em; margin-right: -.35em; }
.tx-d1 { font-size: 1.2em; } .tx-d2 { font-size: 1.5em; } .tx-d3 { font-size: 1.9em; }
.tx-d1, .tx-d2, .tx-d3, .tx-env-delim { font-style: normal; line-height: 1; vertical-align: middle; }
.tx-br { display: block; height: .3em; }
.tx-table { display: inline-table; vertical-align: middle; border-collapse: collapse; margin: 0 .15em; }
.tx-tr { display: table-row; }
.tx-td { display: table-cell; padding: .12em .3em; white-space: nowrap; text-align: center; }
.tx-td.tx-ar { text-align: right; padding-right: 0; }
.tx-td.tx-al { text-align: left; padding-left: 0; }
.tx-cases-t .tx-td.tx-al + .tx-td.tx-al { padding-left: 1.2em; }
.tx-env-delim.tx-rows1 { font-size: 1.3em; } .tx-env-delim.tx-rows2 { font-size: 2.2em; }
.tx-env-delim.tx-rows3 { font-size: 3em; } .tx-env-delim.tx-rows4 { font-size: 3.8em; }
.ev-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: baseline;
}
.ev-tag.K { color: var(--emerald); background: var(--emerald-bg); border: 1px solid var(--emerald-bd); }
.ev-tag.L { color: var(--cyan);    background: var(--cyan-bg);    border: 1px solid var(--cyan-bd); }
.ev-tag.S { color: var(--blue);    background: rgba(96, 165, 250, 0.12); border: 1px solid rgba(96, 165, 250, 0.35); }
.ev-tag.M { color: var(--amber);   background: var(--amber-bg);   border: 1px solid var(--amber-bd); }

/* ---------- Data Tables (Blueprints, Clusters, Islands, Benchmarks, Search) ---------- */
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar-row .grow { flex: 1; min-width: 180px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-panel);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.data-table th {
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text-hi); }
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--bg-elev); }
.data-table tbody tr.selected { background: var(--cyan-bg); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table code { overflow-wrap: anywhere; font-size: 11.8px; color: var(--text-hi); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Blueprints Split ---------- */
.bp-detail-split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.85fr);
  gap: 14px;
  align-items: start;
}
.bp-inspector {
  position: sticky;
  top: 68px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bp-header-box {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-hi);
  overflow-wrap: anywhere;
}

/* ---------- Clusters stacked bar ---------- */
.stacked-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-code);
  border: 1px solid var(--border);
  margin: 8px 0 14px;
}
.stacked-bar .seg-misplaced { background: var(--crimson); }
.stacked-bar .seg-drift     { background: var(--amber); }
.stacked-bar .seg-aligned   { background: var(--emerald); }

/* ---------- Portability Islands & Matrix ---------- */
.island-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.island-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 15px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.island-card:hover { border-color: var(--cyan-bd); background: var(--bg-elev); }
.island-card.active { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); background: var(--cyan-bg); }
.island-card .ic-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.island-card .ic-name { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text-hi); }
.island-card .ic-sub { font-size: 12px; color: var(--text-muted); }

.overlap-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
.overlap-table th, .overlap-table td { padding: 6px 8px; border: 1px solid var(--border); text-align: right; white-space: nowrap; }
.overlap-table th { background: var(--bg-elev); color: var(--text-muted); text-align: left; }
.overlap-table th.col-h { text-align: center; max-width: 120px; }
.overlap-table .col-h-txt, .overlap-table .row-h-txt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlap-table .col-h-txt { max-width: 120px; }
.overlap-table .row-h-txt { max-width: 220px; }
.overlap-table td.hm-0 { background: var(--bg-code); color: var(--text-dim); }
.overlap-table td.hm-lo { background: rgba(56, 189, 248, 0.14); color: var(--cyan); }
.overlap-table td.hm-mid { background: rgba(45, 212, 191, 0.18); color: var(--teal); }
.overlap-table td.hm-hi { background: rgba(52, 211, 153, 0.22); color: var(--emerald); font-weight: 700; }
.overlap-table td.hm-self { background: var(--bg-elev); color: var(--text-hi); font-weight: 700; }
.overlap-table .jacc { display: block; font-size: 9.5px; color: var(--text-muted); font-weight: 400; }

/* ---------- Search ---------- */
.search-hero {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.search-big-input {
  width: 100%;
  font-size: 15px;
  padding: 10px 14px;
  font-family: var(--mono);
}
.search-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.search-result-row:last-child { border-bottom: 0; }
.search-result-row:hover { background: var(--bg-elev); }
.sr-main { min-width: 0; flex: 1; }
.sr-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hi);
  overflow-wrap: anywhere;
}
.sr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.sr-acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* ---------- Edge map (contact matrix, library overlap, same-statement pairs) ---------- */
.atlas-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.atlas-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.atlas-card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.atlas-card-hd h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text-hi);
}
.atlas-canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  overflow: hidden;
}
.atlas-canvas {
  display: block;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 1 / 1;
  height: auto;
  image-rendering: pixelated;
  cursor: crosshair;
  border-radius: 4px;
}
.atlas-readout {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-body);
  line-height: 1.4;
}
.atlas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.atlas-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.atlas-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.atlas-toggle input { accent-color: var(--cyan); }

.hist-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.hist-bars {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  height: 92px;
  padding: 6px 2px 0;
  border-bottom: 1px solid var(--border);
}
.hist-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.hist-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: opacity 0.14s;
}
.hist-bar.alien   { background: var(--crimson); }
.hist-bar.variant { background: var(--amber); }
.hist-bar.clone   { background: var(--emerald); }
.hist-bar:hover { opacity: 0.78; }
.hist-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.twins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 12px;
}
.twin-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.twin-card-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.twin-sides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.twin-side {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.twin-side-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hi);
  overflow-wrap: anywhere;
}
.twin-side-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Editorial overrides for diagrams, documents, tables ---------- */
.circuit-shell { border-radius: 10px; background: var(--bg); }
.cir-toolbar, .cir-selector-bar { background: var(--bg); }
.cir-legend-bar { background: var(--bg); font-family: var(--sans); font-size: 12px; }
.cir-leg-pill { border: 0; background: transparent; padding: 0 4px; }
.cir-chip { font-size: 11.5px; background: transparent; }
.cir-chip.active { background: var(--bg-elev); border-color: var(--border-hi); color: var(--text-hi); }
.cir-chip.active .chip-tag { color: var(--text-muted); }
.cir-crumb.cur { border-color: var(--border-hi); color: var(--text-hi); background: var(--bg-elev); }
.cir-crumb:hover { border-color: var(--border-hi); }
.cir-inspector { background: var(--bg); gap: 12px; padding: 16px 18px; }
.cir-ins-hd { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; }
.cir-ins-mode { font-weight: 450; color: var(--text-dim); }
.cir-ins-title { font-size: 13.5px; }
.cir-ins-kv { grid-template-columns: 112px minmax(0, 1fr); gap: 6px 10px; }
.cir-ins-kv .k { font-family: var(--sans); font-size: 12px; }
.cir-ins-kv .v { font-size: 12px; }
.circuit-tip { border-color: var(--border-hi); font-family: var(--sans); font-size: 12px; }

.doc-layout { grid-template-columns: 280px minmax(0, 1fr); gap: 40px; }
.doc-sidebar { background: transparent; border: 0; border-right: 1px solid var(--border); border-radius: 0; top: 76px; max-height: calc(100vh - 100px); }
.doc-sidebar-top { background: transparent; border-bottom: 0; padding: 0 16px 10px 0; }
.doc-sidebar-title { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--text-hi); }
.doc-list { padding: 0 12px 12px 0; gap: 1px; }
.doc-cat-hdr { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--text-dim); padding: 14px 10px 4px; }
.doc-item { border: 0; border-left: 2px solid transparent; border-radius: 0 6px 6px 0; padding: 7px 10px; }
.doc-item .di-title { font-weight: 450; font-size: 13px; }
.doc-item.active { background: var(--bg-elev); border-left-color: var(--accent); color: var(--text-hi); }
.doc-item.active .di-title { font-weight: 600; }
.doc-item .di-meta { font-family: var(--sans); font-size: 11.5px; }
.doc-article-wrap { background: transparent; border: 0; padding: 0 0 24px; }
.doc-article-meta { border-bottom: 0; padding: 0; margin: 0 0 8px; font-family: var(--sans); font-size: 12.5px; color: var(--text-dim); }

.md-body { max-width: 74ch; font-size: 15.5px; line-height: 1.72; }
.md-body h1 { font-family: var(--serif); font-size: 32px; font-weight: 600; margin: 0 0 20px; }
.md-body h2 { font-family: var(--serif); font-size: 23px; font-weight: 600; margin: 40px 0 12px; padding-bottom: 0; border-bottom: 0; }
.md-body h3 { font-size: 16.5px; margin: 28px 0 8px; }
.md-body h4 { font-size: 14.5px; }
.md-body p { margin: 0 0 16px; }
.md-body li { margin-bottom: 6px; }
.md-body blockquote { border-left: 2px solid var(--border-hi); background: transparent; color: var(--text-muted); padding: 2px 16px; }
.md-body code { font-size: 0.86em; padding: 1px 5px; background: var(--bg-elev); border: 0; }
.md-body pre { background: var(--bg-code); }
.md-body .md-table-wrap { max-width: 100%; }
.md-body table { font-size: 13.5px; }
.md-body th { background: transparent; border-bottom: 1px solid var(--border-hi); }
.md-body details { background: transparent; }
.math-block { background: transparent; border: 0; border-left: 2px solid var(--border); border-radius: 0; }
.ev-tag { font-size: 10.5px; font-weight: 600; padding: 0 4px; }
.ev-tag.K, .ev-tag.L, .ev-tag.S, .ev-tag.M { background: transparent; }

.toolbar-row { margin-bottom: 16px; gap: 10px; }
.table-wrap { background: transparent; border-radius: 8px; }
.data-table { font-size: 13px; }
.data-table th { background: transparent; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-hi); }
.data-table th, .data-table td { padding: 10px 12px; }
.data-table tbody tr.selected { background: var(--bg-elev); box-shadow: inset 2px 0 0 var(--accent); }
.data-table tbody tr:hover { background: var(--bg-elev); }

.bp-head { margin: 0 0 18px; }
.bp-head h2 { margin: 0 0 4px; font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--text-hi); letter-spacing: -0.01em; }
.bp-head-meta { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.bp-anchor { font-size: 11.5px; margin-top: 3px; }
.bp-inspector { background: transparent; top: 76px; }
.bp-header-box { background: var(--bg-code); }

.stacked-bar { height: 6px; border: 0; margin: 4px 0 22px; opacity: 0.85; }
.island-card { background: transparent; padding: 16px 18px; }
.island-card.active { box-shadow: none; background: var(--bg-elev); border-color: var(--border-hi); }
.island-card .ic-members { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.overlap-table th { background: transparent; }
.overlap-table td.hm-lo { background: var(--accent-bg); color: var(--text-body); }
.overlap-table td.hm-mid { background: rgba(124, 196, 228, 0.18); color: var(--text-hi); }
.overlap-table td.hm-hi { background: rgba(124, 196, 228, 0.28); color: var(--text-hi); }

.search-hero { background: transparent; border: 0; padding: 0; margin-bottom: 24px; max-width: 900px; }
.search-hero h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 32px; font-weight: 600; color: var(--text-hi); }
.search-hero .page-lede { margin-bottom: 18px; font-size: 15px; color: var(--text-muted); }
.search-big-input { font-family: var(--sans); font-size: 16px; padding: 12px 16px; border-radius: 9px; }
.search-results { border-radius: 9px; }
.search-result-row { padding: 12px 16px; }
.sr-meta { font-family: var(--sans); font-size: 12px; gap: 12px; }
.sr-type { color: var(--text-body); font-weight: 500; }
.sr-acts { align-items: center; }

.atlas-card { background: transparent; padding: 18px 20px; gap: 12px; }
.atlas-card-hd h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.atlas-explain { margin: -2px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--text-muted); max-width: 70ch; }
.atlas-legend { font-family: var(--sans); font-size: 12px; gap: 12px; }
.atlas-readout { font-family: var(--sans); font-size: 12.5px; background: transparent; }
.atlas-toggles { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hist-wrap { background: transparent; padding: 16px 18px; }
.hist-title { font-size: 14px; font-weight: 600; color: var(--text-hi); }
.hist-axis { font-family: var(--sans); font-size: 11.5px; }
.hist-bar { opacity: 0.8; }
.twins-grid { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; }
.twin-card { background: transparent; padding: 16px 18px; gap: 12px; }
.twin-card-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-muted); }
.twin-j { color: var(--text-hi); font-weight: 600; font-variant-numeric: tabular-nums; }
.twin-side { background: transparent; }
.twin-side-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.twin-side-tag { font-size: 12px; font-weight: 600; color: var(--text-body); }
.twin-side-meta { font-family: var(--sans); font-size: 11.5px; overflow-wrap: anywhere; min-width: 0; }
.twin-side-name { overflow-wrap: anywhere; }
.doc-list { overflow-x: hidden; }
.doc-item { min-width: 0; overflow-wrap: anywhere; }
.twin-card-ft { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.twin-card-ft .twin-side-meta { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }

/* ---------- v2.3 atlas: proof similarity index, matrices, map ---------- */
.psi-section { min-width: 0; }
.psi-hist .psi-hist-hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.psi-hist-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.psi-hist h3.hist-title { margin: 0; }
.psi-pool { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.psi-legend { margin-bottom: 4px; }
.psi-scale button { padding: 3px 10px; font-size: 12px; }
button.hist-bar-col { border: 0; background: transparent; padding: 0; margin: 0; cursor: pointer; border-radius: 3px 3px 0 0; min-width: 0; font: inherit; color: inherit; }
button.hist-bar-col:hover .hist-bar { opacity: 1; filter: brightness(1.15); }
button.hist-bar-col:focus-visible { outline: 2px solid var(--accent, var(--cyan)); outline-offset: 1px; }
.hist-bar-col.dim .hist-bar { opacity: 0.22; }
.hist-bar-col.sel .hist-bar { opacity: 1; box-shadow: 0 0 0 2px var(--text-hi); }
.psi-toolbar { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.psi-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.psi-filter { flex: 1 1 260px; min-width: 0; max-width: 460px; }
.psi-sort { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.psi-dir { min-width: 74px; font-variant-numeric: tabular-nums; }
.psi-lbl { font-size: 12px; color: var(--text-muted); }
.psi-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; margin-right: 8px; }
.psi-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.psi-chip { border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 999px; padding: 3px 11px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.psi-chip:hover { color: var(--text-hi); border-color: var(--border-hi); }
.psi-chip.active { color: var(--text-hi); background: var(--bg-elev); border-color: var(--border-hi); font-weight: 600; }
.psi-chip:focus-visible, .psi-dir:focus-visible { outline: 2px solid var(--accent, var(--cyan)); outline-offset: 1px; }
.psi-count { margin: 2px 0 10px; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.psi-empty { padding: 18px; }
.psi-name-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.psi-wrap-pill { display: inline-block; font-size: 10.5px; line-height: 1.5; padding: 0 7px; border: 1px solid var(--border-hi); border-radius: 999px; color: var(--text-muted); white-space: nowrap; font-family: var(--mono); }
.psi-band { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text-body); }
.psi-band::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.psi-band.alien::before { background: var(--crimson); }
.psi-band.variant::before { background: var(--amber); }
.psi-band.clone::before { background: var(--emerald); }
.atlas-readout.locked { color: var(--text-hi); border-left: 2px solid var(--cyan); padding-left: 8px; }
.map-zoom-hint { position: absolute; right: 10px; bottom: 10px; z-index: 3; pointer-events: none; padding: 5px 10px; border-radius: 6px; font-size: 12px; background: var(--bg-elev); color: var(--text-hi); border: 1px solid var(--border-hi); opacity: 0; transform: translateY(4px); transition: opacity 0.18s, transform 0.18s; }
.map-zoom-hint.on { opacity: 0.95; transform: none; }
@media (max-width: 720px) {
  .twins-grid { grid-template-columns: minmax(0, 1fr); }
  .psi-filter { flex-basis: 100%; max-width: none; }
}
@media (max-width: 520px) {
  .psi-section .twin-sides { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- v2.4 atlas and map ---------- */
.syn-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.syn-subtitle { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.psi-scope-note { margin: 2px 0 6px; font-size: 12.5px; }
.psi-hash { overflow-wrap: break-word; }
.psi-section .twin-side-name { word-break: normal; overflow-wrap: break-word; }

/* ---------- Inline source preview buttons ---------- */
.src-link { display: inline-flex; align-items: baseline; gap: 4px; max-width: 100%; flex-wrap: wrap; }
.src-peek-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding: 0 5px;
  height: 17px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
  vertical-align: 1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.src-peek-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.src-link .src-peek-btn { margin-left: 2px; }

/* ---------- Live Lean source drawer ---------- */
.src-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(6, 8, 11, 0.45);
  animation: srcFade 0.18s ease-out;
}
html[data-theme="light"] .src-backdrop { background: rgba(23, 25, 28, 0.22); }
.src-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 85;
  width: min(820px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(24px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease, width 0.22s ease;
}
.src-drawer.open { transform: translateX(0); opacity: 1; }
.src-drawer.compare { width: min(1440px, 98vw); }
@keyframes srcFade { from { opacity: 0; } to { opacity: 1; } }
.src-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.src-hd-main { min-width: 0; }
.src-title {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-hi);
  overflow-wrap: anywhere;
}
.src-path {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.src-close { flex-shrink: 0; font-size: 18px; }
.src-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.src-toolbar .spacer { flex: 1; }
.src-status { font-size: 12px; color: var(--text-muted); min-height: 1em; }
.src-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.src-drawer.compare .src-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.src-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.src-drawer.compare .src-pane + .src-pane { border-left: 1px solid var(--border); }
.src-pane-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.src-pane-id { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.src-pane-tag { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.src-pane-title { font-family: var(--mono); font-size: 12px; color: var(--text-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-pane-acts { display: flex; gap: 6px; flex-shrink: 0; }
.src-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg-code);
}
.src-code {
  position: relative;
  padding: 10px 0 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  min-width: max-content;
}
.src-line { display: flex; align-items: flex-start; border-left: 2px solid transparent; }
.src-line.hl { background: var(--src-hl); border-left-color: var(--accent); }
.src-ln {
  flex: 0 0 auto;
  width: 4.2em;
  padding: 0 12px 0 6px;
  text-align: right;
  color: var(--text-dim);
  user-select: none;
  font-variant-numeric: tabular-nums;
}
.src-ln:hover { color: var(--accent); text-decoration: none; }
.src-line.hl .src-ln { color: var(--accent); }
.src-text { white-space: pre; padding-right: 20px; color: var(--text-body); tab-size: 2; }
.src-more {
  display: block;
  margin: 2px 0 6px 4.2em;
  padding: 2px 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}
.src-more:hover { color: var(--accent); }
.src-loading, .src-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--sans);
}
.src-loading { flex-direction: row; }
.src-error h4 { margin: 0; font-size: 15px; color: var(--text-hi); font-weight: 600; }
.src-error p { margin: 0 0 6px; max-width: 44ch; font-size: 13.5px; }
.src-foot.hidden { display: none; }
.src-foot {
  padding: 9px 20px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
}
.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-tac { color: var(--tok-tac); }
.tok-name { color: var(--tok-name); font-weight: 600; }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-attr { color: var(--tok-attr); }
.tok-punct { color: var(--tok-punct); }
.tok-sorry { color: var(--tok-sorry); font-weight: 700; text-decoration: underline wavy; text-underline-offset: 3px; }


/* ---------- Project switcher ---------- */
.brand-wrap { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; position: relative; }
.proj-switch { position: relative; }
.proj-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11.5px; color: var(--text-body);
  padding: 2px 8px 2px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; cursor: pointer; max-width: 230px;
}
.proj-btn:hover, .proj-btn[aria-expanded="true"] { border-color: var(--border-hi); color: var(--text-hi); }
.proj-btn-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-caret { font-size: 9px; color: var(--text-muted); }
.proj-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 300px; max-height: 70vh; overflow: auto;
  padding: 6px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); box-shadow: var(--shadow);
}
.proj-item { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 7px; color: var(--text-body); text-decoration: none; }
.proj-item:hover, .proj-item:focus-visible { background: var(--bg-elev); text-decoration: none; outline: none; }
.proj-item.active { background: var(--bg-elev); box-shadow: inset 2px 0 0 var(--accent); }
.proj-item-slug { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); }
.proj-item-title { font-size: 12px; color: var(--text-muted); }
.proj-item.all { font-size: 13px; color: var(--text-hi); }
.proj-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Projects home ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.proj-card { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 10px; }
.proj-card.current { border-color: var(--border-hi); background: var(--bg-elev); }
.proj-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.proj-card h3 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--text-hi); line-height: 1.3; }
.proj-card-slug { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.proj-card-tag { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-body); }
.proj-card-facts { margin: 0; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.proj-card .cir-ins-acts { margin-top: auto; padding-top: 4px; }
.add-proof { margin: 44px 0 0; max-width: 80ch; border-top: 1px solid var(--border); padding-top: 16px; }
.add-proof summary { cursor: pointer; font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--text-hi); }
.add-proof p { font-size: 14px; color: var(--text-body); max-width: 72ch; }
.add-proof pre { background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }

/* ---------- Body layout: outline rail + content ---------- */
.body-wrap { display: flex; align-items: stretch; flex: 1; min-height: 0; width: 100%; }
.content-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.outline-rail {
  position: sticky; top: 57px; align-self: flex-start;
  width: 264px; flex: 0 0 264px; height: calc(100vh - 57px);
  overflow-y: auto; border-right: 1px solid var(--border);
  padding: 14px 10px 24px 14px; background: var(--bg);
}
body:not(.rail-on) .outline-rail { display: none; }
.rail-toggle { width: 32px; flex-shrink: 0; }
.rail-hd { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.rail-modes { display: flex; gap: 2px; flex-wrap: wrap; }
.rail-modes button {
  border: 0; background: transparent; color: var(--text-muted); font-size: 12.5px; padding: 4px 8px; border-radius: 6px; cursor: pointer;
}
.rail-modes button:hover { color: var(--text-hi); background: var(--bg-elev); }
.rail-modes button.active { color: var(--text-hi); background: var(--bg-elev); font-weight: 600; }
.rail-close { display: none; border: 0; background: transparent; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.rail-list { display: flex; flex-direction: column; gap: 1px; }
.rail-note { font-size: 12px; line-height: 1.5; color: var(--text-dim); padding: 2px 8px 10px; }
.rail-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  width: 100%; padding: 5px 8px 5px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-body); font-size: 13px; text-align: left; cursor: pointer; text-decoration: none;
  border-left: 2px solid transparent;
}
.rail-row:hover { background: var(--bg-elev); color: var(--text-hi); text-decoration: none; }
.rail-row.active { background: var(--bg-elev); color: var(--text-hi); border-left-color: var(--accent); font-weight: 600; }
.rail-row.flag .rail-lbl::after { content: " ≠"; color: var(--amber); }
.rail-row.folder .rail-lbl { font-family: var(--mono); font-size: 12px; }
.rail-row.folder::before { content: "▸"; color: var(--text-dim); font-size: 10px; margin-right: -2px; }
.rail-row.folder.open::before { content: "▾"; }
.rail-row.muted { color: var(--text-muted); font-size: 12px; }
.rail-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.rail-cnt { flex-shrink: 0; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- Breadcrumbs ---------- */
.crumb-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  width: 100%; max-width: 1360px; margin: 0 auto; padding: 14px 24px 0;
  font-size: 13px; color: var(--text-muted);
}
.crumb { color: var(--text-muted); }
.crumb:hover { color: var(--text-hi); }
.crumb.cur { color: var(--text-hi); max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-sep { color: var(--text-dim); }
.crumb-bar:not(.hidden) + .app-main { padding-top: 22px; }
.crumb-bar:not(.hidden) + .app-main.full-bleed { padding-top: 10px; }
.circuit-shell { height: calc(100vh - 150px); }

/* ---------- In-page navigation affordance ---------- */
a.dom-row { color: inherit; text-decoration: none; }
a.dom-row:hover { text-decoration: none; }
.dom-row { grid-template-columns: minmax(150px, 1.4fr) minmax(100px, 1fr) 100px 12px; }
.nav-glyph { color: var(--text-dim); text-align: right; }
.dom-row.clickable:hover .nav-glyph, .finding-card:hover .nav-glyph { color: var(--accent); }
a.btn { text-decoration: none; }

/* ---------- Overview lens ---------- */
.lens-hd { align-items: center; }
.lens-body { min-height: 120px; }
.lens-box { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-code); overflow: auto; max-height: 560px; margin-bottom: 12px; }
.lens-box svg { display: block; width: 100%; height: auto; }
.lens-box .loading-card { border: 0; }
.lens-box.lens-map { background: transparent; border: 0; max-height: none; overflow: visible; }
.lens-canvas { display: block; margin: 10px auto; max-width: 100%; }

/* ---------- Cell trays (edge map, module matrix) ---------- */
.cell-tray { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.tray-hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tray-hd strong { color: var(--text-hi); font-size: 14px; font-weight: 600; display: block; }
.tray-sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tray-hd .icon-btn { width: 26px; height: 26px; font-size: 15px; }
.cell-tray h4 { margin: 8px 0 2px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.tray-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tray-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tray-row:last-child { border-bottom: 0; }
.tray-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 180px; }
.tray-name { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); overflow-wrap: anywhere; }
.tray-arrow { color: var(--text-dim); }
.tray-meta { font-size: 11.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.tray-list { display: flex; flex-direction: column; }
.atlas-canvas { cursor: pointer; }

/* ---------- 2D map ---------- */
.map2d-section { margin-bottom: 8px; }
.map2d-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.map2d-grid.compact { grid-template-columns: minmax(0, 1.4fr) minmax(200px, 1fr); }
.map2d-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.map2d-wrap { padding: 0; background: var(--bg-code); }
.map2d-canvas { display: block; width: 100%; height: auto; aspect-ratio: 760 / 560; }
.map2d-detail { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.map-sub { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 6px; }
.map2d-detail .cir-ins-note, .map2d-detail .cir-ins-title { overflow-wrap: anywhere; }
.tray-row .btn.sm { padding: 2px 8px; font-size: 11.5px; }
.map-terms { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--text-body); overflow-wrap: anywhere; line-height: 1.6; }
.map-nn { display: flex; flex-wrap: wrap; gap: 6px; }
.map-nn-btn { border: 1px solid var(--border); background: transparent; color: var(--text-body); border-radius: 999px; padding: 2px 9px; font-family: var(--mono); font-size: 11.5px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-nn-btn:hover { border-color: var(--border-hi); color: var(--text-hi); }

/* ---------- Declaration inspector (#item) ---------- */
.item-head { margin: 0 0 22px; max-width: 90ch; }
.item-title { margin: 0 0 6px; font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--text-hi); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.item-full { font-family: var(--mono); font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.item-meta { margin: 10px 0 0; font-size: 14px; color: var(--text-body); }
.nb-strip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr) minmax(0, 1fr); gap: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 0 22px; }
.nb-col { padding: 14px 18px 14px 0; min-width: 0; }
.nb-col + .nb-col { padding-left: 18px; border-left: 1px solid var(--border); }
.nb-self { background: var(--bg-elev); }
.nb-hd { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.nb-self-name { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--text-hi); overflow-wrap: anywhere; }
.nb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nb-list li { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 12.5px; min-width: 0; }
.nb-list a { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nb-rel { font-size: 11px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.nb-more { color: var(--text-dim); }
.nb-empty { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.item-tabs .spacer { flex: 1; }
.item-body { min-height: 160px; }
.item-kv { grid-template-columns: 140px minmax(0, 1fr); max-width: 760px; margin-bottom: 16px; }
.item-docs { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.item-docs li { margin-bottom: 4px; }
.item-docs .nb-rel { margin-left: 8px; }
.item-diagram { max-height: 640px; }
.item-source { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.src-toolbar.docked { border-bottom: 1px solid var(--border); }
.src-scroll.docked { max-height: 620px; min-height: 160px; }
.src-sym { color: inherit; text-decoration: underline; text-decoration-color: var(--border-hi); text-underline-offset: 3px; }
.src-sym:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---------- Source drill-down: links, peek, trail, "Used in" tray ---------- */
/* Long module paths in the item header wrap instead of widening the page. */
.item-head .item-meta, .item-head .item-full { overflow-wrap: anywhere; }
/* In-project and same-file names: a quiet accent underline (solid / dashed).
   Mathlib and Lean core: no underline until hovered, then a faint dotted one. */
.src-sym.o-project, .src-sym.o-module { text-decoration-style: solid; text-decoration-color: var(--cyan-bd); text-decoration-thickness: 1px; }
.src-sym.o-local, .src-sym.src-def { text-decoration-style: dashed; text-decoration-color: var(--cyan-bd); text-decoration-thickness: 1px; }
.src-sym.o-mathlib, .src-sym.o-core { text-decoration-style: dotted; text-decoration-color: transparent; }
.src-sym.o-mathlib:hover, .src-sym.o-core:hover { color: inherit; text-decoration-color: var(--text-dim); }
.src-sym.src-import { text-decoration-style: solid; text-decoration-color: var(--accent); text-decoration-thickness: 1px; }
.src-sym.src-import.o-mathlib, .src-sym.src-import.o-core { text-decoration-color: var(--border-hi); }
.src-sym:focus-visible, .src-try:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }
.src-sym.src-hit { background: var(--accent-bg); border-radius: 3px; box-shadow: 0 0 0 1px var(--cyan-bd); }
.src-try { cursor: pointer; }
.src-try:hover { text-decoration: underline dotted var(--border-hi); text-underline-offset: 3px; }
.src-try.busy { cursor: progress; opacity: 0.65; }
.src-try.src-untracked:hover { text-decoration: none; cursor: default; }
.src-line.flash { animation: srcFlash 1.6s ease-out; }
@keyframes srcFlash { 0%, 35% { background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); } 100% { background: transparent; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .src-line.flash { animation: none; background: var(--accent-bg); } }

.src-mode-wrap { display: inline-flex; align-items: center; gap: 6px; }
.src-mode-lbl { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.src-trail {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--bg-elev); font-size: 12.5px;
}
.src-trail .st-back { flex-shrink: 0; padding: 2px 9px; }
.st-path { display: flex; align-items: center; gap: 6px; min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.st-path::-webkit-scrollbar { display: none; }
.st-crumb { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.st-crumb:hover { color: var(--accent); }
.st-sep { color: var(--text-dim); }
.st-cur { font-family: var(--mono); font-size: 12px; color: var(--text-hi); font-weight: 600; }

.src-peek-inline {
  position: sticky; left: 0; margin: 4px 0 8px 8px; max-width: calc(100vw - 32px);
  border: 1px solid var(--border-hi); border-left: 2px solid var(--accent); border-radius: 8px;
  background: var(--bg-panel); color: var(--text-body); font-family: var(--sans); font-size: 12.5px; line-height: 1.45;
  white-space: normal; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); overflow: hidden;
}
.src-peek-inline:not(.in-code) { margin: 0; max-width: none; border-radius: 0; border-left-width: 2px; border-right: 0; box-shadow: none; }
.src-peek-inline.o-mathlib, .src-peek-inline.o-core { border-left-color: var(--border-hi); }
.spk-hd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--border); }
.spk-name { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); min-width: 0; overflow-wrap: anywhere; }
.spk-name .q-pre, .su-name .q-pre { color: var(--text-dim); font-weight: 400; }
.spk-name strong, .su-name strong { font-weight: 600; }
.spk-meta { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; min-width: 0; }
.spk-close { margin-left: auto; width: 26px; height: 26px; font-size: 15px; flex-shrink: 0; }
.pill.o-mathlib, .pill.o-core { color: var(--text-muted); }
.pill.o-project, .pill.o-local, .pill.o-module { color: var(--accent); border-color: var(--cyan-bd); }
.spk-body { max-height: 320px; overflow: auto; background: var(--bg-code); }
.spk-body .src-code { padding: 6px 0 8px; font-size: 12px; }
.spk-loading { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--text-muted); }
.spk-loading .spinner { width: 16px; height: 16px; }
.spk-note { margin: 0; padding: 10px 12px; color: var(--text-muted); font-size: 12.5px; }
.spk-more { padding: 0 12px 8px 4.2em; color: var(--text-dim); font-size: 12px; }
.spk-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 12px; border-top: 1px solid var(--border); }

.src-used-host { border-bottom: 1px solid var(--border); }
.src-used-toggle {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; width: 100%;
  padding: 7px 14px; border: 0; background: transparent; color: var(--text-body);
  font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.src-used-toggle:hover { background: var(--bg-hover); }
.su-caret { display: inline-block; width: 0.8em; color: var(--text-dim); transition: transform 0.15s ease; }
.src-used-toggle[aria-expanded="true"] .su-caret { transform: rotate(90deg); }
.su-title { font-weight: 600; color: var(--text-hi); }
.su-counts { color: var(--text-muted); font-size: 12px; min-width: 0; }
.su-panel { padding: 2px 14px 12px; }
.su-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 8px; }
.su-filters .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.su-filters .seg button { padding: 4px 9px; font-size: 12px; }
.su-q { flex: 1 1 150px; min-width: 0; max-width: 260px; padding: 4px 9px; font-size: 12.5px; }
.su-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); }
.su-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.su-row:last-child { border-bottom: 0; }
.su-name { flex: 1 1 220px; min-width: 0; font-family: var(--mono); font-size: 12px; color: var(--text-hi); overflow-wrap: anywhere; }
.su-tags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; }
.su-rp.r1 { color: var(--blue); }
.su-rp.r2 { color: var(--emerald); }
.su-rp.r3 { color: var(--amber); }
.su-used { white-space: nowrap; }
.su-hidden { font-style: italic; color: var(--text-dim); white-space: nowrap; }
.su-acts { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.su-acts .btn.sm { padding: 2px 8px; font-size: 11.5px; }
.su-more { margin-left: 0; }
.su-note, .su-foot { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }
.su-empty { padding: 10px 12px; color: var(--text-dim); font-size: 12.5px; }
@media (max-width: 720px) {
  .src-trail { padding: 6px 10px; }
  .src-used-toggle, .su-panel { padding-left: 10px; padding-right: 10px; }
  .su-name { flex-basis: 100%; }
  .su-acts { margin-left: 0; }
  .su-q { max-width: none; }
}

/* ---------- Experiments ---------- */
.exp-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.exp-cols h4 { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); font-weight: 600; }
.exp-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; max-width: 80ch; }
.exp-list li { margin-bottom: 6px; }

@media (max-width: 1060px) {
  .map2d-grid, .map2d-grid.compact, .tray-cols, .exp-cols { grid-template-columns: minmax(0, 1fr); }
  .nb-strip { grid-template-columns: minmax(0, 1fr); }
  .nb-col + .nb-col { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; }
}

@media (max-width: 900px) {
  body:not(.rail-on) .outline-rail { display: block; }
  .outline-rail {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 75; height: 100vh;
    transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: none;
  }
  body.rail-mobile-open .outline-rail { transform: none; box-shadow: var(--shadow); }
  .rail-close { display: inline-block; }
}


/* ---------- v2.1 polish ---------- */
.dom-name .sub-note a.inline-diagram { color: var(--accent); }
.dom-row.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hero-scope { margin: 14px 0 0; max-width: 72ch; font-size: 14px; line-height: 1.6; color: var(--text-body); border-left: 2px solid var(--border-hi); padding-left: 12px; }
.btn.quiet { border-color: transparent; color: var(--text-muted); }
.btn.quiet:hover { color: var(--text-hi); border-color: var(--border); }
.item-axioms { margin: 8px 0 0; font-size: 12.5px; color: var(--text-muted); }
.proj-card-top { flex-direction: column; align-items: flex-start; gap: 2px; }
.proj-card-license { margin: 0; }
.license-badge { display: inline-block; font-size: 11.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
body.route-projects .outline-rail, body.route-projects #railToggleBtn { display: none !important; }
body.route-projects .fm-proof { display: none; }
.atlas-axis { margin: -2px 0 0; font-size: 12px; color: var(--text-muted); }
.island-card .ic-top { flex-wrap: wrap; min-width: 0; }
.island-card .ic-name { min-width: 0; overflow-wrap: anywhere; }
.island-card { min-width: 0; }
.rail-row.group .rail-lbl { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.rail-row.folder.group::before { content: "▸"; }
.rail-row.folder.group.open::before { content: "▾"; }

/* 2D map toolbar, tooltip and legend */
.map-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.map-tools .spacer { flex: 1; }
.map-tools .seg button { padding: 3px 9px; font-size: 12px; }
.map-zoom { font-size: 12px; color: var(--text-muted); min-width: 3.4em; text-align: center; font-variant-numeric: tabular-nums; }
.map-find { width: 190px; padding: 4px 9px; font-size: 12.5px; }
.map-find-status { font-size: 12px; color: var(--text-muted); }
.map2d-wrap { position: relative; }
.map2d-canvas { touch-action: none; }
.map-tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 240px;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border-hi);
  background: var(--bg); box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; color: var(--text-body);
}
.map-tip-name { font-family: var(--mono); font-weight: 600; color: var(--text-hi); overflow-wrap: anywhere; margin-bottom: 2px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.map-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text-body); font-size: 12px; cursor: pointer;
}
.map-pill:hover { border-color: var(--border-hi); color: var(--text-hi); }
.map-pill.off { opacity: 0.45; text-decoration: line-through; }
.map-pill .atlas-swatch { margin-right: 0; }
.map-legend-note { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }

/* Overflow safety at narrow widths */
.content-col, .app-main, .doc-layout > *, .overview-grid > *, .atlas-grid > *, .bp-detail-split > *, .map2d-grid > *, .twin-card, .twin-side { min-width: 0; }
.md-body code, .cir-ins-note, .data-table td { overflow-wrap: anywhere; }
.md-body pre { max-width: 100%; }
.md-body .md-table-wrap, .table-wrap {
  overflow-x: auto; max-width: 100%;
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.22), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.22), transparent) right / 10px 100% no-repeat scroll;
}
@media (max-width: 720px) {
  .map-find { width: 100%; }
  .map-tools .spacer { display: none; }
  .hero h1 { overflow-wrap: anywhere; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-title { font-size: 21px; }
  .search-big-input { min-width: 0; }
  .twins-grid { grid-template-columns: minmax(0, 1fr); }
  .tray-cols { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions { flex-wrap: wrap; }
  .crumb.cur { max-width: 60vw; }
}


/* ---------- v2.2: full screen, touch, color-by, trust badges, comparison ---------- */
.fs-on {
  position: fixed !important; inset: 0; z-index: 900; width: 100vw; height: 100vh; max-width: none !important; max-height: none !important;
  margin: 0 !important; padding: 14px 18px !important; border-radius: 0 !important; border: 0 !important;
  background: var(--bg) !important; overflow: auto; box-sizing: border-box;
}
body.fs-lock { overflow: hidden; }
.fs-btn { white-space: nowrap; }
.atlas-card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.atlas-card.fs-on { display: flex; flex-direction: column; }
.atlas-card.fs-on .atlas-canvas-wrap { flex: 1 0 auto; }
.atlas-card.fs-on .atlas-canvas { max-width: none; width: min(100%, calc(100vh - 230px)); height: auto; }
.map-host.fs-on { display: flex; flex-direction: column; gap: 8px; }
.map-host.fs-on > .section-lede { display: none; }
.fs-on .map2d-grid { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 320px; align-items: stretch; }
.fs-on .map2d-main { min-height: 0; display: flex; flex-direction: column; }
.fs-on .map2d-wrap { flex: 1; min-height: 0; }
.fs-on .map2d-canvas { width: 100%; height: 100%; aspect-ratio: auto; }
.fs-on .map2d-detail { overflow: auto; max-height: 100%; }
.fs-on.details-collapsed .map2d-grid { grid-template-columns: minmax(0, 1fr); }
.fs-on.details-collapsed .map2d-detail { display: none; }
.map-details-toggle { display: none; }
.fs-on .map-details-toggle { display: inline-flex; }
.lens-box.fs-on { max-height: none; }
.circuit-shell.fs-on { height: 100vh !important; padding: 0 !important; display: flex; flex-direction: column; }
.cir-stage-wrap { touch-action: none; }
.cir-legend-bar .spacer { flex: 1; }

.map-color-lbl { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.map-color { padding: 4px 8px; font-size: 12.5px; }
.map-focus { display: flex; flex-wrap: wrap; gap: 6px; }
.map-chip { border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.map-chip:hover { color: var(--text-hi); border-color: var(--border-hi); }
.map-chip.active { color: var(--text-hi); background: var(--bg-elev); border-color: var(--border-hi); font-weight: 600; }
.map-colorbar-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-colorbar { display: inline-block; width: 180px; height: 10px; border-radius: 5px; border: 1px solid var(--border); }

.trust-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; line-height: 1.6;
  padding: 0 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; vertical-align: middle;
}
.trust-badge.tool::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
.trust-badge.notes { color: var(--amber); border-color: var(--amber-bd); }
.trust-badge.notes::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.page-head .trust-badge, .search-hero .trust-badge, .bp-head .trust-badge { margin: 0 0 10px; }
.trust-line { margin: 14px 0 0; font-size: 12.5px; color: var(--text-muted); max-width: 72ch; }
.doc-article-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cmp-section { margin-top: 12px; }
.cmp-table td a { font-weight: 600; }
.cmp-table td:first-child { white-space: nowrap; }
.section-hdr .trust-badge { align-self: center; }
@media (max-width: 720px) {
  .fs-on .map2d-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .fs-on .map2d-detail { max-height: 35vh; }
  /* Phones: the controls stack tall, so the full-screen map keeps a usable
     height and the overlay scrolls instead of squeezing the canvas. */
  .map-host.fs-on .map2d-grid { flex: none; grid-template-rows: auto auto; }
  .map-host.fs-on .map2d-main { display: block; }
  .map-host.fs-on .map2d-wrap { flex: none; height: max(320px, 62vh); }
  .map-colorbar { width: 120px; }
}

/* ---------- v2.3 tables, filters, documents ---------- */
.data-table th.sortable { white-space: nowrap; }
.data-table th.sortable .sort-ind { display: inline-block; margin-left: 4px; min-width: 0.8em; font-size: 10px; opacity: 0.35; transition: opacity 0.12s ease; }
.data-table th.sortable:hover .sort-ind { opacity: 0.75; }
.data-table th.sortable.sorted { color: var(--text-hi); }
.data-table th.sortable.sorted .sort-ind { opacity: 1; color: var(--accent); }
.data-table th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.data-table tbody tr[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.btn.filter-clear[hidden], .doc-filter-meta[hidden] { display: none; }
.doc-filter-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); }
.doc-filter-count { min-width: 0; overflow-wrap: anywhere; }
.doc-list-empty { padding: 12px; }
.md-body h1[id], .md-body h2[id], .md-body h3[id], .md-body h4[id] { scroll-margin-top: 84px; }
.md-body a[data-doc-anchor] { text-decoration-style: dotted; }
.doc-prevnext { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
.doc-pn { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-body); text-decoration: none; }
.doc-pn:hover { border-color: var(--border-hi); background: var(--bg-elev); color: var(--text-hi); }
.doc-pn.next { text-align: right; grid-column: 2; }
.doc-pn-dir { font-size: 11.5px; color: var(--text-muted); }
.doc-pn-title { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.cmp-table td.cmp-proof { white-space: nowrap; }
.cmp-table .cmp-cur-pill { margin-left: 6px; font-size: 10.5px; }
.bp-table .bp-diagram-btn { margin-left: 6px; }
@media (max-width: 600px) {
  .doc-prevnext { grid-template-columns: minmax(0, 1fr); }
  .doc-pn.next { grid-column: auto; }
}

/* ---------- v2.4 clusters, benchmarks, dossiers ---------- */
abbr.ev-tag { text-decoration: none; cursor: help; }
.fl-id { color: var(--text-hi); font-weight: 600; white-space: nowrap; }
.fl-reps { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: 11px; }
.fl-reps .src-link { min-width: 0; }
#flirtTable code, #tier1MisfileTable code, #islandTable code, #benchReposTable code { overflow-wrap: break-word; word-break: normal; }
.bench-selfchecks { margin: 4px 0 18px; }
.bench-selfchecks > summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-hi);
  padding: 6px 0;
  list-style-position: inside;
}
.bench-selfchecks[open] > summary { margin-bottom: 8px; }
.island-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.island-grid[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.island-grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.island-grid[data-cols="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1700px) {
  .island-grid[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .island-grid[data-cols="3"] { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .island-grid[data-cols] { grid-template-columns: minmax(0, 1fr); }
}
.island-card .ic-top { flex-wrap: nowrap; align-items: flex-start; }
.island-card .ic-name { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; word-break: normal; }
.island-card .ic-top .pill { flex: 0 0 auto; margin-left: auto; }
.island-card .ic-members { overflow-wrap: break-word; word-break: normal; }
.island-card .ic-members > span { white-space: normal; }

/* ---------- Self-test Banner ---------- */
.selftest-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--emerald-bd);
  background: var(--emerald-bg);
  color: var(--emerald);
}
.selftest-banner.fail {
  border-color: var(--crimson-bd);
  background: var(--crimson-bg);
  color: var(--crimson);
}

/* ---------- Responsive ---------- */
@media (max-width: 1060px) {
  .overview-grid,
  .bp-detail-split,
  .atlas-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .twins-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .cir-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(320px, 1fr) 210px;
  }
  .cir-inspector {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 820px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .doc-sidebar {
    position: static;
    max-height: 280px;
  }
  .doc-article-wrap { padding: 16px; }
  .doc-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
  .doc-layout { gap: 20px; }
}

@media (max-width: 600px) {
  .topbar-inner { padding: 6px 10px; gap: 6px; }
  .app-main { padding: 14px 10px 28px; }
  .hero { padding: 8px 0 24px; }
  .hero h1 { font-size: 28px; }
  .hero-sub { font-size: 16px; }
  .page-head h1 { font-size: 26px; }
  .dom-row { grid-template-columns: minmax(110px, 1fr) 64px; }
  .dom-bar-track { display: none; }
  .search-trigger { min-width: 0; padding: 5px 10px; }
  .search-trigger kbd { display: none; }
}

@media (max-width: 1200px) {
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .nav-tab { padding: 0 7px; font-size: 13px; }
}

@media (max-width: 720px) {
  .main-nav { order: 3; flex-basis: 100%; min-height: 40px; }
  .src-drawer,
  .src-drawer.compare {
    top: 3vh;
    bottom: 3vh;
    left: 3vw;
    right: 3vw;
    width: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transform: translateY(12px);
  }
  .src-drawer.open { transform: none; }
  .src-drawer.compare .src-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .src-drawer.compare .src-pane + .src-pane { border-left: 0; border-top: 1px solid var(--border); }
  .src-hd, .src-toolbar { padding-left: 14px; padding-right: 14px; }
  .twins-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-card { padding-right: 8px; margin-right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .src-drawer, .src-backdrop { transition: none; animation: none; }
}

@media (max-width: 1500px) {
  .search-trigger kbd { display: none; }
  .search-trigger { min-width: 0; padding: 5px 10px; }
}
@media (max-width: 1100px) {
  #toolGhLink { display: none; }
}

/* ---------- v2.3 chrome: focus, keyboard, search, nav ---------- */
/* Overlay layering: the source drawer and hover tip sit above full screen (900). */
.src-backdrop { z-index: 950; }
.src-drawer { z-index: 960; }
.circuit-tip { z-index: 980; }

/* Sticky offsets follow the measured header height (--topbar-h is set from JS). */
.outline-rail { top: var(--topbar-h, 57px); height: calc(100vh - var(--topbar-h, 57px)); }
.circuit-shell { height: calc(100vh - var(--topbar-h, 57px) - 93px); }
@media (max-width: 900px) {
  .outline-rail { top: 0; height: 100vh; }
}

/* Nav tabs and diagram chips are links now. */
a.nav-tab, a.nav-tab:hover, a.cir-chip, a.cir-chip:hover, a.cir-crumb, a.cir-crumb:hover { text-decoration: none; }
a.cir-crumb { display: inline-block; }
span.cir-crumb.cur { cursor: default; }

/* Focus rings that are not clipped by overflow: hidden / auto parents. */
.nav-tab:focus-visible,
.seg button:focus-visible,
.proj-item:focus-visible,
.dom-row.clickable:focus-visible,
.search-result-row a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg button:focus-visible { position: relative; z-index: 1; border-radius: 6px; }
.nav-tab:focus-visible { border-radius: 4px; }
.input:focus-visible, .select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg), 0 0 0 1px var(--accent); }
.cir-chip:focus-visible, .cir-crumb:focus-visible, .src-peek-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Diagrams: transient zoom hint and locked selection. */
.cir-zoom-hint {
  position: absolute; left: 50%; top: 12px; z-index: 4; transform: translateX(-50%);
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-hi);
  background: var(--bg-elev); color: var(--text-hi); box-shadow: var(--shadow);
  font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.18s ease;
}
.cir-zoom-hint.show { opacity: 1; }
.cir-ins-hd .cir-ins-clear { width: 24px; height: 24px; margin-left: 6px; font-size: 14px; line-height: 1; }

/* Search: keyboard-highlighted result and hint. */
.search-result-row.kb-active { background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); }
.search-kb-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }

/* Copy feedback. */
.btn.copied { color: var(--emerald); border-color: var(--emerald-bd); }

/* Larger touch targets on touch screens and narrow windows. */
@media (pointer: coarse), (max-width: 720px) {
  .src-peek-btn { height: auto; min-height: 28px; padding: 4px 9px; margin-left: 6px; font-size: 11.5px; }
  .src-link .src-peek-btn { margin-left: 6px; }
  .btn.sm { min-height: 34px; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .seg button { min-height: 34px; }
  .cir-chip, .cir-crumb { min-height: 30px; display: inline-flex; align-items: center; }
  .nav-tab { min-height: 40px; }
  .cir-ins-hd .cir-ins-clear { width: 36px; height: 36px; }
}
@media (pointer: coarse) {
  .search-kb-hint { display: none; }
}

/* ---------- v2.4 overview, projects, chrome ---------- */
/* Labels and titles wrap between words (and at the <wbr> after "." / "_" in
   long Lean names) instead of mid-word. */
.cir-ins-title, .sr-name, .src-title, .doc-item, .doc-pn-title,
.tray-name, .map2d-detail .cir-ins-title, .item-title, .nb-self-name,
.island-card .ic-name, .map-tip-name, .cir-ins-note, .data-table td, .hero h1 {
  overflow-wrap: break-word;
  word-break: normal;
}

/* Topbar: the project switcher already names the project. */
.brand-wrap:has(.proj-switch:not(.hidden)) .brand-repo { display: none; }

/* Comparison table: compact enough to fit the content column at 1440 px. */
.cmp-table th, .cmp-table td { padding: 9px 6px; }
.cmp-table th { font-size: 11.5px; }
.cmp-table th:first-child, .cmp-table td:first-child { padding-left: 12px; }
.cmp-table td.cmp-proof { white-space: normal; min-width: 140px; max-width: 260px; }
.cmp-table td.cmp-proof a, .cmp-table td.cmp-proof > span:first-child { overflow-wrap: break-word; }
.cmp-table td.cmp-license { font-size: 12px; color: var(--text-muted); }
.cmp-table td.cmp-license .lic-part { white-space: nowrap; }
.cmp-table .cmp-star { margin-left: 1px; color: var(--text-dim); font-family: var(--sans); }
.cmp-footnote, .cmp-legend { margin: 8px 2px 0; font-size: 12px; color: var(--text-dim); }

/* Wide tables: right-edge fade and a small cue, only while they overflow. */
.table-wrap.tw-more, .md-table-wrap.tw-more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
}
.tw-cue {
  position: sticky; left: 0;
  padding: 4px 12px 2px;
  font-size: 11.5px; color: var(--text-dim);
  white-space: nowrap; pointer-events: none;
}
.tw-cue[hidden] { display: none; }

/* Touch: comfortable hit areas; scrollable mobile nav fades at the right edge. */
@media (pointer: coarse) {
  .map-chip, .map-pill, .rail-close, .src-peek-btn { min-height: 32px; }
  .map-chip, .map-pill { display: inline-flex; align-items: center; }
  .rail-close { min-width: 32px; }
}
@media (max-width: 720px) {
  .main-nav.nav-more {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  }
}

/* Search on phones: result rows and the scope switcher stay inside the screen. */
@media (max-width: 720px) {
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .seg > button, .seg > a { flex-shrink: 0; white-space: nowrap; }
  .search-hero .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .search-result-row { flex-wrap: wrap; }
  .search-result-row .sr-main { flex: 1 1 100%; min-width: 0; }
  .search-result-row .sr-meta > * { min-width: 0; overflow-wrap: break-word; }
}

/* ---------- v2.5 proof diff view (lemma diff + line diff) ----------
   Four kinds, never told apart by color alone: glyph (− + ⇄ =), border
   style (solid, solid, dashed, dotted) and bar pattern. */
:root {
  --pd-del: var(--crimson);  --pd-del-bg: var(--crimson-bg);  --pd-del-bd: var(--crimson-bd);
  --pd-add: var(--emerald);  --pd-add-bg: var(--emerald-bg);  --pd-add-bd: var(--emerald-bd);
  --pd-mv:  var(--amber);    --pd-mv-bg:  var(--amber-bg);    --pd-mv-bd:  var(--amber-bd);
  --pd-eq:  var(--slate);
  --pd-word-del: rgba(226, 119, 122, 0.30);
  --pd-word-add: rgba(111, 207, 159, 0.28);
}
html[data-theme="light"] {
  --pd-word-del: rgba(180, 45, 52, 0.18);
  --pd-word-add: rgba(24, 121, 78, 0.18);
}

/* Summary bar (pair cards, item page, panel head) */
.pdiff-bar { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pdb-track { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--bg-elev); }
.pdb-seg { flex: 0 1 0; min-width: 4px; }
.pdb-seg.del { background: repeating-linear-gradient(135deg, var(--pd-del) 0 3px, transparent 3px 5px), var(--pd-del-bg); }
.pdb-seg.add { background: var(--pd-add); }
.pdb-seg.mv  { background: radial-gradient(circle, var(--pd-mv) 1.2px, transparent 1.6px) 0 0 / 4px 4px, var(--pd-mv-bg); }
.pdb-seg.eq  { background: transparent; box-shadow: inset 0 0 0 1px var(--pd-eq); border-radius: 2px; }
.pdb-seg.none { flex: 1 1 auto; background: transparent; }
.pdb-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.pdb-chip {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; font: inherit; font-size: 11.5px;
  color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.6;
}
button.pdb-chip { cursor: pointer; }
button.pdb-chip:hover { background: var(--bg-elev); color: var(--text-hi); }
.pdb-chip .pdb-g { font-family: var(--mono); font-weight: 700; }
.pdb-chip.del { border-color: var(--pd-del-bd); } .pdb-chip.del .pdb-g { color: var(--pd-del); }
.pdb-chip.add { border-color: var(--pd-add-bd); } .pdb-chip.add .pdb-g { color: var(--pd-add); }
.pdb-chip.mv  { border-color: var(--pd-mv-bd); border-style: dashed; } .pdb-chip.mv .pdb-g { color: var(--pd-mv); }
.pdb-chip.eq  { border-style: dotted; } .pdb-chip.eq .pdb-g { color: var(--pd-eq); }
.pdb-chip.zero { opacity: 0.55; }
.pdiff-bar.compact { margin-top: 4px; }
.pdiff-bar.compact .pdb-track { height: 4px; }
.twin-card-diff { min-width: 0; }

/* Drawer chrome: tabs row, layout switch, line diff options, back button */
.pdiff-tabs { display: flex; align-items: center; gap: 10px; padding: 8px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pdiff-tabs .spacer { flex: 1; }
.ld-opts { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ld-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-body); cursor: pointer; white-space: nowrap; }
.ld-check input { margin: 0; accent-color: var(--accent); }
.src-body.pdiff-host,
.src-drawer.compare .src-body.pdiff-host { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.pdiff-scroll { min-height: 0; overflow: auto; padding: 14px 20px 24px; }

/* Lemma diff panel */
.pdiff-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pd-head { display: flex; flex-direction: column; gap: 10px; }
.pd-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pd-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; }
.pd-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-right: 6px; }
.pd-side-name { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); overflow-wrap: anywhere; }
.pd-side-meta { font-size: 11.5px; color: var(--text-muted); }
.pd-ctrls { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; position: sticky; top: -14px; z-index: 2; background: var(--bg); padding: 6px 0; border-bottom: 1px solid var(--border); }
.pd-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pd-chip {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.pd-chip:hover { color: var(--text-hi); background: var(--bg-elev); }
.pd-chip.active { color: var(--text-hi); background: var(--bg-elev); border-color: var(--border-hi); font-weight: 600; }
.pd-chip-g { font-family: var(--mono); font-weight: 700; }
.pd-chip.del .pd-chip-g { color: var(--pd-del); }
.pd-chip.add .pd-chip-g { color: var(--pd-add); }
.pd-chip.mv .pd-chip-g { color: var(--pd-mv); }
.pd-chip.eq .pd-chip-g { color: var(--pd-eq); }
.pd-chip-n { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.pd-chip.active .pd-chip-n { color: var(--text-body); }
.pd-chip:focus-visible, .pdb-chip:focus-visible, .ld-mv-tag:focus-visible, .ld-fold:focus-visible, .pd-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pd-q { flex: 1 1 160px; min-width: 0; max-width: 280px; padding: 5px 10px; font-size: 12.5px; }
.pd-list { display: flex; flex-direction: column; min-width: 0; }
.pd-sec { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; font-size: 12.5px; }
.pd-sec:first-child { margin-top: 2px; }
.pd-sec-g { font-family: var(--mono); font-weight: 700; }
.pd-sec.del .pd-sec-g { color: var(--pd-del); } .pd-sec.add .pd-sec-g { color: var(--pd-add); }
.pd-sec.mv .pd-sec-g { color: var(--pd-mv); }   .pd-sec.eq .pd-sec-g { color: var(--pd-eq); }
.pd-sec-t { font-weight: 600; color: var(--text-hi); }
.pd-sec-n { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pd-sec-s { color: var(--text-dim); font-size: 11.5px; }
.pd-row {
  display: grid; grid-template-columns: 1.5em minmax(0, 1fr) auto; align-items: start; gap: 2px 8px;
  padding: 5px 8px 5px 6px; border-left: 3px solid transparent; border-bottom: 1px solid var(--border); min-width: 0;
}
.pd-row.del { border-left: 3px solid var(--pd-del); background: var(--pd-del-bg); }
.pd-row.add { border-left: 3px solid var(--pd-add); background: var(--pd-add-bg); }
.pd-row.mv  { border-left: 3px dashed var(--pd-mv); background: var(--pd-mv-bg); }
.pd-row.eq  { border-left: 3px dotted var(--pd-eq); }
.pd-g { font-family: var(--mono); font-weight: 700; font-size: 13px; text-align: center; line-height: 1.5; }
.pd-row.del .pd-g { color: var(--pd-del); } .pd-row.add .pd-g { color: var(--pd-add); }
.pd-row.mv .pd-g { color: var(--pd-mv); }   .pd-row.eq .pd-g { color: var(--pd-eq); }
.pd-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pd-names { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.pd-name { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); overflow-wrap: anywhere; }
a.pd-name:hover { color: var(--accent); }
.pd-ns { font-family: var(--mono); font-size: 11px; color: var(--text-dim); min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-arrow { color: var(--pd-mv); font-weight: 700; }
.pd-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.pd-pill { display: inline-flex; align-items: center; padding: 0 7px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; color: var(--text-muted); white-space: nowrap; line-height: 1.6; }
.pd-pill.shift { border-style: dashed; border-color: var(--pd-mv-bd); color: var(--pd-mv); }
.pd-pill.reason { border-color: var(--pd-mv-bd); color: var(--text-body); }
.pd-pill.origin.proj { color: var(--text-body); }
.pd-pill.origin.core { border-style: dotted; }
.pd-qual { display: inline-flex; align-items: baseline; min-width: 0; max-width: 100%; }
.pd-qual .pd-name { font-weight: 600; }
.pd-qual .pd-ns { flex: 0 1 auto; font-size: 12.5px; }
.pd-legend { margin: 2px 0 8px; font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
.pd-legend b { font-family: var(--mono); color: var(--text-body); }
.psi-sample-note { margin: -6px 0 10px; font-size: 12px; }
.pd-used { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pd-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pd-act { border: 1px solid var(--border); background: transparent; color: var(--text-muted); font: inherit; font-size: 11px; padding: 0 7px; border-radius: 6px; cursor: pointer; white-space: nowrap; line-height: 1.7; text-decoration: none; }
.pd-act:hover { color: var(--text-hi); border-color: var(--border-hi); text-decoration: none; }
.pd-loc { font-family: var(--mono); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
.pd-trunc, .pd-empty { margin: 6px 0 2px; font-size: 12px; color: var(--text-muted); }
.pd-shared-btn { align-self: flex-start; margin: 2px 0 4px; }
.pd-foot { margin: 0; font-size: 11.5px; color: var(--text-dim); }
.pd-split-hd { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px 0 6px; border-bottom: 1px solid var(--border); }
.pd-split-hd .pd-side-name { font-size: 12px; }
.pd-srow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pd-srow.span { grid-template-columns: minmax(0, 1fr); }
.pd-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: start; }
.pd-col { min-width: 0; display: flex; flex-direction: column; }
.pdiff-panel.compact .pd-ctrls { position: static; }

/* Line diff */
.ld-pane { min-height: 0; }
.ld-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.ld-range { font-family: var(--mono); color: var(--text-muted); margin-right: 4px; }
.ld-note { color: var(--text-muted); font-size: 11.5px; }
.ld-code { padding: 6px 0 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; min-width: max-content; }
.ld-row { display: grid; grid-template-columns: 3.6em 3.6em 1.6em auto auto; align-items: start; border-left: 3px solid transparent; }
.ld-row.del, .ld-cell.del { background: var(--pd-del-bg); border-left: 3px solid var(--pd-del); }
.ld-row.add, .ld-cell.add { background: var(--pd-add-bg); border-left: 3px solid var(--pd-add); }
.ld-row.mv,  .ld-cell.mv  { background: var(--pd-mv-bg);  border-left: 3px dashed var(--pd-mv); }
.ld-ln { padding: 0 8px 0 4px; text-align: right; color: var(--text-dim); user-select: none; font-variant-numeric: tabular-nums; }
.ld-g { text-align: center; font-weight: 700; user-select: none; }
.ld-row.del .ld-g, .ld-cell.del .ld-g { color: var(--pd-del); }
.ld-row.add .ld-g, .ld-cell.add .ld-g { color: var(--pd-add); }
.ld-row.mv .ld-g,  .ld-cell.mv .ld-g  { color: var(--pd-mv); }
.ld-txt { white-space: pre; padding-right: 14px; color: var(--text-body); tab-size: 2; }
.ld-row.eq .ld-txt, .ld-cell.eq .ld-txt { color: var(--text-muted); }
mark.ld-w { color: var(--text-hi); border-radius: 2px; padding: 0 1px; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.del > .ld-txt mark.ld-w { background: var(--pd-word-del); text-decoration-style: wavy; }
.add > .ld-txt mark.ld-w { background: var(--pd-word-add); }
.ld-mv-tag { margin-right: 12px; padding: 0 7px; border: 1px dashed var(--pd-mv-bd); border-radius: 999px; background: transparent; color: var(--pd-mv); font: inherit; font-family: var(--sans); font-size: 11px; cursor: pointer; white-space: nowrap; align-self: center; }
.ld-mv-tag:hover { background: var(--pd-mv-bg); }
.ld-fold { display: block; margin: 2px 0; padding: 2px 10px 2px calc(7.2em + 12px); width: 100%; text-align: left; border: 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); background: var(--bg-elev); color: var(--text-muted); font: inherit; font-family: var(--sans); font-size: 11.5px; cursor: pointer; }
.ld-fold:hover { color: var(--text-hi); }
.ld-code.split { min-width: 0; }
.ld-srow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ld-cell { display: grid; grid-template-columns: 3.4em 1.6em minmax(0, 1fr); align-items: start; border-left: 3px solid transparent; min-width: 0; overflow: hidden; }
.ld-cell + .ld-cell { border-right: 0; box-shadow: inset 1px 0 0 var(--border); }
.ld-cell .ld-txt { white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 8px; }
.ld-cell .ld-mv-tag { grid-column: 3; justify-self: start; margin: 0 0 2px; }
.ld-cell.empty { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--bg-elev) 6px 7px); }
.ld-row.flash, .ld-cell.flash, .ld-srow.flash { outline: 2px solid var(--accent); outline-offset: -2px; }
.ld-unavail { border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ld-unavail h4 { margin: 0; font-size: 14px; color: var(--text-hi); }
.ld-unavail p { margin: 0; font-size: 13px; color: var(--text-body); overflow-wrap: anywhere; }
.ld-fallback { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.ld-fallback.with-lemmas { grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2fr); }

@media (max-width: 900px) {
  .ld-fallback.with-lemmas { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .pdiff-tabs { padding: 8px 14px; }
  .pdiff-scroll { padding: 12px 12px 20px; }
  .pd-ctrls { top: -12px; }
  .pd-sides, .pd-split-hd, .pd-srow, .pd-cols { grid-template-columns: minmax(0, 1fr); }
  .pd-srow { gap: 0; border-bottom: 1px solid var(--border); }
  .pd-row { grid-template-columns: 1.4em minmax(0, 1fr); }
  .pd-acts { grid-column: 2; justify-content: flex-start; }
  .pd-ns { display: none; }
  .pd-q { max-width: none; flex-basis: 100%; }
  .ld-srow { grid-template-columns: minmax(0, 1fr); }
  .ld-srow .ld-cell.empty { display: none; }
  .ld-cell + .ld-cell { box-shadow: none; }
  .ld-row { grid-template-columns: 2.8em 2.8em 1.4em auto auto; }
}

/* ---------- Round 3 polish ---------- */
.bp-table td { white-space: normal; vertical-align: top; }
.bp-table td:first-child { min-width: 180px; }
.bp-table .bp-id { overflow-wrap: anywhere; word-break: break-word; }
.bp-table .bp-anchor, .bp-table .bp-anchor a { overflow-wrap: anywhere; word-break: break-word; }
.bp-table .bp-diagram-btn { display: block; margin: 4px 0 0; }
.bp-table td .pill { white-space: nowrap; }
@media (min-width: 1061px) {
  .bp-detail-split { grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); }
}
.island-tier-legend { margin: -4px 0 14px; font-size: 12.5px; line-height: 1.5; }
.island-tier-legend b { color: var(--text-body); }
.cmp-legend b { color: var(--text-body); font-weight: 600; }
.search-xrefs-link { margin: -4px 0 10px; font-size: 13px; }
.search-xrefs-link a { color: var(--accent); }
.route-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px; padding: 8px 12px; border: 1px solid var(--border-hi); border-radius: 8px; background: var(--bg-elev); color: var(--text-body); font-size: 13px; }
.route-notice .icon-btn { flex: none; }

/* ---------- v2.7 Homepage 3-tier explorer workbench ---------- */
.app-main.wb-wide {
  max-width: none;
  padding: 10px 18px 40px;
}
body.wb-wide-route .crumb-bar {
  max-width: none;
  padding: 8px 18px 0;
}
body.wb-wide-route .crumb-bar:not(.hidden) + .app-main.wb-wide {
  padding-top: 8px;
}

.hero.hero-wb {
  max-width: none;
  padding: 2px 0 10px;
  margin-bottom: 6px;
}
.hero-wb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
}
.hero-wb-id {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.hero.hero-wb h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}
.hero.hero-wb .trust-line { margin: 0; }
.hero.hero-wb .hero-actions { margin-top: 0; gap: 6px; }
.hero-wb-subrow {
  display: flex;
  align-items: baseline;
  gap: 4px 14px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.hero.hero-wb .hero-sub {
  font-size: 13.5px;
  line-height: 1.45;
  max-width: none;
}
.hero-wb-metrics {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.hero.hero-wb .hero-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  max-width: none;
}

.ov-workbench {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
}
.ov-band {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  overflow: hidden;
  min-width: 0;
}
.ov-treemap-band {
  border: 0;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}
#ovTreemapHost .tm-head { display: none; }
#ovTreemapHost .tm-shell:not(.fs-on) .tm-body {
  grid-template-columns: minmax(0, 1fr);
}
#ovTreemapHost .tm-shell:not(.fs-on) .tm-inspector {
  border-left: 0;
  border-top: 1px solid var(--border);
  max-height: none;
}
#ovTreemapHost .tm-shell:not(.fs-on) .tm-canvas-wrap {
  min-height: 480px;
  height: clamp(480px, 66vh, 800px);
}

.ov-band-hd {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--border);
}
.ov-band-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
  flex: 1 1 260px;
}
.ov-band-kicker {
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap;
}
.ov-src-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  overflow-wrap: break-word;
  min-width: 0;
}
.ov-band-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ov-src-loc {
  max-width: 44ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-band-acts {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.ov-inside-strip {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ov-inside-hd {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
}
.ov-inside-kicker { font-weight: 650; color: var(--text-hi); }
.ov-inside-path { color: var(--text-muted); overflow-wrap: anywhere; }
.ov-inside-stats { color: var(--text-muted); font-size: 12px; margin-right: auto; }
.ov-inside-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 6px;
}
.ov-inside-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-panel);
  min-width: 0;
}
.ov-inside-row.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.ov-inside-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.ov-inside-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ov-inside-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ov-inside-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ov-source-dock { min-width: 0; }
.ov-source-dock .src-scroll.docked { max-height: 500px; min-height: 150px; }
.ov-src-placeholder {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-code);
}
.ov-src-ph-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ov-src-ph-note { margin: 0; font-size: 13px; color: var(--text-muted); }
.ov-src-ph-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.ov-diag-sub {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.ov-diag-zoom { display: inline-flex; align-items: center; gap: 4px; }
.ov-diag-stage-wrap {
  position: relative;
  min-height: 300px;
  max-height: 600px;
  overflow: hidden;
  background: var(--bg-code);
}
.ov-diag-stage-wrap[data-pan-zoom="1"] {
  height: clamp(360px, 52vh, 580px);
  cursor: grab;
  touch-action: none;
}
.ov-diag-stage-wrap.dragging { cursor: grabbing; }
.ov-diag-stage { min-height: 280px; }
.ov-diag-stage.pan-zoom { transform-origin: 0 0; will-change: transform; }
.ov-diag-stage:not(.pan-zoom) { padding: 12px 14px; }
.ov-ego-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.ov-ego-tip { margin-left: auto; color: var(--text-dim); font-size: 11.5px; }
.ov-diagram-band.fs-on { display: flex; flex-direction: column; }
.ov-diagram-band.fs-on .ov-diag-stage-wrap { flex: 1 1 auto; max-height: none; height: auto; }

.ov-summary-below {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  max-width: 1360px;
  margin-left: auto;
  margin-right: auto;
}
.ov-below-hdr { margin-top: 0; }
.ov-quick-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.ov-quick-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.ov-quick-card:hover {
  border-color: var(--border-hi);
  background: var(--bg-elev);
  text-decoration: none;
}
.ov-qc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ov-qc-title { font-weight: 600; font-size: 14px; color: var(--text-hi); }
.ov-qc-meta { font-size: 11.5px; color: var(--accent); white-space: nowrap; }
.ov-qc-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }

@media (max-width: 720px) {
  .app-main.wb-wide { padding: 8px 10px 28px; }
  body.wb-wide-route .crumb-bar { padding: 8px 10px 0; }
  .hero.hero-wb h1 { font-size: 19px; }
  #ovTreemapHost .tm-shell:not(.fs-on) .tm-canvas-wrap {
    min-height: 320px;
    height: clamp(320px, 52vh, 500px);
  }
  .ov-band-acts { margin-left: 0; }
  .ov-src-loc { max-width: 100%; }
  .ov-ego-tip { margin-left: 0; width: 100%; }
}
