@import url('./tokens.css');

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html { overflow-x: hidden; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
  height: 100vh;
  min-width: 0;
}

/* ============ HEADER ============ */
.site-header {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-6);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-hair);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.brand-lockup img {
  height: 28px;
  width: auto;
  display: block;
}
.brand-divider {
  width: 1px; height: 22px; background: var(--border-soft); flex-shrink: 0;
}
.brand-title {
  display: flex; flex-direction: row; align-items: center; gap: var(--sp-3); line-height: 1.1; white-space: nowrap;
}
a.brand-title {
  text-decoration: none;
}
a.brand-title:hover { text-decoration: none; }
.brand-title .project-name {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--fg-brand);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.brand-title .brand-section {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--fg-1);
  font-variation-settings: "opsz" 24;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-left: auto;
}

.github-link {
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.github-link:hover {
  opacity: 1;
}


.btn {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--carnelian);
  color: white;
}
.btn-primary:hover { background: var(--carnelian-deep); }
.btn-secondary {
  background: transparent;
  color: var(--fg-1);
  border-color: var(--ink);
}
.btn-secondary:hover { background: rgba(18,20,23,0.06); }
.btn-ghost {
  background: transparent;
  color: var(--fg-2);
}
.btn-ghost:hover { background: rgba(18,20,23,0.06); color: var(--fg-1); }

.version-select {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  appearance: auto;
  padding-right: 24px;
}

/* ============ ABOUT MODAL ============ */
.about-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.about-lede {
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--fg-2);
  margin: 0;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-hair);
}
.about-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.about-section h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0;
}
.about-section p {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--fg-2);
  margin: 0;
  text-wrap: pretty;
}
.about-section strong { color: var(--fg-1); font-weight: 600; }
.about-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-list li {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--fg-2);
}
.about-list li strong { color: var(--fg-1); }

/* ============ HERO STRIP (above the graph) ============ */
.hero {
  padding: var(--sp-4) var(--sp-6) var(--sp-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-hair);
  flex-shrink: 0;
  max-height: 36vh;
  overflow: visible;
  position: relative;
  z-index: 10;
}
.hero-inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  max-width: 1600px;
  margin: 0 auto;
}
.hero-headline {
  width: 100%;
}
.hero-detail {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: var(--sp-6);
}
@media (max-height: 720px) {
  .hero { padding: 10px var(--sp-6); }
  .hero h1 { font-size: var(--fs-lg) !important; margin-bottom: 2px !important; }
  .hero .lede { display: none; }
  .hero .eyebrow { margin-bottom: 2px !important; font-size: var(--fs-xs) !important; }
  .hero-stats .stat .num { font-size: var(--fs-lg) !important; }
  .hero-stats { gap: var(--sp-5) !important; }
}
@media (max-width: 900px) {
  .hero-stats { display: none; }
  .hero-detail { grid-template-columns: 1fr; }
}
.hero .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-brand);
  margin-bottom: var(--sp-2);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 500;
  font-variation-settings: "opsz" 48;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: var(--fg-1);
  text-wrap: balance;
}
.hero h1 em {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
  color: var(--carnelian);
}
.hero .lede {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--fg-3);
  max-width: none;
  margin: 0;
  text-wrap: pretty;
}

.hero-stats {
  display: flex;
  gap: var(--sp-6);
  font-family: var(--font-mono);
  padding-bottom: 4px;
  align-items: center;
  position: relative;
}
.stat {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 6px;
}
.stat .num {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  font-variation-settings: "opsz" 36;
  color: var(--fg-1);
  letter-spacing: -0.02em;
}
.stat .lbl {
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-4);
}
.stat-link {
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: var(--sp-2);
  margin: calc(-1 * var(--sp-2));
  transition: background var(--dur-fast) var(--ease-standard);
}
.stat-link:hover {
  background: rgba(18,20,23,0.06);
}
.stat-link:hover .lbl {
  color: var(--fg-2);
}

.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.stat-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.stat-list-item:hover {
  background: rgba(18,20,23,0.06);
}
.stat-list-item .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stat-list-name {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-1);
}
.stat-list-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  letter-spacing: 0.04em;
}

/* ============ MAIN SPLIT ============ */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 340px;
  overflow: hidden;
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr 360px; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr 320px; }
}

