/* ─────────────────────────────────────────────────────────────────────────
   The Body by Jude — Human Atlas
   A dark, print-like interface around a full-body dissection model.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #060a0e;
  --bg-soft: #080d12;
  --panel: #0b1218;
  --panel-raised: #0f1820;
  --panel-glass: rgba(11, 18, 24, 0.86);
  --line: rgba(166, 195, 210, 0.12);
  --line-strong: rgba(166, 195, 210, 0.22);
  --text: #e9eff3;
  --text-soft: #c4d1d9;
  --muted: #8ba0ad;
  --faint: #5f7481;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(94, 234, 212, 0.12);
  --accent-line: rgba(94, 234, 212, 0.32);
  --danger: #f28b82;
  --ok: #63d69d;
  --radius: 14px;
  --radius-sm: 9px;
  --font-ui: "Segoe UI", "Inter", "SF Pro Text", system-ui, -apple-system, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(94, 234, 212, 0.28); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(166, 195, 210, 0.24) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(166, 195, 210, 0.18);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

svg { display: block; }
kbd {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ───────────────────────────── shell ───────────────────────────── */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  position: relative;
  z-index: 30;
  flex: 0 0 64px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent),
    var(--bg-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
  text-decoration: none;
  color: var(--accent);
}
.brand-mark { width: 30px; height: 30px; opacity: 0.95; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.16em;
  color: var(--text);
  text-transform: uppercase;
}
.brand-sub {
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--faint);
}

.search-trigger {
  flex: 1 1 auto;
  max-width: 500px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--faint);
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.search-trigger:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
}
.search-trigger svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  flex: 0 0 auto;
}
.search-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}
.search-trigger kbd { flex: 0 0 auto; }

.body-switch {
  display: flex;
  gap: 1px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
}
.body-switch button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  transition: color 150ms ease, background 150ms ease;
}
.body-switch button:hover { color: var(--text-soft); background: rgba(255, 255, 255, 0.05); }
.body-switch button.is-active { color: var(--text); background: rgba(94, 234, 212, 0.13); }
.body-switch svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.body-switch button.is-active svg { stroke: var(--accent); }

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}
.nav-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: color 150ms ease, background 150ms ease;
}
.nav-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-btn.is-active { color: var(--text); background: rgba(255, 255, 255, 0.055); }
.nav-btn.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateX(-50%);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.055); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.menu-btn { display: none; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr) 356px;
  background: var(--bg);
}

/* ───────────────────────────── sidebar ───────────────────────────── */

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 180px),
    var(--panel);
}

.sidebar-head {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
}
.tablist {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.16);
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 5px 13px;
  border-radius: 6px;
  transition: background 150ms ease, color 150ms ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: rgba(255, 255, 255, 0.075); color: var(--text); }
.sidebar-close { display: none; }

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px 24px;
}
.side-intro {
  margin: 0 4px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.system-list { display: flex; flex-direction: column; gap: 3px; }

.system-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  border-radius: 9px;
  transition: background 150ms ease;
}
.system-row:hover { background: rgba(255, 255, 255, 0.035); }
.system-row.is-off .system-name { color: var(--muted); }
.system-row.is-off .system-dot { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--c); }
.system-row.is-loading { pointer-events: none; }

