:root {
  --bg: #080a0b;
  --panel: #101315;
  --panel-2: #161a1d;
  --panel-3: #1e2427;
  --ink: #f3f0e8;
  --muted: #a7aea8;
  --faint: #69716d;
  --line: rgba(243, 240, 232, 0.1);
  --line-strong: rgba(243, 240, 232, 0.2);
  --accent: #43d9ad;
  --accent-soft: rgba(67, 217, 173, 0.14);
  --amber: #f0b429;
  --red: #ff6b5f;
  --cyan: #6cc7d9;
  --green: #43d9ad;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(67, 217, 173, 0.45) rgba(255, 255, 255, 0.045);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.045);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(8, 10, 11, 0.9);
  border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 62%, #ffffff 10%), rgba(243, 240, 232, 0.36));
}

*::-webkit-scrollbar-corner {
  background: var(--bg);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 15% 10%, rgba(67, 217, 173, 0.12), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(240, 180, 41, 0.1), transparent 26%),
    var(--bg);
  background-size: 44px 44px, 44px 44px, auto, auto, auto;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 68px 46px minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  background: rgba(10, 13, 14, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.top-actions,
.dataset-switcher,
.view-tabs,
.metric-row,
.tab-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
  min-width: 0;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(67, 217, 173, 0.2), rgba(240, 180, 41, 0.14));
  cursor: pointer;
}

.mark span {
  border-radius: 2px;
  background: var(--ink);
  opacity: 0.82;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(560px, 46vw);
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.sv {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
}

.dataset-switcher {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.dataset-switcher button,
.view-tabs button,
.secondary-btn,
.primary-btn {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.dataset-switcher button {
  height: 30px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dataset-switcher button.active {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover,
.secondary-btn:hover,
.primary-btn:hover,
.view-tabs button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view-tabs {
  gap: 4px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.view-tabs button {
  height: 32px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.view-tabs button.active {
  color: var(--ink);
  background: var(--panel-3);
  border-color: var(--line-strong);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  background: rgba(8, 10, 11, 0.72);
}

.filter-rail,
.inspector {
  min-height: 0;
  background: rgba(16, 19, 21, 0.88);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.inspector {
  display: none;
  border-right: none;
  border-left: 1px solid var(--line);
}

.filter-rail {
  padding: 18px;
}

.filter-block {
  margin-bottom: 22px;
}

.filter-block h3,
.panel-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft);
}

.search,
.select,
.range {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  outline: none;
}

.search,
.select {
  height: 38px;
  padding: 0 11px;
  font-size: 13px;
}

.search-input {
  width: 100%;
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  outline: none;
  padding: 0 12px;
  font-size: 13px;
  line-height: 38px;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.search-input::placeholder {
  color: var(--faint);
}

.search-input:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.065);
}

.search-input:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, transparent);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

select.search-input {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 16px,
    calc(100% - 12px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select.search-input option {
  color: var(--ink);
  background: var(--panel);
}

.range {
  accent-color: var(--accent);
}

.view-host {
  min-height: 0;
  overflow: auto;
  position: relative;
}

.tab-content {
  height: 100%;
  position: relative;
}

.graph-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    radial-gradient(circle at 68% 34%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 36%),
    rgba(8, 10, 11, 0.8);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

#graphSvg,
.graph-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--ink);
  stroke: none;
}

#graphSvg line,
#graphSvg path,
#graphSvg circle,
#graphSvg rect {
  vector-effect: non-scaling-stroke;
}

#graphSvg .node-label {
  paint-order: stroke;
  stroke: rgba(8, 10, 11, 0.94);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.float-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 8;
  display: grid;
  gap: 6px;
}

.float-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(16, 19, 21, 0.88);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-weight: 800;
}

.float-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: rgba(255, 255, 255, 0.07);
}

.filter-row {
  position: absolute;
  top: 14px;
  left: 60px;
  right: 430px;
  z-index: 8;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.float-legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 8;
  width: 250px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(16, 19, 21, 0.92);
  box-shadow: var(--shadow);
}