.mobile-inspector-toggle { display: none; }

/* ------ graph pane ------ */
.graph-pane {
  position: relative;
  background: var(--bg-1);
  overflow: hidden;
  border-right: 1px solid var(--border-hair);
}

.graph-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.graph-canvas:active { cursor: grabbing; }

/* Faint blueprint grid on paper background, drawn as CSS */
.graph-pane::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(18,20,23,0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(18,20,23,0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 95%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 95%);
}

/* Floating overlays over the graph */
.graph-overlay {
  position: absolute;
  z-index: 3;
  background: rgba(251, 250, 246, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

/* Search + title overlay, top-left */
.graph-topbar {
  top: var(--sp-5);
  left: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: 8px 10px 8px 14px;
  pointer-events: none;
}
.graph-topbar > * { pointer-events: auto; }

.graph-topbar .title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}
.graph-topbar .title b { color: var(--fg-1); font-weight: 600; }

.search-wrap {
  flex: 1;
  max-width: 320px;
  margin-left: auto;
  position: relative;
}
.search-wrap input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  padding: 8px 10px 8px 30px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  color: var(--fg-1);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.search-wrap input:focus {
  border-color: var(--carnelian);
  box-shadow: 0 0 0 2px rgba(179,27,27,0.15);
}
.search-wrap svg {
  position: absolute;
  left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--fg-4);
  pointer-events: none;
}

/* Search bar below hero stats, above graph */
.graph-search {
  position: absolute;
  top: var(--sp-5);
  left: var(--sp-5);
  z-index: 10;
  display: flex;
  align-items: center;
  width: min(380px, calc(100% - 200px));
}
.graph-search svg {
  position: absolute;
  left: 12px;
  color: var(--fg-4);
  pointer-events: none;
  flex-shrink: 0;
}
.graph-search input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  padding: 10px 14px 10px 36px;
  background: rgba(251, 250, 246, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  color: var(--fg-1);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.graph-search input:focus {
  border-color: var(--carnelian);
  box-shadow: 0 0 0 2px rgba(179,27,27,0.12);
  background: var(--bg-2);
}
.graph-search .search-results {
  top: calc(100% + 4px);
  left: 0;
  right: 0;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  margin-top: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  max-height: 260px;
  overflow-y: auto;
  display: none;
  z-index: 10;
}
.search-results.open { display: block; }
.search-results .result {
  padding: 8px 12px;
  font-size: var(--fs-sm);
  cursor: pointer;
  border-bottom: 1px solid var(--border-hair);
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-results .result:last-child { border-bottom: none; }
.search-results .result:hover { background: var(--fog); }
.search-results .result .kind {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-left: auto;
}
.search-results .swatch {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}

/* Legend overlay, bottom-left */
.graph-legend {
  top: var(--sp-5);
  right: var(--sp-5);
  padding: 12px 14px;
}
.graph-legend h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0 0 8px 0;
  font-weight: 600;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast) var(--ease-standard);
}
.legend-row:hover { color: var(--fg-1); }
.legend-row.off { opacity: 0.3; }
.legend-row.off:hover { opacity: 0.55; }
.legend-row .dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid transparent;
}
.legend-row .count {
  margin-left: auto;
  padding-left: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
}

/* Jacobs logo — bottom-left of graph */
.jacobs-float {
  position: absolute;
  bottom: var(--sp-5);
  left: var(--sp-5);
  width: 140px;
  height: auto;
  display: block;
  opacity: 0.55;
  pointer-events: none;
  z-index: 3;
  mix-blend-mode: multiply;
}

/* Physics + zoom controls bottom-right */
.graph-controls {
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
}
.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  white-space: nowrap;
}
.control-row label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--mist);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: left var(--dur-fast) var(--ease-standard);
}
.toggle.on { background: var(--carnelian); }
.toggle.on::after { left: 16px; }

