/* ───────────────────────────────── tokens ───────────────────────────────── */
:root {
  --bg: #04060d;
  --bg-2: #070b16;
  --panel: rgba(9, 14, 26, 0.72);
  --panel-solid: #0a1020;
  --border: rgba(120, 160, 220, 0.16);
  --border-bright: rgba(140, 190, 255, 0.34);
  --text: #dce6f5;
  --text-dim: #8697b0;
  --text-faint: #5b6a83;
  --accent: #66e0ff;
  --accent-2: #8f6bff;
  --accent-3: #ff5fa8;
  --warn: #ffb347;
  --danger: #ff5f6b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, .mono { font-family: var(--mono); }
[hidden] { display: none !important; }
.muted { color: var(--text-dim); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(130, 170, 230, 0.22); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(130, 170, 230, 0.4); }

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

.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-dim); text-decoration: underline; text-underline-offset: 3px;
}
.linkish:hover { color: var(--accent); }

/* ─────────────────────────────── launch screen ──────────────────────────── */
.launch {
  position: fixed; inset: 0; overflow-y: auto;
  display: grid; place-items: center;
  padding: clamp(20px, 5vh, 64px) 20px;
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(102, 224, 255, 0.13), transparent 62%),
    radial-gradient(900px 560px at 12% 110%, rgba(143, 107, 255, 0.14), transparent 60%),
    radial-gradient(700px 480px at 92% 88%, rgba(255, 95, 168, 0.09), transparent 60%),
    var(--bg);
}
.launch-bg { position: absolute; inset: 0; pointer-events: none; }
.launch-bg canvas { width: 100%; height: 100%; display: block; opacity: 0.85; }