.leg-title,
.section-kicker,
.eyebrow {
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.leg-title {
  margin-bottom: 10px;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.leg-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  width: min(410px, 90vw);
  height: 100%;
  border-left: 1px solid var(--line-strong);
  background: rgba(16, 19, 21, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 220ms ease;
}

.detail-panel.open {
  transform: translateX(0);
}

.dp-header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dp-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  cursor: pointer;
}

.dp-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.dp-body {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.mental-layout,
.stories-layout,
.validation-layout,
.heatmap-layout,
.crash-layout {
  height: 100%;
  display: grid;
  min-width: 0;
}

.mental-layout,
.crash-layout {
  grid-template-columns: 380px minmax(0, 1fr);
}

.stories-layout,
.validation-layout,
.heatmap-layout {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.list-pane,
.wide-pane,
.side-pane,
.detail-pane,
.crash-list-col,
.crash-detail-col,
.cooc-main,
.cooc-side {
  min-width: 0;
  overflow: auto;
  padding: 24px;
}

.list-pane,
.side-pane,
.crash-detail-col,
.cooc-side {
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.list-pane,
.crash-list-col {
  border-left: none;
  border-right: 1px solid var(--line);
}

.detail-pane,
.wide-pane,
.cooc-main,
.crash-list-col {
  background: var(--bg);
}

.section-header {
  margin-bottom: 16px;
}

.section-header.compact {
  margin-top: 22px;
}

.section-header h2,
.detail-heading h2 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 700;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  max-width: 680px;
}

.record-list,
.crash-grid {
  display: grid;
  gap: 8px;
}

.record-card,
.crash-card {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.record-card:hover,
.record-card.active,
.crash-card:hover,
.crash-card.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--panel-3);
}

.record-id {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.record-story {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.record-text,
.card-sub,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.detail-title {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.confidence {
  min-width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.context-cell,
.dashboard-card,
.stat-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.context-cell span,
.model-grid span,
.sb-label,
.dashboard-label {
  display: block;
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
}

.context-cell strong,
.model-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.actor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.actor-card,
.story-card,
.card,
.claim-card,
.actor-mini {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.actor-card {
  padding: 14px;
}

.actor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.actor-head h3 {
  margin: 0;
  font-size: 18px;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.model-grid div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.timeline-col {
  min-height: 120px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.timeline-title {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.timeline-item {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.timeline-item:first-of-type {
  border-top: none;
}

.timeline-item strong {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item span,
.timeline-empty {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.badge-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.badge-human_behavior,
.badge-rider_behavior {
  color: var(--green);
  background: rgba(67, 217, 173, 0.12);
}

.badge-driver_behavior {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.12);
}

.badge-pedestrian_behavior {
  color: var(--green);
  background: rgba(67, 217, 173, 0.12);
}

.badge-infrastructure {
  color: var(--amber);
  background: rgba(240, 180, 41, 0.12);
}

.badge-environment {
  color: var(--cyan);
  background: rgba(108, 199, 217, 0.12);
}

.badge-vehicle_context,
.badge-vehicle_factors {
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
}

.badge-post_crash {
  color: #fb7185;
  background: rgba(251, 113, 133, 0.12);
}

.badge-outcome {
  color: var(--red);
  background: rgba(255, 107, 95, 0.12);
}

.badge-evidence_source {
  color: #a3e635;
  background: rgba(163, 230, 53, 0.12);
}

.status-confirmed_by_cris {
  color: var(--green);
  background: rgba(67, 217, 173, 0.1);
}

.status-narrative_only {
  color: var(--amber);
  background: rgba(240, 180, 41, 0.1);
}

.status-contradicts_cris {
  color: #fb7185;
  background: rgba(251, 113, 133, 0.13);
}

.status-duplicate_of_cris,
.status-unknown {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.role-responsible {
  color: #fb7185;
  background: rgba(251, 113, 133, 0.14);
}

.role-affected {
  color: var(--cyan);
  background: rgba(108, 199, 217, 0.12);
}

.role-witness_described {
  color: #a3e635;
  background: rgba(163, 230, 53, 0.1);
}

.role-uncertain {
  color: var(--muted);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.story-card {
  padding: 16px;
  cursor: pointer;
}

.story-card:hover,
.story-card.active {
  border-color: color-mix(in srgb, var(--accent) 44%, transparent);
  background: var(--panel-3);
}

.story-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.story-count {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
}

.story-pct {
  color: var(--muted);
  font-family: var(--mono);
}

.story-card h3 {
  margin: 10px 0 4px;
  font-size: 16px;
}

.story-id {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}

.condition-list {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.condition-list span,
.metric-row {
  color: var(--muted);
  font-size: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row strong {
  color: var(--ink);
  font-family: var(--mono);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-grid.mini {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.dashboard-value,
.sb-val {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
}

.claim-card {
  padding: 12px;
  margin-bottom: 8px;
}

.claim-card.suppressed {
  opacity: 0.66;
}

.claim-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.claim-meta,
.claim-reason {
  margin-top: 5px;
  color: var(--faint);
  font-size: 11px;
}

.claim-evidence {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.safety-summary {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent-soft), rgba(255, 255, 255, 0.025));
}

.summary-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.summary-head strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.summary-text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.summary-chain {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.summary-step {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.summary-step span {
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
}

.summary-step strong {
  color: var(--muted);
  font-size: 12px;
}

.actor-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.actor-mini {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.actor-mini strong {
  color: var(--ink);
}

.actor-mini span {
  color: var(--muted);
  font-size: 12px;
}

.narr-text {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.rail-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 8px 0;
  color: var(--muted);
  text-align: left;
}

.rail-row strong {
  color: var(--ink);
  font-family: var(--mono);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.cooc-summary,
.cooc-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.cooc-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.cooc-slider {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.cooc-slider strong {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}

.cooc-slider input {
  width: 100%;
  accent-color: var(--accent);
}

.cooc-stat,
.cooc-metrics div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.cooc-stat strong,
.cooc-metrics strong {
  display: block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 20px;
}

.cooc-stat span,
.cooc-metrics span {
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
}

.hm-wrap {
  position: relative;
  min-height: 620px;
  overflow: auto;
  display: flex;
  justify-content: center;
}

.hm-wrap svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  stroke: none;
}

.hm-wrap svg text {
  fill: var(--muted);
  stroke: none;
  font-family: var(--sans);
  font-weight: 700;
}

.cooc-axis-label {
  transition: opacity 140ms ease, font-weight 140ms ease;
  opacity: 0.85;
}

.cooc-svg.has-highlight .cooc-axis-label {
  opacity: 0.32;
}

.cooc-svg.has-highlight .cooc-axis-label.highlighted {
  opacity: 1;
  font-weight: 800;
}

.cooc-svg rect[data-pair-cell] {
  cursor: pointer;
  transition: opacity 140ms ease, stroke 140ms ease, filter 140ms ease;
}

.cooc-svg rect[data-pair-cell].related {
  stroke: color-mix(in srgb, var(--accent) 34%, transparent);
  stroke-width: 1.4;
}

.cooc-svg rect[data-pair-cell]:hover,
.cooc-svg rect[data-pair-cell].selected {
  stroke: var(--ink);
  stroke-width: 2;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 62%, transparent));
}

.cooc-tip {
  position: absolute;
  z-index: 12;
  display: grid;
  gap: 4px;
  max-width: 310px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(8, 10, 11, 0.94);
  box-shadow: var(--shadow);
  color: var(--ink);
  pointer-events: none;
}

.cooc-tip strong {
  font-size: 12px;
  line-height: 1.25;
}

.cooc-tip span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.cooc-axis-label {
  font-size: 11px;
  paint-order: stroke;
  stroke: rgba(8, 10, 11, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.cooc-pair-list {
  display: grid;
  gap: 8px;
}

.cooc-pair {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: left;
  cursor: pointer;
}

.cooc-pair:hover,
.cooc-pair.active {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  background: var(--accent-soft);
}

.cooc-chain {
  margin: 12px 0;
}

.cooc-pair strong {
  color: var(--accent);
  font-family: var(--mono);
}

.mental-case-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.mental-case-toolbar .search-input:first-child {
  grid-column: 1 / -1;
}

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent);
}

.active-filter button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.view {
  min-height: 100%;
  padding: 22px;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-header h2,
.intro-copy h2,
.inspector h2 {
  margin: 6px 0 0;
  font-size: 25px;
  line-height: 1.08;
  letter-spacing: 0;
}

.view-header p,
.intro-copy p,
.muted {
  color: var(--muted);
  line-height: 1.52;
}

.view-header p {
  max-width: 760px;
  margin: 8px 0 0;
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.case-card,
.pathway-row,
.dataset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.026));
}

.metric-card {
  padding: 16px;
  min-height: 102px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.bar-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 2fr) 78px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--amber));
}

.bar-value {
  font-family: var(--mono);
  color: var(--ink);
  text-align: right;
}

.graph-shell,
.matrix-shell,
.flow-shell {
  height: calc(100vh - 178px);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    rgba(12, 15, 16, 0.82);
  background-size: 34px 34px;
  position: relative;
  overflow: hidden;
}

.graph-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 13, 14, 0.88);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.tool-group label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.tool-group input {
  width: 112px;
}

.graph-shell svg,
.matrix-shell svg,
.flow-shell svg {
  width: 100%;
  height: 100%;
}

.node text {
  paint-order: stroke;
  stroke: rgba(8, 10, 11, 0.85);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.tooltip {
  position: fixed;
  z-index: 40;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(12, 15, 16, 0.96);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.pathway-list {
  display: grid;
  gap: 8px;
}

.pathway-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 140px 72px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
}

.pathway-row:hover,
.case-card:hover,
.dataset-card:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.065);
}

.path-count {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

.chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chain-node {
  max-width: 180px;
  overflow: hidden;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}

.chain-arrow {
  color: var(--faint);
  font-family: var(--mono);
}

.case-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.case-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 180px)) auto;
  gap: 8px;
}

.case-toolbar.mental-case-toolbar {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.case-toolbar.mental-case-toolbar .search-input:first-child {
  grid-column: 1 / -1;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
}

.case-card {
  padding: 13px;
  cursor: pointer;
}

.case-card h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.case-card p,
.narrative-box {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.52;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 0;
}

.secondary-btn,
.primary-btn {
  min-height: 36px;
  padding: 0 14px;
  font-weight: 800;
  font-size: 12px;
}

.secondary-btn {
  border-color: var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
}

.primary-btn {
  color: #07100d;
  background: var(--accent);
}

.inspector-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: rgba(16, 19, 21, 0.96);
  border-bottom: 1px solid var(--line);
}

.inspector h2 {
  max-width: 260px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.inspector-body {
  padding: 18px;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section h3 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 12px;
}

.kv span:nth-child(odd) {
  color: var(--faint);
}

.narrative-box {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.intro-backdrop,
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(14px);
}

.intro-backdrop.visible,
.palette-backdrop.visible {
  display: flex;
}

.intro-modal {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(430px, 1.25fr);
  width: min(1080px, 96vw);
  max-height: min(760px, 92vh);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intro-visual {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(150deg, rgba(67, 217, 173, 0.26), rgba(8, 10, 11, 0.35) 42%, rgba(240, 180, 41, 0.16) 68%, rgba(255, 107, 95, 0.16));
  background-size: 34px 34px, 34px 34px, auto;
  isolation: isolate;
}

.intro-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(8, 10, 11, 0.48), transparent 22%, transparent 78%, rgba(8, 10, 11, 0.42)),
    linear-gradient(0deg, rgba(8, 10, 11, 0.36), transparent 32%, transparent 70%, rgba(8, 10, 11, 0.28));
}

.intro-map {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 520px;
  z-index: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.radar-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 1px;
}

.radar-ring:nth-child(2) {
  stroke: rgba(67, 217, 173, 0.1);
  stroke-dasharray: 4, 12;
  animation: radarRotate 25s linear infinite;
  transform-origin: 260px 260px;
}

.radar-ring:nth-child(3) {
  stroke: rgba(240, 180, 41, 0.08);
  stroke-dasharray: 8, 20;
  animation: radarRotateReverse 35s linear infinite;
  transform-origin: 260px 260px;
}

.radar-axis {
  stroke: rgba(255, 255, 255, 0.035);
  stroke-width: 1px;
  stroke-dasharray: 2, 8;
}

.radar-sweep {
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.72;
  transform-origin: 260px 260px;
  animation: radarRotate 5s linear infinite;
  filter: drop-shadow(0 0 6px var(--accent));
}

.trajectory-path {
  fill: none;
  stroke-width: 2px;
  stroke-linecap: round;
  opacity: 0.38;
}

.trajectory-path.path-a {
  stroke: var(--green);
  filter: drop-shadow(0 0 3px var(--green));
}

.trajectory-path.path-b {
  stroke: var(--amber);
  filter: drop-shadow(0 0 3px var(--amber));
}

.trajectory-path.path-c {
  stroke: var(--cyan);
  filter: drop-shadow(0 0 3px var(--cyan));
}

.trajectory-path.path-d {
  stroke: var(--red);
  filter: drop-shadow(0 0 3px var(--red));
}

.flow-particle-a { filter: drop-shadow(0 0 8px var(--green)); }
.flow-particle-b { filter: drop-shadow(0 0 8px var(--amber)); }
.flow-particle-c { filter: drop-shadow(0 0 8px var(--cyan)); }
.flow-particle-d { filter: drop-shadow(0 0 8px var(--red)); }

.collision-ring-outer {
  fill: rgba(239, 68, 68, 0.16);
  stroke: var(--red);
  stroke-width: 1.5;
  transform-origin: 260px 260px;
  animation: pulseRingGlow 1.8s cubic-bezier(0.215, 0.610, 0.355, 1.000) infinite;
}

.collision-ring-inner {
  fill: #ff4a4a;
  filter: drop-shadow(0 0 10px #ff3b3b);
}

.factor-chip {
  position: absolute;
  z-index: 2;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(16, 19, 21, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
  cursor: default;
}

.factor-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.45);
}

.chip-a {
  left: 15%;
  top: 26%;
  border-left: 3px solid var(--green);
}
.chip-a:hover {
  border-color: var(--green);
}

.chip-b {
  right: 13%;
  top: 22%;
  border-left: 3px solid var(--cyan);
}
.chip-b:hover {
  border-color: var(--cyan);
}

.chip-c {
  left: 12%;
  bottom: 21%;
  border-left: 3px solid var(--amber);
}
.chip-c:hover {
  border-color: var(--amber);
}

.chip-d {
  right: 18%;
  bottom: 17%;
  border-left: 3px solid var(--red);
}
.chip-d:hover {
  border-color: var(--red);
}

.signal-card {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 4px;
  min-width: 120px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(16, 19, 21, 0.8);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  transition: transform 200ms ease, border-color 200ms ease;
}

.signal-card:hover {
  transform: scale(1.04);
}

.signal-card .metric {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
}

.signal-card span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.signal-a {
  top: 14%;
  left: 12%;
  border-top: 3px solid var(--accent);
}
.signal-a:hover {
  border-color: var(--accent);
}

.signal-b {
  top: 44%;
  right: 10%;
  border-top: 3px solid var(--amber);
}
.signal-b:hover {
  border-color: var(--amber);
}

.signal-c {
  bottom: 14%;
  left: 18%;
  border-top: 3px solid var(--cyan);
}
.signal-c:hover {
  border-color: var(--cyan);
}

@keyframes radarRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes radarRotateReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes pulseRingGlow {
  0% {
    transform: scale(0.85);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes scanBeam {
  0%,
  100% {
    transform: translateX(-72px) rotate(24deg);
    opacity: 0.2;
  }
  50% {
    transform: translateX(72px) rotate(24deg);
    opacity: 0.95;
  }
}

@keyframes pulseRing {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.74);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

@keyframes flowDot {
  0% {
    transform: translate(-42px, 34px);
    opacity: 0;
  }
  15%,
  80% {
    opacity: 1;
  }
  100% {
    transform: translate(86px, -48px);
    opacity: 0;
  }
}

.signal-card .metric {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
}

.signal-card span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.signal-a {
  top: 14%;
  left: 12%;
}

.signal-b {
  top: 44%;
  right: 10%;
}

.signal-c {
  bottom: 14%;
  left: 18%;
}

.intro-copy {
  overflow: auto;
  padding: 36px;
}

.intro-copy h2 {
  font-size: 34px;
}

.privacy-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid rgba(67, 217, 173, 0.25);
  border-radius: 8px;
  color: var(--ink);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
}

.dataset-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.dataset-card {
  padding: 16px;
  cursor: pointer;
}

.dataset-card.active {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: var(--accent-soft);
}

.dataset-card h3 {
  margin: 0;
  font-size: 18px;
}

.dataset-card p {
  min-height: 54px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.dataset-card .stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.dataset-card .stats div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.dataset-card .stats strong {
  display: block;
  font-family: var(--mono);
}

.dataset-card .stats span {
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.intro-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.palette {
  width: min(720px, 94vw);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.palette input {
  width: 100%;
  height: 58px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0 18px;
  outline: none;
  font-size: 16px;
}

.palette-results {
  max-height: 420px;
  overflow: auto;
  padding: 8px;
}

.palette-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.palette-item:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.loading-panel {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  color: var(--muted);
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  z-index: 120;
  bottom: 18px;
  left: 50%;
  max-width: 520px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
  color: var(--ink);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.delta-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 110px 110px;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.delta-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .header-stats {
    max-width: 100%;
  }

  .stat-pill {
    min-height: 28px;
    padding: 4px 8px;
  }

  .filter-row {
    right: 18px;
  }

  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    inset: 114px 0 0 auto;
    z-index: 60;
    width: min(390px, 94vw);
    transform: translateX(100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .inspector.open {
    transform: translateX(0);
  }

  .cooc-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  body.modal-open {
    overflow: hidden;
  }

  html,
  body,
  .app-shell {
    height: auto;
    min-height: 100%;
  }

  .app-shell {
    grid-template-rows: auto auto auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .top-actions,
  .header-stats {
    justify-content: flex-start;
    max-width: 100%;
  }

  .filter-row {
    position: static;
    padding: 14px 14px 0 60px;
  }

  .float-legend {
    position: static;
    width: auto;
    margin: 14px;
  }

  .graph-canvas {
    min-height: 620px;
  }

  .workspace {
    display: block;
  }

  .filter-rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .metric-grid,
  .dashboard-grid,
  .compare-grid,
  .dataset-cards,
  .intro-modal {
    grid-template-columns: 1fr;
  }

  .heatmap-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .cooc-main,
  .cooc-side {
    max-height: none;
    padding: 18px;
  }

  .cooc-side {
    border-top: 1px solid var(--line);
    border-left: none;
  }

  .cooc-controls {
    grid-template-columns: 1fr;
  }

  .hm-wrap {
    min-height: 470px;
  }

  .intro-backdrop {
    align-items: flex-start;
    justify-content: center;
    padding: 40px 22px;
  }

  .intro-modal {
    width: min(100%, 420px);
    max-height: none;
    overflow: visible;
  }

  .intro-visual {
    min-height: 276px;
  }

  .factor-chip {
    padding: 6px 8px;
    font-size: 10px;
  }

  .ring-b {
    width: 240px;
    height: 240px;
  }

  .intro-copy {
    overflow: visible;
    padding: 32px 24px;
  }

  .intro-copy h2 {
    font-size: 34px;
    line-height: 1.08;
  }

  .case-toolbar {
    grid-template-columns: 1fr;
  }

  .pathway-row,
  .delta-row {
    grid-template-columns: 1fr;
  }
}