.system-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 9px 4px 9px 8px;
  text-align: left;
}
.system-dot {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 13%, transparent);
  transition: background 180ms ease, box-shadow 180ms ease;
}
.system-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
  font-size: 12.5px;
}
.system-count {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.system-sub {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -3px 8px 5px 27px;
  padding: 3px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 10.5px;
  text-align: left;
  transition: color 150ms ease, background 150ms ease;
}
.system-sub:hover { color: var(--text-soft); background: rgba(255, 255, 255, 0.03); }
.system-sub[aria-pressed="true"] { color: var(--accent); }
.system-sub-name { flex: 1; min-width: 0; }
.system-sub-count { font-variant-numeric: tabular-nums; }
.system-sub svg {
  width: 13px; height: 13px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.eye-btn { width: 28px; height: 28px; }
.eye-btn svg { width: 15px; height: 15px; }
.eye-btn.is-loading svg { animation: spin 900ms linear infinite; }

.system-progress {
  position: absolute;
  left: 27px; right: 6px; bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.system-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--c);
  transition: width 180ms ease;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  padding: 6px 4px;
  border-radius: 6px;
  transition: color 150ms ease;
}
.text-btn:hover { color: var(--accent); }
.text-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.side-note {
  display: flex;
  gap: 9px;
  margin: 22px 2px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--faint);
}
.side-note svg { flex: 0 0 auto; width: 14px; height: 14px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.side-note p { margin: 0; font-size: 11px; line-height: 1.55; }

.region-list { display: flex; flex-direction: column; gap: 2px; }
.region-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 16px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 8px;
  border: 0;
  border-bottom: 1px solid rgba(166, 195, 210, 0.07);
  background: transparent;
  text-align: left;
  border-radius: 7px;
  transition: background 150ms ease;
}
.region-row:hover { background: rgba(255, 255, 255, 0.04); }
.region-index { color: var(--faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.region-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.region-name { font-size: 12.5px; color: var(--text-soft); }
.region-detail { font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-row svg { width: 14px; height: 14px; fill: none; stroke: var(--faint); stroke-width: 1.6; transition: stroke 150ms ease, transform 150ms ease; }
.region-row:hover svg { stroke: var(--accent); transform: translateX(2px); }

/* parts index */

.parts-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin: 0 2px 9px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  transition: border-color 150ms ease, background 150ms ease;
}
.parts-search:focus-within { border-color: var(--accent-line); background: rgba(94, 234, 212, 0.035); }
.parts-search > svg { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: var(--faint); stroke-width: 1.7; }
.parts-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 11.5px;
}
.parts-search input::placeholder { color: var(--faint); }
.parts-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  padding: 0;
}
.parts-clear:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.parts-clear svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2; }

.parts-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px 9px;
  color: var(--faint);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}
.parts-summary .link-btn { font-size: 9.5px; }

.parts-tree { display: flex; flex-direction: column; gap: 1px; }
.part-system { border-bottom: 1px solid rgba(166, 195, 210, 0.075); padding-bottom: 3px; }
.part-system:last-child { border-bottom: 0; }
.part-system-head { display: flex; align-items: center; gap: 3px; padding: 4px 0; }
.part-system-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  text-align: left;
}
.part-system-toggle .part-dot { width: 8px; height: 8px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 12%, transparent); }
.part-system-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); font-size: 11.5px; }
.part-system-count { flex: 0 0 auto; color: var(--faint); font-size: 9px; font-variant-numeric: tabular-nums; }

.part-twist {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px; height: 20px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
}
.part-twist svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.1; transition: transform 140ms ease; }
.part-twist[aria-expanded="true"] svg { transform: rotate(90deg); }
.part-twist.is-leaf { pointer-events: none; opacity: 0.3; }

.part-children { margin-left: 9px; padding-left: 4px; border-left: 1px solid rgba(166, 195, 210, 0.08); }

.part-region-head { display: flex; align-items: center; gap: 3px; padding: 2px 0 2px 6px; }
.part-region-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 3px 2px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}
.part-region-toggle .part-region-count { margin-left: auto; color: var(--faint); font-size: 9px; letter-spacing: 0; }

.part-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 27px;
  border-radius: 6px;
  padding-right: 1px;
  transition: background 130ms ease;
}
.part-row:hover { background: rgba(255, 255, 255, 0.04); }
.part-row.is-hidden .part-focus { color: var(--faint); }
.part-row.is-hidden .part-dot { opacity: 0.3; }
.part-row.is-selected { background: rgba(94, 234, 212, 0.08); }
.part-row.is-selected .part-focus { color: var(--text); }