.zoom-btns {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.zoom-btn {
  width: 28px; height: 26px;
  background: var(--bg-1);
  border: none;
  cursor: pointer;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.zoom-btn:hover { background: var(--fog); color: var(--fg-1); }
.zoom-btn + .zoom-btn { border-left: 1px solid var(--border-hair); }

/* Hint bottom middle */
.graph-hint {
  position: absolute;
  left: 50%;
  bottom: var(--sp-5);
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
  pointer-events: none;
  display: flex;
  gap: 14px;
}
.graph-hint kbd {
  font-family: var(--font-mono);
  background: var(--bg-2);
  border: 1px solid var(--border-hair);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-right: 4px;
}

/* ============ INSPECTOR ============ */
.inspector {
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

@media (max-width: 1024px) and (min-width: 768px) {
  html { height: auto; width: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  body { overflow: visible; height: auto; min-height: 100vh; width: 100%; max-width: 100vw; }
  .hero-inner { grid-template-columns: 1fr; gap: var(--sp-5); }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: 0;
    overflow: visible;
    flex: 0 0 auto;
  }
  .graph-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-hair);
    height: 62dvh;
    min-height: 420px;
  }
  .inspector { border-top: 1px solid var(--border-hair); max-height: none; overflow: visible; }
  .inspector-detail { height: auto; overflow: visible; }
  .inspector-body { overflow-y: visible; }
  .inspector-empty { height: auto; }
  .graph-search { width: min(440px, calc(100% - 24px)); left: 12px; top: 12px; }
  .graph-legend { right: 12px; top: 12px; max-width: min(38vw, 260px); max-height: 42vh; overflow: auto; }
  .graph-controls { right: 12px; bottom: 12px; }
  .jacobs-float { left: 12px; bottom: 12px; width: clamp(94px, 16vw, 130px); }
}

@media (max-width: 767px) {
  html { height: auto; width: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  body { overflow: visible; height: auto; min-height: 100vh; width: 100%; max-width: 100vw; }
  .site-header { padding: 10px 12px; gap: var(--sp-3); flex-wrap: wrap; }
  .brand-lockup { min-width: 0; max-width: 100%; }
  .brand-title { white-space: nowrap; }
  .brand-title .project-name, .brand-title .brand-section { font-size: var(--fs-sm); }
  .header-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .hero { padding: var(--sp-5) 12px; max-height: none; }
  .hero h1 { font-size: clamp(28px, 9vw, 42px); line-height: 1.08; }
  .hero-stats { grid-template-columns: 1fr; }
  .workspace {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    min-height: 0;
    overflow: visible;
    flex: 0 0 auto;
  }
  .graph-pane { height: 70dvh; min-height: 480px; border-right: none; border-bottom: none; }
  .graph-pane::before { mask-image: none; -webkit-mask-image: none; }
  .graph-search { top: 10px; left: 10px; width: calc(100% - 20px); }
  .graph-search input { padding: 12px 14px 12px 36px; font-size: 16px; }
  .graph-legend { display: none; }
  .jacobs-float { display: none; }
  .graph-controls { right: 10px; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .zoom-btn { min-width: 38px; min-height: 38px; font-size: 18px; }
  .mobile-inspector-toggle {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: rgba(251, 250, 246, 0.95);
    color: var(--fg-1);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: 600;
    box-shadow: var(--shadow-2);
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
  }
  .inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    max-height: min(62dvh, 520px);
    border-top: 1px solid var(--border-hair);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform var(--dur-med) var(--ease-standard);
    box-shadow: var(--shadow-2);
  }
  body.mobile-inspector-open .inspector { transform: translateY(0); }
}

.inspector-empty {
  padding: var(--sp-7) var(--sp-6);
  color: var(--fg-3);
  text-align: left;
  font-size: var(--fs-base);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  height: 100%;
}
.inspector-empty .mono-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-brand);
  font-weight: 600;
}
.inspector-empty h3 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  color: var(--fg-1);
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 36;
}
.inspector-empty ul {
  list-style: none;
  margin: var(--sp-3) 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.inspector-empty li {
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--fg-2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.inspector-empty li:hover {
  border-color: var(--border-soft);
  background: var(--fog);
}
.inspector-empty li .num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--fg-brand);
  font-weight: 600;
  padding-top: 2px;
  min-width: 16px;
}