.launch-inner {
  position: relative; z-index: 1;
  width: min(680px, 100%);
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.brand-mark {
  position: relative; width: 72px; height: 72px; margin: 0 auto 18px;
}
.brand-mark .ring, .brand-mark .core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border-radius: 50%;
}
.brand-mark .core { width: 13px; height: 13px; background: var(--accent); box-shadow: 0 0 22px 6px rgba(102, 224, 255, 0.75); }
.brand-mark .ring { border: 1.5px solid; }
.brand-mark .r1 { width: 32px; height: 32px; border-color: rgba(102, 224, 255, 0.85); animation: spin 7s linear infinite; }
.brand-mark .r2 { width: 52px; height: 52px; border-color: rgba(143, 107, 255, 0.7); animation: spin 12s linear infinite reverse; }
.brand-mark .r3 { width: 72px; height: 72px; border-color: rgba(255, 95, 168, 0.4); animation: spin 20s linear infinite; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.launch h1 {
  margin: 0; font-size: clamp(38px, 7vw, 60px); font-weight: 700; letter-spacing: -0.035em;
  background: linear-gradient(96deg, #ffffff 12%, var(--accent) 48%, var(--accent-2) 78%, var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 6px 0 0; color: var(--text-dim); font-size: 15px; letter-spacing: 0.02em; }
.pitch {
  margin: 22px auto 30px; max-width: 54ch; line-height: 1.65;
  color: var(--text-dim); font-size: 15px;
}

.repo-form { display: block; }
.input-wrap {
  display: flex; align-items: center; gap: 10px;
  background: rgba(10, 16, 30, 0.85);
  border: 1px solid var(--border-bright);
  border-radius: 14px; padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px rgba(102, 224, 255, 0.13);
}
.input-icon { width: 17px; height: 17px; color: var(--text-faint); flex: none; }
#repo-input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  padding: 13px 0; font-size: 16px; font-family: var(--mono); letter-spacing: -0.01em;
}
#repo-input::placeholder { color: var(--text-faint); }

.go {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 11px 18px; border: 0; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em; color: #04060d;
  background: linear-gradient(100deg, var(--accent), #7fd8ff 40%, var(--accent-2));
  transition: filter 0.16s, transform 0.16s;
}
.go svg { width: 14px; height: 14px; }
.go:hover { filter: brightness(1.12); }
.go:active { transform: scale(0.97); }
.go:disabled { opacity: 0.55; cursor: default; }

.examples {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 7px; margin-top: 16px;
}
.examples-label { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; }
.examples button {
  background: rgba(120, 160, 220, 0.08); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  transition: all 0.16s;
}
.examples button:hover { color: var(--text); border-color: var(--border-bright); background: rgba(120, 160, 220, 0.16); }

.options { margin-top: 18px; text-align: left; }
.options > summary {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; list-style: none; padding: 8px 2px;
  font-size: 13px; color: var(--text-dim);
}
.options > summary::-webkit-details-marker { display: none; }
.options > summary:hover { color: var(--text); }
.rate-hint { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.options-body {
  display: grid; gap: 14px; padding: 14px;
  background: rgba(10, 16, 30, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.opt { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.opt input[type="checkbox"] { margin-top: 3px; accent-color: var(--accent); width: 15px; height: 15px; }
.opt strong { display: block; font-weight: 600; font-size: 13px; }
.opt em { display: block; margin-top: 3px; font-style: normal; color: var(--text-faint); font-size: 12px; line-height: 1.5; }
.opt-range { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.opt-range input[type="range"] { accent-color: var(--accent); }
.opt-range output { font-family: var(--mono); font-size: 12px; color: var(--text-dim); min-width: 3ch; }
.opt-token { display: block; cursor: default; }
#token-input {
  width: 100%; margin-top: 8px; padding: 9px 11px;
  background: rgba(4, 6, 13, 0.7); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
  font-family: var(--mono); font-size: 12px;
}
#token-input:focus { border-color: var(--accent); }

.local-path { margin-top: 26px; }
.local-or { position: relative; margin-bottom: 18px; }
.local-or::before { content: ""; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--border); }
.local-or span {
  position: relative; padding: 0 12px; background: var(--bg);
  color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
}
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 22px 18px; cursor: pointer; transition: all 0.18s;
  background: rgba(10, 16, 30, 0.35);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: rgba(102, 224, 255, 0.07); }
.dropzone svg { width: 26px; height: 26px; color: var(--text-faint); margin-bottom: 8px; }
.dropzone p { margin: 0 0 4px; font-size: 13px; }
.dropzone .cmd {
  display: inline-block; margin-top: 10px; padding: 6px 12px;
  background: rgba(4, 6, 13, 0.8); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; color: var(--accent);
}

.error {
  margin: 18px 0 0; padding: 11px 14px; border-radius: var(--radius-sm);
  background: rgba(255, 95, 107, 0.1); border: 1px solid rgba(255, 95, 107, 0.35);
  color: #ffb4b9; font-size: 13px; line-height: 1.55; text-align: left;
}

.launch-foot {
  margin-top: 30px; display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 12px;
}

/* ──────────────────────────────── viewer ───────────────────────────────── */
.viewer { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; }
/* touch-action keeps one-finger orbit and two-finger pinch with the camera
   instead of scrolling or zooming the page (OrbitControls sets it inline too;
   this covers the frame before it attaches). */
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
/* z-index + isolation: CSS2DRenderer assigns each label a depth-sorted
   z-index; without a stacking context here those values escape and paint
   scene labels over the UI panels. */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; isolation: isolate; }
.labels > * { pointer-events: none; }

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 50%, transparent 46%, rgba(2, 4, 10, 0.72) 100%);
}
.scanline {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.028;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.9) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* in-scene labels */
.rs-label {
  transform: translate(-50%, -100%);
  display: flex; align-items: baseline; gap: 6px;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: rgba(4, 8, 18, 0.68);
  border: 1px solid color-mix(in srgb, var(--label-color) 40%, transparent);
  backdrop-filter: blur(6px);
  font-size: 11px; letter-spacing: 0.01em;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
  transition: opacity 0.25s;
}
.rs-label-name { color: var(--label-color); font-weight: 600; font-family: var(--mono); }
.rs-label-meta { color: var(--text-faint); font-size: 10px; }
.rs-label[data-depth="0"] { font-size: 13px; padding: 4px 12px; }
.rs-label[data-depth="0"] .rs-label-name { font-size: 13px; }

.rs-person {
  transform: translate(-50%, -100%);
  display: grid; gap: 1px; padding: 4px 10px; border-radius: 8px; white-space: nowrap;
  background: rgba(4, 8, 18, 0.74);
  border: 1px solid color-mix(in srgb, var(--person-color) 45%, transparent);
  backdrop-filter: blur(6px); text-align: center;
}
.rs-person.is-link { pointer-events: auto; cursor: pointer; }
.rs-person.is-link:hover { background: rgba(10, 18, 34, 0.95); }
.rs-person-name { color: var(--person-color); font-weight: 600; font-size: 12px; font-family: var(--mono); }
.rs-person-count { color: var(--text-faint); font-size: 10px; }

/* topbar */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(to bottom, rgba(4, 6, 13, 0.85), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  backdrop-filter: blur(10px); transition: all 0.16s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-bright); }
.repo-id { min-width: 0; }
.repo-name {
  display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--text); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.repo-name:hover { color: var(--accent); }
.repo-desc {
  margin: 1px 0 0; font-size: 12px; color: var(--text-faint);
  max-width: 46ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.repo-stats { display: flex; gap: 18px; margin: 0 0 0 auto; flex: none; }
.repo-stats div { text-align: right; }
.repo-stats dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); }
.repo-stats dd { margin: 1px 0 0; font-family: var(--mono); font-size: 14px; font-weight: 600; }