.part-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--faint)); flex: 0 0 auto; }
.part-focus {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  text-align: left;
}
.part-focus .part-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-side { flex: 0 0 auto; color: var(--faint); font-size: 8px; letter-spacing: 0.09em; text-transform: uppercase; }
.part-count-pill { flex: 0 0 auto; color: var(--faint); font-size: 8.5px; font-variant-numeric: tabular-nums; }

.part-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-soft);
}
.part-eye:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.part-eye.is-off { color: var(--faint); }
.part-eye svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.part-empty { padding: 9px 8px 5px; color: var(--faint); font-size: 10px; line-height: 1.5; }
.part-load {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 4px 8px 8px;
  padding: 5px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
}
.parts-foot { padding-top: 8px; }
.parts-foot .text-btn { margin-top: 4px; }

.sidebar-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}
.dataset-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 10.5px;
}
.dataset-badge strong { color: var(--text-soft); font-weight: 600; }
.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.5);
  animation: pulse 2.6s ease-out infinite;
}
.link-btn {
  align-self: flex-start;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--faint);
  font-size: 10.5px;
  text-decoration: underline;
  text-decoration-color: rgba(166, 195, 210, 0.22);
  text-underline-offset: 3px;
  transition: color 150ms ease;
}
.link-btn:hover { color: var(--accent); }

/* ───────────────────────────── stage ───────────────────────────── */

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 700px at 63% 16%, rgba(45, 212, 191, 0.07), transparent 62%),
    radial-gradient(900px 700px at 20% 100%, rgba(59, 130, 246, 0.045), transparent 60%),
    linear-gradient(180deg, #070c11 0%, #060a0e 100%);
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  outline: none;
}
#scene:active { cursor: grabbing; }
#scene.is-pickable { cursor: pointer; }

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 42%, rgba(3, 6, 9, 0.58) 100%),
    linear-gradient(180deg, rgba(3, 6, 9, 0.18), transparent 14%, transparent 86%, rgba(3, 6, 9, 0.34));
}

.stage-top {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.stage-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.66);
  backdrop-filter: blur(10px);
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.stage-title { color: var(--text-soft); }
.stage-divider { width: 1px; height: 11px; background: var(--line-strong); }
.stage-actions { display: flex; gap: 6px; pointer-events: auto; }
.stage-volume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.66);
  backdrop-filter: blur(10px);
}
.stage-volume-icon { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stage-volume input { width: 96px; }
.stage-volume #volumeValue { color: var(--text-soft); font-size: 10.5px; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.66);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 11.5px;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.ghost-btn:hover { color: var(--text); border-color: var(--line-strong); background: rgba(14, 22, 29, 0.85); }
.ghost-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.ghost-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stage-bottom {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.stage-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: opacity 600ms ease;
}
.hint-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.55);
}
.stage-hint.is-dim { opacity: 0.35; }

.view-switch {
  display: flex;
  gap: 1px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.72);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}
.view-switch button {
  width: 27px; height: 24px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 150ms ease, color 150ms ease;
}
.view-switch button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.view-switch button.is-active { color: var(--text); background: rgba(255, 255, 255, 0.09); }

/* tooltip + selection label */

.tooltip {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 280px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(8, 13, 18, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  pointer-events: none;
  transform: translate(12px, 14px);
  white-space: nowrap;
}
.tooltip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.tooltip-name { font-size: 11.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tooltip-system { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); padding-left: 2px; }

.selection-label {
  position: absolute;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  padding: 5px 9px 5px 7px;
  border: 1px solid var(--accent-line);
  border-radius: 99px;
  background: rgba(7, 14, 18, 0.92);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  pointer-events: none;
  transform: translate(-50%, -160%);
  white-space: nowrap;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  transition: opacity 150ms ease;
}
.selection-label span:last-child { overflow: hidden; text-overflow: ellipsis; }
.selection-pin {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.16);
  flex: 0 0 auto;
}