/* Inspector detail mode */
.inspector-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.inspector-header {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-hair);
  position: relative;
}
.inspector-header .kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.inspector-header .kicker .kind-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.inspector-header .kicker .kind-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 600;
}
.inspector-header .kicker .cluster {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-brand);
  font-weight: 600;
}
.inspector-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
  font-weight: 500;
  font-variation-settings: "opsz" 36;
  color: var(--fg-1);
  text-wrap: balance;
}
.inspector-header h2 .rel-arrow {
  color: var(--fg-4);
  margin: 0 0.3em;
  font-weight: 400;
}
.inspector-header h2 .rel-endpoint {
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-2);
}
.inspector-header .edge-label {
  font-family: var(--font-accent);
  font-style: italic;
  font-size: var(--fs-lg);
  color: var(--carnelian);
  font-weight: 400;
  display: block;
  margin-top: 6px;
}

.close-btn {
  position: absolute;
  top: 18px; right: 14px;
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-4);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.close-btn:hover { background: rgba(18,20,23,0.06); color: var(--fg-1); }

.inspector-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border-hair);
  flex-shrink: 0;
}
.tab-btn {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.005em;
  padding: 12px 0;
  margin-right: 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.tab-btn:hover { color: var(--fg-1); }
.tab-btn.active {
  color: var(--fg-1);
  border-bottom-color: var(--carnelian);
}
.tab-btn .badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--fog);
  color: var(--fg-3);
  border-radius: 999px;
  font-weight: 500;
}
.tab-btn.active .badge { background: var(--carnelian); color: white; }

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
}

.section {
  margin-bottom: var(--sp-5);
}
.section:last-child { margin-bottom: 0; }


.section h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0 0 10px 0;
}

.definition {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--fg-2);
  text-wrap: pretty;
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--fog);
  color: var(--fg-2);
  border: 1px solid var(--border-hair);
  text-transform: uppercase;
}
.chip-hover {
  position: relative;
  cursor: default;
}
.chip-tooltip {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  background: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  z-index: 20;
  min-width: 160px;
  max-width: 260px;
  box-shadow: var(--shadow-2);
  flex-direction: column;
  gap: 3px;
}
.chip-hover:hover .chip-tooltip { display: flex; }
.chip-tooltip span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--bg-1);
  padding: 2px 0;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.chip-vocab {
  background: rgba(179, 27, 27, 0.06);
  color: var(--carnelian);
  border: 1px solid rgba(179, 27, 27, 0.18);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.chip-vocab::before { content: "⬡ "; font-size: 9px; }
.chip-vocab:hover {
  background: rgba(179, 27, 27, 0.12);
  border-color: var(--carnelian);
}

/* properties list */
.prop-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.prop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 7px 0;
  font-size: var(--fs-sm);
}
.prop-item .name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg-1);
  font-size: var(--fs-sm);
}
.prop-item .type-group {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.prop-item .type {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
}
.prop-item .type .req { color: var(--carnelian); margin-left: 4px; font-size: 10px; }
.prop-item .note {
  grid-column: 1 / -1;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--fg-3);
  text-wrap: pretty;
}

/* enum hover pill */
.enum-hover {
  position: relative;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--fog);
  color: var(--fg-3);
  cursor: default;
}
.enum-hover::before { content: "⌄ "; font-size: 8px; }
.enum-tooltip {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  z-index: 20;
  min-width: 140px;
  max-width: 220px;
  box-shadow: var(--shadow-2);
}
.enum-hover:hover .enum-tooltip { display: flex; flex-direction: column; gap: 3px; }
.enum-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--bg-1);
  padding: 2px 0;
  white-space: nowrap;
}

/* vocab tag on property */
.vocab-tag {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(179, 27, 27, 0.06);
  color: var(--carnelian);
  border: 1px solid rgba(179, 27, 27, 0.18);
  cursor: pointer;
  width: fit-content;
  transition: background var(--dur-fast) var(--ease-standard);
}
.vocab-tag::before { content: "⬡ "; }
.vocab-tag:hover {
  background: rgba(179, 27, 27, 0.12);
  border-color: var(--carnelian);
}