/* panels */
.panel {
  position: absolute; z-index: 4;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: panelIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } }
.panel-left { top: 74px; left: 18px; width: 246px; }
.panel-right { top: 74px; right: 18px; width: 288px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }

.panel-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 11px 13px; background: none; border: 0; cursor: pointer;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim);
}
.panel-toggle svg { width: 13px; height: 13px; transition: transform 0.2s; }
.panel-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.panel-body { padding: 0 13px 13px; }
.panel-body[hidden] { display: none; }

.spectrum {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.05); margin-bottom: 12px;
}
.spectrum span { height: 100%; transition: filter 0.16s; }
.spectrum span:hover { filter: brightness(1.5); }

.legend { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 5px; max-height: 210px; overflow-y: auto; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend .dot { width: 8px; height: 8px; border-radius: 2px; flex: none; box-shadow: 0 0 8px currentColor; }
.legend .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.legend .pct { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.metrics div { min-width: 0; }
.metrics dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.metrics dd { margin: 2px 0 0; font-family: var(--mono); font-size: 13px; font-weight: 600; }

.note {
  margin: 12px 0 0; padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(255, 179, 71, 0.09); border: 1px solid rgba(255, 179, 71, 0.28);
  color: #ffd79a; font-size: 11px; line-height: 1.5;
}

/* search + inspector */
.search-wrap { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-icon { width: 14px; height: 14px; color: var(--text-faint); flex: none; }
#search-input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 13px; }
#search-input::placeholder { color: var(--text-faint); }
#search-input::-webkit-search-cancel-button { filter: invert(0.6); }
.search-count { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: none; }

.inspector { padding: 12px; border-bottom: 1px solid var(--border); }
.inspector-empty { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.55; }
.insp-path { margin: 0 0 8px; font-family: var(--mono); font-size: 12px; word-break: break-all; line-height: 1.5; }
.insp-path .dir { color: var(--text-faint); }
.insp-path .base { color: var(--text); font-weight: 600; }
.insp-lang { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; margin-bottom: 10px; }
.insp-lang .dot { width: 8px; height: 8px; border-radius: 2px; box-shadow: 0 0 8px currentColor; }
.insp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.insp-grid dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.insp-grid dd { margin: 2px 0 0; font-family: var(--mono); font-size: 12px; }
.insp-actions { display: flex; gap: 6px; }
.insp-actions a, .insp-actions button {
  flex: 1; text-align: center; padding: 6px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: rgba(120, 160, 220, 0.08);
  font-size: 11px; font-weight: 500; color: var(--text-dim); cursor: pointer;
  transition: all 0.16s;
}
.insp-actions a:hover, .insp-actions button:hover {
  color: var(--text); border-color: var(--border-bright);
  background: rgba(120, 160, 220, 0.16); text-decoration: none;
}
.insp-actions button[data-act="focus"] {
  border-color: rgba(102, 224, 255, 0.35); color: var(--accent);
  background: rgba(102, 224, 255, 0.08);
}
.insp-actions button[data-act="focus"]:hover { background: rgba(102, 224, 255, 0.16); color: var(--accent); }
.insp-actions a:active, .insp-actions button:active { transform: scale(0.97); }

.hitlist { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.hitlist li { }
.hitlist button {
  display: block; width: 100%; text-align: left; padding: 6px 8px;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hitlist button { transition: background 0.12s, color 0.12s, padding-left 0.12s; }
.hitlist button:hover { background: rgba(120, 160, 220, 0.12); color: var(--text); padding-left: 11px; }
.hitlist .hl { color: var(--accent); }

/* dock */
.dock {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 36px);
  animation: dockIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes dockIn { from { opacity: 0; transform: translate(-50%, 10px); } }
.modes, .tools, .timeline {
  display: flex; align-items: center; gap: 4px; padding: 5px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.mode {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border: 0; border-radius: 999px; cursor: pointer;
  background: none; color: var(--text-dim); font-size: 13px; transition: all 0.18s;
}
.mode:hover { color: var(--text); }
.mode.is-active { background: rgba(102, 224, 255, 0.15); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(102, 224, 255, 0.3); }
.mode-key {
  display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.07); font-family: var(--mono); font-size: 10px; color: var(--text-faint);
}
.mode.is-active .mode-key { background: rgba(102, 224, 255, 0.2); color: var(--accent); }
.mode:disabled { opacity: 0.4; cursor: not-allowed; }

.timeline { padding: 5px 14px 5px 5px; gap: 10px; }
#time-play {
  background: rgba(102, 224, 255, 0.12); border-color: rgba(102, 224, 255, 0.3);
  color: var(--accent); border-radius: 50%;
}
#time-play:hover { background: rgba(102, 224, 255, 0.22); color: var(--accent); }

/* The activity strip. One measure, commit volume over time, with the played
   span lit and the rest recessive. Progress is emphasis within one hue, not a
   second series. */
.time-track {
  position: relative;
  width: clamp(140px, 26vw, 320px);
  height: 30px;
  border-radius: 6px;
  background: rgba(120, 160, 220, 0.06);
  overflow: visible;
}
.time-spark { display: block; width: 100%; height: 100%; }
.rs-spark-base rect { fill: rgba(134, 151, 176, 0.38); }
.rs-spark-on rect { fill: var(--accent); }

.time-playhead {
  position: absolute; top: -2px; bottom: -2px; width: 1.5px; margin-left: -0.75px;
  background: #fff; border-radius: 2px; pointer-events: none;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.75);
}
.time-hover {
  position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none;
  background: rgba(4, 8, 18, 0.95); border: 1px solid var(--border-bright);
  font-family: var(--mono); font-size: 10px; color: var(--text-dim);
}
#time-range {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: ew-resize;
}
#time-range:focus-visible { opacity: 0.001; outline: 2px solid var(--accent); outline-offset: 3px; }
.time-read { display: grid; line-height: 1.25; min-width: 128px; }
.time-read strong { font-family: var(--mono); font-size: 12px; }
.time-read span { font-size: 10px; color: var(--text-faint); }
/* What the bars measure and how much history is behind them. A chart whose
   units have to be guessed is not explained. */
.time-measure { letter-spacing: 0.02em; opacity: 0.85; }

.tool {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border: 0; border-radius: 999px; cursor: pointer;
  background: none; color: var(--text-dim); font-size: 12px; transition: all 0.18s;
}
.tool svg { width: 13px; height: 13px; }
.tool:hover { color: var(--text); background: rgba(120, 160, 220, 0.12); }
.tool.is-active { color: var(--accent); background: rgba(102, 224, 255, 0.15); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
#record-button.is-active .rec-dot { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
#help-button { font-weight: 700; width: 32px; justify-content: center; padding: 8px 0; }

/* captions */
.caption {
  position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%);
  text-align: center; pointer-events: none; z-index: 6;
  /* A soft scrim so the caption stays legible over the structure and its
     labels, which float wherever the geometry puts them. */
  padding: 26px 64px;
  background: radial-gradient(60% 120% at 50% 50%, rgba(2, 5, 12, 0.82), rgba(2, 5, 12, 0) 72%);
  animation: capIn 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes capIn { from { opacity: 0; transform: translate(-50%, 14px); letter-spacing: 0.2em; } }
.caption h2 {
  margin: 0; font-size: clamp(26px, 4.4vw, 46px); font-weight: 200; letter-spacing: 0.12em;
  text-transform: uppercase; text-shadow: 0 4px 40px rgba(0, 0, 0, 0.9);
}
.caption p { margin: 8px 0 0; font-size: 13px; color: var(--text-dim); letter-spacing: 0.06em; }

.tour-bar { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: rgba(255, 255, 255, 0.08); z-index: 6; }
.tour-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3)); box-shadow: 0 0 12px var(--accent); }

.viewer.is-cinema .topbar,
.viewer.is-cinema .panel,
.viewer.is-cinema .dock { opacity: 0; pointer-events: none; transition: opacity 0.5s; }
.viewer.is-cinema .scanline { opacity: 0.09; }

/* While recording, every frame is drawn at an explicit timestamp. Any CSS
   transition or animation is driven by wall-clock time instead, so it would
   bleed a different amount into each frame; the HUD's 0.5s fade-out was
   landing half-drawn in the opening second of every recording. */
.rs-recording *,
.rs-recording *::before,
.rs-recording *::after {
  transition: none !important;
  animation: none !important;
}

/* tooltip */
.tooltip {
  position: absolute; z-index: 8; pointer-events: none;
  padding: 7px 10px; border-radius: var(--radius-sm);
  background: rgba(4, 8, 18, 0.94); border: 1px solid var(--border-bright);
  backdrop-filter: blur(10px); box-shadow: var(--shadow);
  font-family: var(--mono); font-size: 11px; line-height: 1.5; max-width: 320px;
}
.tooltip .tt-name { color: var(--text); font-weight: 600; }
.tooltip .tt-meta { color: var(--text-faint); }

/* loading */
.loading {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(4, 6, 13, 0.92); backdrop-filter: blur(8px);
}
.loading-inner { text-align: center; width: min(340px, 84vw); }
.loading-orb { position: relative; width: 64px; height: 64px; margin: 0 auto 22px; }
.loading-orb span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid transparent; border-top-color: var(--accent);
  animation: orb 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
.loading-orb span:nth-child(2) { inset: 9px; border-top-color: var(--accent-2); animation-duration: 2.1s; animation-direction: reverse; }
.loading-orb span:nth-child(3) { inset: 18px; border-top-color: var(--accent-3); animation-duration: 2.8s; }
@keyframes orb { to { transform: rotate(360deg); } }
.loading-phase { margin: 0; font-size: 15px; }
.loading-detail { margin: 5px 0 0; font-family: var(--mono); font-size: 12px; color: var(--text-faint); min-height: 18px; }
.loading-bar { height: 3px; margin: 18px 0 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.35s ease; }

/* help dialog */
.help {
  border: 1px solid var(--border-bright); border-radius: var(--radius);
  background: var(--panel-solid); color: var(--text);
  padding: 22px 24px; max-width: 420px; box-shadow: var(--shadow);
}
.help[open] { animation: helpIn 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes helpIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.help::backdrop { background: rgba(4, 6, 13, 0.7); backdrop-filter: blur(4px); }
.help h2 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); }
.help h2 + ul { margin-bottom: 20px; }
.keys, .legend-help { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.keys li { display: flex; align-items: center; gap: 9px; color: var(--text-dim); }
.legend-help li { color: var(--text-dim); }
.legend-help b { color: var(--text); }
kbd {
  display: inline-grid; place-items: center; min-width: 22px; padding: 2px 6px;
  border-radius: 5px; background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border); font-size: 11px; color: var(--text);
}
.help form { margin-top: 18px; text-align: right; }
.help form .tool { border: 1px solid var(--border); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 20;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(9, 14, 26, 0.95); border: 1px solid var(--border-bright);
  backdrop-filter: blur(10px); box-shadow: var(--shadow); font-size: 13px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast.is-error { border-color: rgba(255, 95, 107, 0.5); color: #ffb4b9; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 40px; text-align: center; }

/* ─────────────────────────────── responsive ─────────────────────────────── */
@media (max-width: 1080px) {
  .panel-left { display: none; }
  .panel-right { width: 254px; }
}
@media (max-width: 820px) {
  /* Labels are fixed-size overlays, so on a small screen they must shrink or
     they swamp the structure they are annotating. */
  .rs-label { font-size: 10px; padding: 2px 7px; }
  .rs-label[data-depth="0"] { font-size: 11px; padding: 3px 9px; }
  .rs-label[data-depth="0"] .rs-label-name { font-size: 11px; }
  .rs-person-name { font-size: 11px; }

  .panel-right { display: none; }
  .repo-stats { display: none; }
  /* Home-indicator phones: keep the dock above the gesture bar. */
  .dock { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); gap: 7px; }
  .mode { padding: 7px 11px; font-size: 12px; }
  .mode-key { display: none; }
  .tool span { display: none; }
  .tool { padding: 8px 10px; }
  #help-button span { display: inline; }
  .caption h2 { font-size: 24px; }
  /* The caption's desktop scrim padding is wider than a phone. */
  .caption { padding: 16px 22px; max-width: calc(100vw - 24px); }
  .timeline { order: -1; width: 100%; justify-content: center; }
  /* Let the activity strip take whatever width the row has, instead of the
     fixed desktop clamp leaving it a stub next to the readout. */
  .time-track { width: auto; flex: 1; min-width: 110px; }
  .time-read { min-width: 0; }
  .help { max-width: min(420px, calc(100vw - 32px)); max-height: 86vh; overflow-y: auto; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); text-align: center; }
}

@media (max-width: 560px) {
  .repo-desc { display: none; }
  .topbar { padding: 10px 12px; }
  .repo-name { font-size: 14px; }
  .time-measure { display: none; }
  .time-read span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
  .caption h2 { font-size: 20px; letter-spacing: 0.09em; }
  .caption p { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .brand-mark .ring { animation: none; }
  .launch-inner, .caption, .toast { animation: none; }
  .panel, .dock, .help[open] { animation: none; }
  .loading-orb span { animation-duration: 4s; }
}