/* dissection card */

.dissect-card {
  position: absolute;
  left: 20px;
  bottom: 58px;
  z-index: 7;
  width: 264px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(9, 15, 21, 0.9);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: cardIn 220ms ease both;
}
.dissect-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.eyebrow {
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.dissect-title { margin-top: 3px; font-size: 12.5px; color: var(--text-soft); }
.segmented {
  display: flex;
  gap: 2px;
  margin: 12px 0 13px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
}
.segmented button {
  flex: 1;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 10px;
  padding: 5px 2px;
  transition: background 150ms ease, color 150ms ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: rgba(255, 255, 255, 0.075); color: var(--text); }

.range {
  width: 100%;
  height: 4px;
  margin: 6px 0;
  border-radius: 99px;
  appearance: none;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--range-progress, 0%), rgba(255, 255, 255, 0.1) var(--range-progress, 0%));
  outline: none;
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 13px; height: 13px;
  border: 2px solid #0a1117;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.range::-moz-range-thumb {
  width: 11px; height: 11px;
  border: 2px solid #0a1117;
  border-radius: 50%;
  background: var(--accent);
}
.range:disabled { opacity: 0.4; cursor: default; }
.range-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--faint);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
#clipValue, #separateValue { color: var(--accent); }

.separate-card {
  position: absolute;
  left: 20px;
  bottom: 58px;
  z-index: 7;
  width: 270px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(9, 15, 21, 0.9);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: cardIn 220ms ease both;
}
.separate-copy {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}
.separate-card .icon-btn { flex: 0 0 auto; }

.switch { position: relative; display: inline-flex; flex: 0 0 auto; width: 32px; height: 18px; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span[aria-hidden] {
  width: 100%; height: 100%;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 180ms ease;
}
.switch span[aria-hidden]::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #dbe4e8;
  transition: transform 180ms ease;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); background: #06201c; }

/* quiz HUD */

.quiz-hud {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 7;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 14px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: rgba(8, 14, 19, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.quiz-hud-item { display: flex; flex-direction: column; gap: 1px; }
.quiz-hud-item span { color: var(--faint); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }
.quiz-hud-item strong { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.quiz-hud .link-btn { align-self: center; }

/* ───────────────────────────── inspector ───────────────────────────── */

.inspector {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 220px),
    var(--panel);
}
.inspector-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.inspector-panel {
  padding: 26px 24px 30px;
  animation: fadeUp 260ms ease both;
}

.display-title {
  margin: 10px 0 12px;
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.04;
  letter-spacing: -0.015em;
  font-weight: 400;
  color: var(--text);
}
.display-title em {
  font-style: italic;
  color: var(--accent);
}
.display-title.small { font-size: 30px; }
.lead {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.start-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 11px;
}
.start-head h2, .how-to h2, .hierarchy h2, .nearby h2, .sources-grid h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--faint);
}
.start-count { color: var(--faint); font-size: 9.5px; }
.start-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.start-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.start-card:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-1px);
}
.start-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.start-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-soft);
}

.how-to { margin-top: 30px; }
.how-to ol { list-style: none; margin: 13px 0 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.how-to li { display: flex; gap: 11px; }
.step {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 9.5px;
}
.how-to li div { color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.how-to li strong { display: block; margin-bottom: 2px; color: var(--text-soft); font-weight: 600; font-size: 11.5px; }

.trust-line {
  display: flex;
  gap: 9px;
  margin-top: 28px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--faint);
}
.trust-line svg { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.trust-line p { margin: 0; font-size: 10.5px; line-height: 1.55; }
.inline-link {
  border: 0; padding: 0; background: transparent;
  color: var(--text-soft);
  font-size: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 2px;
}
.inline-link:hover { color: var(--accent); }

/* part panel */

.part-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.system-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--chip-color, var(--accent)) 30%, transparent);
  border-radius: 99px;
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 11%, transparent);
  color: color-mix(in srgb, var(--chip-color, var(--accent)) 78%, #ffffff);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.system-chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--chip-color, var(--accent));
}
.chip-quiz { --chip-color: var(--accent); }