/* neighbor list */
.neighbors {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.neighbor {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.neighbor:hover { border-color: var(--border-soft); background: var(--fog); }
.neighbor .dot { width: 9px; height: 9px; border-radius: 50%; }
.neighbor .label .rel {
  font-family: var(--font-accent);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--carnelian);
  display: block;
}
.neighbor .label .name {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-1);
}
.neighbor .label .dir {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.neighbor .arrow { color: var(--fg-4); font-family: var(--font-mono); }

/* ============ COMMENTS ============ */
.comments {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.comment-thread {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.comment {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
}
.comment .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--carnelian);
  color: white;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.comment.c-blue .avatar { background: var(--blueprint); }
.comment.c-green .avatar { background: var(--chlorophyll); }
.comment.c-slate .avatar { background: var(--slate-blue); }
.comment.c-amber .avatar { background: var(--sodium); color: var(--ink); }

.comment .bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.comment .byline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}
.comment .byline .name {
  font-weight: 600;
  color: var(--fg-1);
}
.comment .byline .affil {
  font-size: var(--fs-xs);
  color: var(--fg-4);
}
.comment .byline .time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  letter-spacing: 0.06em;
}
.comment .body {
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--fg-2);
  text-wrap: pretty;
}
.comment .body strong {
  background: var(--sodium-soft);
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 500;
  color: var(--ink);
}
.comment .actions {
  display: flex;
  gap: 14px;
  margin-top: 4px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
.comment .actions a {
  color: var(--fg-3);
  text-decoration: none;
  cursor: pointer;
}
.comment .actions a:hover { color: var(--carnelian); text-decoration: underline; }
.comment .actions a.resolved {
  color: var(--chlorophyll);
  font-weight: 500;
}

.comment-reply {
  margin-left: 46px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
}
.comment-reply .avatar { width: 28px; height: 28px; font-size: var(--fs-xs); }
.comment-reply .bubble .byline { font-size: var(--fs-sm); }
.comment-reply .bubble .body { font-size: var(--fs-sm); }

.empty-comments {
  padding: var(--sp-5) 0;
  text-align: center;
  color: var(--fg-4);
  font-size: var(--fs-sm);
  line-height: 1.55;
  border: 1px dashed var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-1);
}

.composer {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-hair);
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
}
.composer .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer .box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer textarea {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-1);
  color: var(--fg-1);
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard);
  width: 100%;
}
.composer textarea:focus {
  border-color: var(--carnelian);
  box-shadow: 0 0 0 2px rgba(179,27,27,0.12);
}
.composer .bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.composer .hint {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* selectable text subtle */
::selection {
  background: var(--sodium-soft);
  color: var(--ink);
}

/* ============ MODALS ============ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 20, 23, 0.5);
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  max-width: 540px;
  width: 92%;
  box-shadow: var(--shadow-3);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content.wide { max-width: 720px; }
.modal-content h3 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 var(--sp-4) 0;
  color: var(--fg-1);
}
.modal-buttons {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}
.modal-buttons button {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--fg-1);
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.modal-buttons button:hover {
  background: rgba(18,20,23,0.06);
  border-color: var(--border-firm);
}
.modal-buttons button.primary {
  background: var(--carnelian);
  color: white;
  border-color: var(--carnelian);
}
.modal-buttons button.primary:hover {
  background: var(--carnelian-deep);
  border-color: var(--carnelian-deep);
}

/* ============ VOCABULARY MODAL ============ */
.vocab-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  margin-bottom: var(--sp-3);
  overflow: hidden;
}
.vocab-card.vocab-external { border-color: var(--carnelian); }
.vocab-card.vocab-open { border-color: var(--border-firm); }
.vocab-card.vocab-external.vocab-open { border-color: var(--carnelian); }

.vocab-header {
  display: flex;
  gap: 10px;
  padding: var(--sp-4);
  cursor: pointer;
  align-items: flex-start;
  transition: background var(--dur-fast) var(--ease-standard);
}
.vocab-header:hover { background: var(--fog); }

.vocab-chevron {
  font-size: 10px;
  color: var(--fg-4);
  width: 14px;
  flex-shrink: 0;
  padding-top: 3px;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.vocab-summary { flex: 1; min-width: 0; }
.vocab-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg-1);
  margin-bottom: 4px;
}
.vocab-external .vocab-label { color: var(--carnelian); }
.vocab-desc {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.5;
  margin-bottom: 8px;
}
.vocab-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.vocab-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fog);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.vocab-badge-type { font-weight: 600; }
.vocab-external .vocab-badge-type {
  background: rgba(179, 27, 27, 0.08);
  color: var(--carnelian);
}
.vocab-ref {
  font-size: 11px;
  color: var(--carnelian);
  text-decoration: none;
}
.vocab-ref:hover { text-decoration: underline; }
.vocab-bindings {
  margin-top: 6px;
  font-size: 11px;
  color: var(--fg-4);
  line-height: 1.6;
}
.vocab-bindings code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--fog);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--fg-2);
}

