:root {
  --bg: #e8e5de;
  --paper: #f6f3ec;
  --paper-strong: #fffdf8;
  --ink: #17201e;
  --muted: #6d756f;
  --rule: #c8c5bc;
  --accent: #d35238;
  --accent-deep: #993620;
  --teal: #176b69;
  --teal-soft: #d8e9e5;
  --gold: #b68a37;
  --shadow: 0 18px 45px rgba(34, 43, 39, 0.13);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(211, 82, 56, 0.08), transparent 25%),
    linear-gradient(125deg, #ebe8e1, #e0ded8);
  font-family: var(--sans);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.operation-overlay {
  position: fixed;
  z-index: 10;
  top: 88px;
  right: 18px;
  width: min(360px, calc(100vw - 36px));
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

body.operation-busy .operation-overlay {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.operation-card {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  border: 1px solid rgba(121, 126, 120, 0.9);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.97);
  box-shadow: 0 12px 32px rgba(25, 34, 31, 0.22);
}

.operation-card strong {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
}

.operation-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.operation-spinner {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border: 3px solid rgba(23, 107, 105, 0.2);
  border-top-color: var(--teal);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: operation-spin 750ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .operation-overlay { transition: none; }
  .operation-spinner { animation-duration: 1.8s; }
}

@media (max-width: 840px) {
  .operation-overlay {
    top: 84px;
    right: 12px;
    width: calc(100vw - 24px);
  }
}

.masthead {
  height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  border-bottom: 1px solid #aaa9a2;
  background: rgba(246, 243, 236, 0.94);
  backdrop-filter: blur(14px);
}

.masthead h1 {
  margin: 2px 0 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead h1 i { color: var(--accent); font-weight: 400; }

.masthead-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.masthead-identity > div {
  min-width: 0;
}

.home-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.home-link:hover {
  background: var(--paper-strong);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.investigation-select {
  flex: 0 1 280px;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--paper-strong);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 12.5px;
  max-width: 280px;
  cursor: pointer;
}

.investigation-select:focus {
  outline: none;
  border-color: var(--accent);
}

.eyebrow,
.field > span,
.section-heading,
.database-stats {
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow { color: var(--muted); }
.eyebrow.accent { color: var(--accent-deep); }

.database-stats {
  color: var(--muted);
  text-align: center;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 7px;
}

button {
  min-height: 32px;
  padding: 6px 11px;
  color: var(--ink);
  border: 1px solid #b5b2aa;
  border-radius: 3px;
  background: rgba(255, 253, 248, 0.85);
  font-size: 11px;
  font-weight: 600;
  transition: border-color 120ms, background 120ms, transform 120ms;
}

button:hover:not(:disabled) {
  border-color: #777d78;
  background: #fff;
}

button:active:not(:disabled) { transform: translateY(1px); }

button.primary {
  color: white;
  border-color: var(--teal);
  background: var(--teal);
}

button.primary:hover:not(:disabled) {
  border-color: #0d514f;
  background: #0d5b59;
}

button.quiet { background: transparent; }
button.full { width: 100%; }

.workspace {
  --search-sidebar-width: 304px;
  --detail-sidebar-width: 326px;
  height: calc(100% - 76px);
  display: grid;
  grid-template-columns: var(--search-sidebar-width) minmax(0, 1fr) var(--detail-sidebar-width);
  transition: grid-template-columns 180ms ease;
}

.sidebar {
  min-height: 0;
  min-width: 0;
  padding: 19px 17px 30px;
  overflow-y: auto;
  background: rgba(246, 243, 236, 0.96);
  scrollbar-width: thin;
}

.search-sidebar { border-right: 1px solid var(--rule); }
.detail-sidebar { border-left: 1px solid var(--rule); }

.workspace.search-sidebar-collapsed { --search-sidebar-width: 0px; }
.workspace.detail-sidebar-collapsed { --detail-sidebar-width: 0px; }

.workspace.search-sidebar-collapsed .search-sidebar,
.workspace.detail-sidebar-collapsed .detail-sidebar {
  visibility: hidden;
  padding-right: 0;
  padding-left: 0;
  overflow: hidden;
  border-width: 0;
  pointer-events: none;
}

.sidebar-toggle[aria-expanded="false"] {
  color: var(--accent-deep);
  border-color: var(--accent);
}

.panel-intro h2,
.detail-sidebar h2,
.canvas-empty h2 {
  margin: 5px 0 8px;
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1;
  letter-spacing: -0.025em;
}

.panel-intro p,
.panel-copy,
.canvas-empty p,
.inspector-placeholder p,
dialog p {
  margin: 0 0 15px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.45;
}

.stack { display: grid; gap: 9px; }
.stack.compact { gap: 8px; padding-top: 11px; }

.field {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 5px;
}

.field > span { color: var(--muted); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-row.three { grid-template-columns: 68px 1fr 1fr; }
.field-row .span-two { grid-column: span 2; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  border: 1px solid #aaa9a2;
  border-radius: 3px;
  outline: none;
  background: var(--paper-strong);
  font-size: 12px;
}

input, select { height: 36px; padding: 0 9px; }
textarea { padding: 9px; resize: vertical; line-height: 1.4; }

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(23, 107, 105, 0.13);
}

.autocomplete-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 3px);
  right: 0;
  left: 0;
  display: none;
  max-height: 230px;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid #9d9e98;
  border-radius: 3px;
  background: var(--paper-strong);
  box-shadow: 0 14px 30px rgba(32, 40, 37, 0.2);
}

.autocomplete-menu.open { display: grid; }

.autocomplete-option {
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option.active {
  background: var(--teal-soft);
}

.autocomplete-option b {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option small {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.search-field input { height: 42px; font-size: 13px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 0 7px;
  color: var(--muted);
}

.section-heading::after {
  height: 1px;
  flex: 1;
  order: 1;
  content: "";
  background: var(--rule);
}

.section-heading span:last-child { order: 2; }

.record-list {
  max-height: 292px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 5px;
  border-bottom: 1px solid #d7d3ca;
}

.record-main {
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  text-align: left;
}

.record-main:hover { background: transparent !important; }
.record-main b, .record-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-main b { font-family: var(--serif); font-size: 14px; }
.record-main small { margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }

.record-add {
  width: 27px;
  min-height: 27px;
  align-self: center;
  padding: 0;
  border-radius: 50%;
}

.empty-copy {
  margin: 7px 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.4;
}

.control-section {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
}

.control-section summary {
  padding: 13px 0 4px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
}

.graph-desk {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(38, 51, 47, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 51, 47, 0.035) 1px, transparent 1px),
    #deddd7;
  background-size: 28px 28px;
}

#graph,
#graph-3d {
  position: absolute;
  inset: 47px 0 104px;
}

.graph-toolbar {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  height: 47px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid rgba(151, 151, 145, 0.8);
  background: rgba(239, 237, 231, 0.9);
  backdrop-filter: blur(8px);
}

.tool-group { display: flex; gap: 5px; }
.tool-group:last-child { justify-content: flex-end; }
.tool-group button { min-height: 29px; padding: 4px 9px; background: rgba(255,255,255,0.45); }
.tool-group select { width: 130px; height: 29px; font-size: 10px; }

.canvas-empty {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(380px, 75%);
  transform: translate(-50%, -55%);
  text-align: center;
  pointer-events: none;
}

.canvas-empty.hidden { display: none; }
.orbital-mark { display: block; color: var(--accent); font-size: 58px; font-weight: 200; }
.orbital-mark.small { font-size: 34px; }

.relationship-legend {
  position: absolute;
  z-index: 4;
  top: 57px;
  right: 10px;
  width: 178px;
  padding: 7px 9px;
  border: 1px solid rgba(151, 151, 145, 0.82);
  border-radius: 4px;
  background: rgba(250, 248, 242, 0.92);
  box-shadow: 0 8px 22px rgba(34, 43, 39, 0.1);
  backdrop-filter: blur(7px);
}

.relationship-legend summary {
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.legend-items { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 8px; margin: 8px 0; }
.legend-item { position: relative; padding-left: 16px; color: var(--muted); font-size: 8px; }
.legend-item::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 2px;
  content: "";
  transform: translateY(-50%);
  background: #8a918c;
}
.legend-item.affiliation::before { background: #26736f; }
.legend-item.funding::before { background: #4f7d45; }
.legend-item.governance::before { background: #745b91; }
.legend-item.advocacy::before { background: #9a762c; }
.legend-item.investigation::before { background: repeating-linear-gradient(90deg, #356b9a 0 4px, transparent 4px 6px); }
.legend-item.criticism::before { background: repeating-linear-gradient(90deg, #b64632 0 4px, transparent 4px 6px); }
.legend-item.legal::before { background: repeating-linear-gradient(90deg, #b16a2d 0 2px, transparent 2px 4px); }
.legend-item.adverse_action::before { background: repeating-linear-gradient(90deg, #8f2f38 0 2px, transparent 2px 4px); }
.relationship-legend small { display: block; color: var(--muted); font-size: 8px; line-height: 1.35; }

.selection-dock {
  position: absolute;
  z-index: 5;
  right: 12px;
  bottom: 34px;
  left: 12px;
  min-height: 61px;
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 9px 11px;
  border: 1px solid #a9aaa5;
  border-radius: 5px;
  background: rgba(252, 250, 245, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.selection-summary { min-width: 88px; }
.selection-summary span, .selection-summary strong { display: block; }
.selection-summary strong { margin-top: 3px; font-family: var(--serif); font-size: 12px; }
.selection-chips { display: flex; gap: 5px; overflow-x: auto; }

.selection-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 20px;
  color: #164f4d;
  background: var(--teal-soft);
  font-size: 10px;
}

.selection-chip button {
  width: 16px;
  min-height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
}

.selection-actions { display: flex; gap: 5px; }
.selection-actions button { white-space: nowrap; }

.status-bar {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  height: 27px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--muted);
  border-top: 1px solid #b9b8b1;
  background: rgba(231, 229, 223, 0.96);
  font-size: 10px;
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.status-bar.busy .status-dot { background: var(--gold); animation: pulse 700ms infinite alternate; }
.status-bar.error .status-dot { background: var(--accent); }
#visible-stats { margin-left: auto; }

@keyframes pulse { to { opacity: 0.3; } }

.tabs {
  position: sticky;
  z-index: 2;
  top: -19px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: -19px -17px 19px;
  background: var(--paper);
}

.tab {
  min-height: 43px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tab.active {
  color: var(--accent-deep);
  border-bottom: 2px solid var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.inspector-placeholder { padding: 60px 14px 0; text-align: center; }

.record-heading {
  margin-bottom: 13px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--rule);
}

.record-heading h2 { overflow-wrap: anywhere; }
.record-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { padding: 3px 6px; color: #245654; border: 1px solid #9bb6b1; border-radius: 20px; font-size: 9px; }
.badge.edge { color: #823524; border-color: #d1a092; }

.record-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 15px;
}

.record-table { margin: 0; }
.record-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #dedad1;
}
.record-row dt { color: var(--muted); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }
.record-row dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.45; white-space: pre-wrap; }

.endpoint-button {
  width: 100%;
  margin: 4px 0;
  text-align: left;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.analysis-grid button { min-height: 65px; text-align: left; }
.analysis-grid b, .analysis-grid span { display: block; }
.analysis-grid b { font-family: var(--serif); font-size: 13px; }
.analysis-grid span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.button-stack { display: grid; gap: 6px; }

.analysis-result pre {
  max-height: 300px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--rule);
  background: #eeece6;
  font-size: 9px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.saved-list { display: grid; gap: 5px; margin-top: 8px; }
.saved-record { display: grid; grid-template-columns: 1fr auto; gap: 5px; }
.saved-record button:first-child { overflow: hidden; text-overflow: ellipsis; text-align: left; white-space: nowrap; }

dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #9e9f98;
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 0 28px 90px rgba(20, 26, 24, 0.35);
}
dialog::backdrop { background: rgba(26, 31, 29, 0.52); backdrop-filter: blur(3px); }
.dialog-card { position: relative; display: grid; gap: 12px; padding: 27px; }
.dialog-card h2 { margin: 0; font-family: var(--serif); font-size: 28px; }
.dialog-close { position: absolute; top: 10px; right: 10px; width: 30px; padding: 0; border: 0; background: transparent; font-size: 21px; }

.toast-region { position: fixed; z-index: 20; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { max-width: 350px; padding: 11px 14px; color: white; border-radius: 4px; background: #213c39; box-shadow: var(--shadow); font-size: 11px; }
.toast.error { background: #8e3827; }

dialog.adjust-graph-dialog {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid #9e9f98;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 28px 90px rgba(20, 26, 24, 0.35);
}

.adjust-graph-card {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  padding: 24px 26px;
  gap: 10px;
}

.adjust-graph-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
}

.adjust-graph-card p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.adjust-controls-scroll {
  overflow-y: auto;
  padding-right: 6px;
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adjust-group {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 10px 14px 14px;
  margin: 0;
  background: rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adjust-group legend {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--teal);
  padding: 0 5px;
}

.adjust-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.adjust-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.adjust-label-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.adjust-label-info label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.info-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.info-btn {
  background: transparent;
  border: 0;
  padding: 2px 3px;
  margin: 0;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
  transition: color 0.15s ease, transform 0.1s ease;
}

.info-btn:hover,
.info-btn:focus-visible,
.info-wrapper.active .info-btn {
  color: var(--teal);
}

.info-wrapper.active .info-btn {
  transform: scale(1.15);
}

.info-bubble {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  padding: 7px 10px;
  font-size: 11px;
  line-height: 1.4;
  color: #f7f5f0;
  background: #172421;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(15, 22, 20, 0.4);
  z-index: 50;
  pointer-events: none;
}

.info-bubble::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 8px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #172421 transparent;
}

.info-wrapper:hover .info-bubble,
.info-wrapper:focus-within .info-bubble,
.info-wrapper.active .info-bubble {
  display: block;
}

.adjust-val {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
  background: var(--teal-soft);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(23, 107, 105, 0.2);
}

.adjust-field input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
  cursor: pointer;
  height: 6px;
  margin: 0;
}

.adjust-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}

.adjust-actions-right {
  display: flex;
  gap: 8px;
}

.ghost-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 6px 10px;
}

.ghost-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  color: var(--accent-deep);
  border-color: var(--rule);
}

@media (max-width: 1280px) {
  .graph-toolbar { display: flex; gap: 8px; overflow-x: auto; }
  .tool-group { flex: 0 0 auto; }
  .tool-group.centered { margin: 0 auto; }
}

@media (max-width: 1120px) {
  .workspace {
    --search-sidebar-width: 270px;
    --detail-sidebar-width: 290px;
  }
  .database-stats { display: none; }
  .masthead h1 { font-size: 22px; }
  .investigation-select { max-width: 240px; }
  .selection-actions button { padding: 5px 7px; font-size: 9px; }
}

@media (max-width: 840px) {
  html, body { overflow: auto; }
  .masthead { position: sticky; z-index: 10; top: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
  .database-stats { display: none; }
  .masthead-identity > div { display: none; }
  .home-link span { display: none; }
  .home-link { padding: 6px 9px; }
  .investigation-select { max-width: min(52vw, 250px); }
  .header-actions button:not(.primary) { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 76px); grid-template-columns: 1fr; }
  .sidebar { max-height: none; border: 0; }
  .workspace.search-sidebar-collapsed .search-sidebar,
  .workspace.detail-sidebar-collapsed .detail-sidebar { display: none; }
  .search-sidebar { order: 2; }
  .graph-desk { order: 1; height: 72vh; min-height: 540px; }
  .detail-sidebar { order: 3; }
  .selection-dock { grid-template-columns: 1fr; }
  .selection-actions { overflow-x: auto; }
}

/* 3D WebGL Visualization & Controls */
.dimension-btn {
  font-weight: 700 !important;
  font-size: 11px !important;
  letter-spacing: 0.3px;
  border-radius: 4px;
  padding: 4px 10px !important;
  transition: all 0.15s ease;
}

.dimension-btn.active {
  background: #26736f !important;
  color: #ffffff !important;
  border-color: #174e4c !important;
  box-shadow: 0 1px 4px rgba(38, 115, 111, 0.35);
}

.graph-canvas-3d {
  position: absolute;
  inset: 47px 0 104px;
  width: 100%;
  height: calc(100% - 151px);
  outline: none;
}

.graph-3d-hud {
  position: absolute;
  bottom: 112px;
  left: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.graph-3d-hud .hud-pill-group {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-axis-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  padding: 5px 7px;
  border: 1px solid rgba(151, 151, 145, 0.55);
  border-radius: 6px;
  background: rgba(247, 244, 237, 0.92);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.hud-axis-title {
  margin-right: 2px;
  color: #5f6662;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.hud-axis-group {
  display: inline-grid;
  grid-template-columns: 15px 22px 22px;
  align-items: center;
  overflow: hidden;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.hud-axis-group > span {
  text-align: center;
  font-size: 9px;
  font-weight: 800;
}

.hud-axis-group button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-left: 1px solid currentColor;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.68);
  color: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 20px;
}

.hud-axis-group button:hover { background: #ffffff; }
.hud-axis-group.axis-x { color: #b64632; }
.hud-axis-group.axis-y { color: #26736f; }
.hud-axis-group.axis-z { color: #356b9a; }

.graph-3d-hud .hud-btn {
  background: rgba(247, 244, 237, 0.92);
  border: 1px solid rgba(151, 151, 145, 0.8);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  color: #17201e;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
  transition: all 0.15s ease;
}

.graph-3d-hud .hud-btn:hover {
  background: #ffffff;
  border-color: #26736f;
  color: #26736f;
}

.graph-3d-hud .hud-btn.active {
  background: #26736f;
  border-color: #174e4c;
  color: #ffffff;
}

.graph-3d-hud .hud-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 4px 10px;
  background: rgba(247, 244, 237, 0.88);
  border: 1px solid rgba(151, 151, 145, 0.4);
  border-radius: 6px;
  font-size: 10px;
  color: #5f6662;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.graph-3d-hud .hud-hint b {
  color: #17201e;
}