.part-name {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: break-word;
}
.part-latin {
  min-height: 17px;
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
  letter-spacing: 0.015em;
}
.part-meta {
  margin-top: 5px;
  color: var(--faint);
  font-size: 10.5px;
}
.part-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 18px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.022);
  color: var(--text-soft);
  font-size: 11px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.action-btn:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); }
.action-btn.is-active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.action-btn.icon-only { width: 30px; padding: 0; justify-content: center; margin-left: auto; }
.action-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.part-rule { height: 1px; background: var(--line); margin: 20px 0 18px; }
.definition {
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: 0.002em;
}
.definition.is-empty { color: var(--faint); font-style: italic; }
.read-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.read-more svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform 180ms ease; }
.read-more:hover svg { transform: rotate(90deg); }
.read-more[aria-expanded="true"] svg { transform: rotate(90deg); }
.definition.is-open { max-height: 340px; overflow: auto; padding-right: 4px; }
.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  color: var(--accent);
  font-size: 10.5px;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.wiki-link svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.wiki-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 22px 0 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--line);
}
.facts div { padding: 9px 10px; background: var(--panel); }
.facts dt { color: var(--faint); font-size: 8.5px; letter-spacing: 0.11em; text-transform: uppercase; }
.facts dd { margin: 3px 0 0; color: var(--text-soft); font-size: 10.5px; line-height: 1.4; overflow-wrap: anywhere; }

.hierarchy { margin-top: 24px; }
.hierarchy-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.hierarchy-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
  padding: 4px 7px;
  color: var(--muted);
  font-size: 10px;
  text-align: left;
  transition: color 150ms ease, border-color 150ms ease;
}
.hierarchy-link:hover { color: var(--accent); border-color: var(--accent-line); }
.hierarchy-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  vertical-align: 1px;
}
.hierarchy-label { margin-top: 12px; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; }