.vocab-body {
  border-top: 1px solid var(--border-hair);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  max-height: 360px;
  overflow-y: auto;
}
.vocab-loading {
  text-align: center;
  color: var(--fg-4);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  padding: var(--sp-3) 0;
}
.vocab-empty {
  text-align: center;
  color: var(--fg-4);
  font-size: var(--fs-sm);
  padding: var(--sp-3) 0;
}

.vocab-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.vocab-tree .vocab-tree {
  padding-left: 20px;
}
.vocab-tree-node {
  margin-bottom: 1px;
}
.vocab-tree-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.vocab-tree-header[data-expandable] {
  cursor: pointer;
}
.vocab-tree-header[data-expandable]:hover {
  background: var(--fog);
}
.vocab-tree-chevron {
  font-size: 9px;
  color: var(--fg-4);
  width: 12px;
  flex-shrink: 0;
  padding-top: 3px;
}
.vocab-tree-leaf {
  color: var(--fg-4);
  width: 12px;
  flex-shrink: 0;
  text-align: center;
  font-weight: 600;
}
.vocab-tree-name {
  color: var(--fg-1);
  font-weight: 500;
}
.vocab-tree-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  background: var(--fog);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  flex-shrink: 0;
}
.vocab-tree-note {
  display: block;
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
  line-height: 1.45;
}
.vocab-tree-children {
  list-style: none;
  margin: 0;
  padding-left: 18px;
}

/* Section count badge */
.section-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--fog);
  color: var(--fg-4);
  margin-left: 6px;
  vertical-align: middle;
}

/* Inline relationship list in Detail tab */
.rel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rel-item {
  display: flex;
  align-items: baseline;
  gap: 0;
  padding: 5px 8px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
  font-size: var(--fs-sm);
}
.rel-item:hover { background: var(--fog); }
.rel-sentence {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.rel-self {
  color: var(--fg-4);
  font-weight: 400;
}
.rel-other {
  font-weight: 600;
}
.rel-label {
  font-family: var(--font-accent);
  font-style: italic;
  color: var(--carnelian);
  white-space: nowrap;
}

/* Meta row (label + value pair) */
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
}

.meta-label {
  color: var(--fg-3);
  font-weight: 500;
  min-width: 90px;
}

.meta-value {
  color: var(--fg-2);
}

/* ============ COMMENTS LOADING ============ */
.comments-loading {
  padding: var(--sp-5) 0;
  text-align: center;
  color: var(--fg-4);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}

.comment-new-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  border: 1px dashed var(--border-soft);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--fg-3);
  text-decoration: none;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
  margin-top: var(--sp-3);
}
.comment-new-link:hover {
  border-color: var(--carnelian);
  color: var(--carnelian);
  background: rgba(179, 27, 27, 0.04);
}

.comment-error {
  padding: var(--sp-4);
  text-align: center;
  color: var(--fg-4);
  font-size: var(--fs-sm);
  line-height: 1.5;
  border: 1px dashed var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--bg-1);
}

/* ── Changelog modal ─────────────────────────────────────────────────── */
.changelog-entry {
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border-soft);
}
.changelog-entry:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.changelog-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.changelog-version {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: 0.04em;
}
.changelog-date {
  font-size: var(--fs-xs);
  color: var(--fg-4);
}
.changelog-summary {
  font-size: var(--fs-sm);
  color: var(--fg-3);
  font-style: italic;
}
.changelog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.changelog-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.changelog-text {
  color: var(--fg-2);
}
.change-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.change-badge-added   { background: rgba(22, 130, 60, 0.12); color: #16823c; }
.change-badge-removed { background: rgba(179, 27, 27, 0.10); color: var(--carnelian); }
.change-badge-changed { background: rgba(30, 77, 216, 0.10); color: var(--blueprint); }
.change-badge-fixed   { background: rgba(180, 120, 0, 0.12); color: #b47800; }