.nearby { margin-top: 24px; }
.nearby-note { margin: 5px 0 10px; color: var(--faint); font-size: 9.5px; line-height: 1.5; }
.nearby-list { display: flex; flex-direction: column; gap: 3px; }
.nearby-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.018);
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease;
}
.nearby-row:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.nearby-dot { width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto; }
.nearby-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.nearby-name { color: var(--text-soft); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nearby-meta { color: var(--faint); font-size: 8.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.nearby-distance { flex: 0 0 auto; color: var(--faint); font-size: 9px; font-variant-numeric: tabular-nums; }

.part-note {
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.55;
}

/* quiz panel */

.quiz-count { color: var(--faint); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.quiz-target-label { margin-top: 26px; color: var(--faint); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.quiz-target {
  margin: 4px 0 7px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.1;
  color: var(--text);
}
.quiz-instruction { margin: 0; color: var(--muted); font-size: 11.5px; }
.quiz-feedback {
  margin-top: 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-soft);
}
.quiz-feedback.is-correct { border-color: rgba(99, 214, 157, 0.35); background: rgba(99, 214, 157, 0.08); color: #b7ecd2; }
.quiz-feedback.is-wrong { border-color: rgba(242, 139, 130, 0.32); background: rgba(242, 139, 130, 0.07); color: #f3c5c0; }
.quiz-score-row {
  display: flex;
  gap: 1px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--line);
}
.quiz-score-row div { flex: 1; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; }
.quiz-score-row strong { font-size: 20px; font-weight: 400; font-family: var(--font-display); color: var(--text); line-height: 1.1; }
.quiz-score-row span { color: var(--faint); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.quiz-actions { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin-top: 18px; }
.primary-btn {
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #04211c;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 150ms ease, transform 150ms ease;
}
.primary-btn:hover { background: #7df3df; }
.primary-btn:active { transform: translateY(1px); }
.quiz-actions .text-btn { justify-content: center; margin-top: 2px; }
.fineprint { margin: 14px 0 0; color: var(--faint); font-size: 9.5px; line-height: 1.6; }

/* ───────────────────────────── loading ───────────────────────────── */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(700px 500px at 50% 42%, rgba(45, 212, 191, 0.08), transparent 65%),
    #060a0e;
  transition: opacity 500ms ease, visibility 500ms ease;
}
.loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { width: min(380px, 84vw); text-align: center; }
.loader-mark { width: 44px; height: 44px; margin: 0 auto 14px; color: var(--accent); opacity: 0.9; animation: breathe 3s ease-in-out infinite; }
.loader-title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text);
}
.loader-sub { margin-top: 4px; color: var(--faint); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
.loader-bar {
  height: 2px;
  margin: 30px 0 12px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.55);
  transition: width 240ms ease;
}
.loader-status { color: var(--muted); font-size: 10.5px; letter-spacing: 0.03em; }
.loader-systems { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.loader-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.05em;
}
.loader-chip i { width: 4px; height: 4px; border-radius: 50%; background: var(--c); }
.loader-chip.is-ready { color: var(--text-soft); border-color: var(--line-strong); }

/* ───────────────────────────── modals ───────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 9vh 18px 24px; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 5, 8, 0.68);
  backdrop-filter: blur(6px);
  animation: fadeIn 180ms ease both;
}

.search-dialog {
  position: relative;
  width: min(660px, 94vw);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(10, 17, 23, 0.97);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: dialogIn 200ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}
.search-field svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 1.7; }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.005em;
}
.search-field input::placeholder { color: var(--faint); }
.search-results { flex: 1; overflow-y: auto; padding: 7px; min-height: 120px; }
.search-empty { padding: 30px 16px; color: var(--faint); font-size: 12px; text-align: center; }
.search-group-label {
  padding: 10px 9px 5px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.result {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.result.is-active { background: rgba(255, 255, 255, 0.055); border-color: var(--line); }
.result-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.result-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.result-name { font-size: 12.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-name mark { background: transparent; color: var(--accent); font-weight: 600; }
.result-meta { font-size: 10px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta em { font-style: italic; }
.result-side {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.search-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 9.5px;
}
.search-footer span { display: inline-flex; align-items: center; gap: 4px; }
.search-source { margin-left: auto; }

.sources-dialog {
  position: relative;
  width: min(880px, 94vw);
  max-height: 82vh;
  overflow-y: auto;
  padding: 34px 38px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(10, 17, 23, 0.985);
  box-shadow: var(--shadow);
  animation: dialogIn 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.sources-close { position: absolute; top: 16px; right: 16px; }
.sources-dialog h1 {
  margin: 9px 0 10px;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.015em;
}
.sources-dialog .lead { max-width: 620px; }
.sources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 21px 34px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.sources-grid h2 { margin-bottom: 7px; color: var(--text-soft); }
.sources-grid p { margin: 0 0 8px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.sources-grid strong { color: var(--text-soft); font-weight: 600; }
.licence-line { color: var(--faint) !important; font-size: 10.5px !important; }
.sources-list { margin: 4px 0 10px; padding-left: 18px; color: var(--muted); font-size: 11.5px; line-height: 1.75; }
.sources-list li { margin-bottom: 4px; }
.sources-list a { color: var(--accent); }
.sources-list a:hover { color: var(--text); }
.sources-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.sources-foot h2 { margin: 0 0 6px; color: var(--faint); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }
.sources-foot p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.7; }
.sources-sign { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.sources-sign span:first-child { color: var(--text-soft); font-family: var(--font-display); font-size: 13px; letter-spacing: 0.06em; }

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  transform: translate(-50%, 12px);
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(10, 17, 23, 0.97);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  color: var(--text-soft);
  font-size: 11.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────────────────── motion ───────────────────────────── */

@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(-6px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(94, 234, 212, 0); } 100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); } }
@keyframes breathe { 0%, 100% { opacity: 0.65; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────────── responsive ───────────────────────────── */

@media (max-width: 1220px) {
  .workspace { grid-template-columns: 252px minmax(0, 1fr) 324px; }
  .inspector-panel { padding: 22px 19px 26px; }
  .display-title { font-size: 32px; }
  .start-grid { gap: 4px; }
  .search-trigger { max-width: 420px; }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 246px minmax(0, 1fr); }
  .inspector {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 0;
    width: min(364px, 92vw);
    z-index: 40;
    border-left: 1px solid var(--line-strong);
    box-shadow: -18px 0 60px rgba(0, 0, 0, 0.5);
    transform: translateX(102%);
    transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .inspector.is-open { transform: none; }
  .inspector-scroll { padding-top: 0; }
  .inspector-panel { padding-top: 24px; }
}

@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .brand { min-width: 0; }
  .brand-sub { display: none; }
  .search-trigger-text { display: none; }
  .search-trigger { flex: 0 0 42px; max-width: none; justify-content: center; padding: 0; }
  .search-trigger kbd { display: none; }
  .body-switch button { padding: 0 7px; }
  .body-switch button span { display: none; }
  .body-switch svg { width: 14px; height: 14px; }
  .topnav { gap: 0; }
  .nav-btn { padding: 0 9px; font-size: 11.5px; }
}

@media (max-width: 780px) {
  .workspace { display: block; }
  .stage { position: absolute; inset: 64px 0 0; }
  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: min(310px, 86vw);
    z-index: 45;
    transform: translateX(-102%);
    transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
    box-shadow: 18px 0 60px rgba(0, 0, 0, 0.5);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .inspector { top: 64px; }
  .topnav { margin-left: 4px; }
  .brand-name { font-size: 18px; }
  .stage-top { left: 14px; right: 14px; top: 12px; }
  .stage-bottom { left: 14px; right: 14px; bottom: 12px; }
  .stage-hint { display: none; }
  .dissect-card, .separate-card { left: 14px; right: 14px; width: auto; bottom: 54px; }
  .quiz-hud { top: auto; bottom: 58px; width: calc(100% - 28px); justify-content: space-between; gap: 8px; }
  .selection-label { max-width: 190px; }
  .sources-dialog { padding: 26px 20px 24px; }
  .sources-dialog h1 { font-size: 27px; }
  .sources-grid { grid-template-columns: 1fr; gap: 18px; }
  .sources-foot { flex-direction: column; align-items: flex-start; gap: 14px; }
  .sources-sign { align-items: flex-start; }
  .modal { padding-top: 6vh; }
  .search-footer span:nth-child(2) { display: none; }
}

@media (max-width: 540px) {
  .topbar { height: 58px; flex-basis: 58px; padding: 0 10px; gap: 8px; }
  .stage { inset: 58px 0 0; }
  .sidebar, .inspector { top: 58px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name { font-size: 16px; letter-spacing: 0.12em; }
  .nav-btn { padding: 0 7px; font-size: 10.5px; }
  .nav-btn:nth-child(3) { display: none; }
  .search-trigger { flex-basis: 36px; height: 34px; }
  .stage-actions .ghost-btn span { display: none; }
  .stage-actions .ghost-btn { width: 32px; padding: 0; justify-content: center; }
  .stage-meta { font-size: 9px; padding: 0 8px; }
  .stage-volume { padding: 0 8px; gap: 6px; }
  .stage-volume input { width: 72px; }
  .display-title { font-size: 29px; }
  .inspector-panel { padding: 20px 16px 24px; }
  .quiz-target { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
