/* Kortex Cosmos — deep-space UI for the interactive 3D knowledge galaxy. */

:root {
  --bg0: #03040c;
  --bg1: #070a18;
  --ink: #e8edff;
  --ink-dim: #97a0c4;
  --ink-faint: #5b6488;
  --panel: rgba(12, 16, 34, 0.72);
  --panel-edge: rgba(120, 150, 255, 0.18);
  --glass-blur: 14px;

  /* scope-family accents (the galaxies) */
  --fam-org: #ffcf6b;
  --fam-product: #57d4ff;
  --fam-client: #ff79d2;
  --fam-infra: #67ffa6;
  --fam-quarantine: #ff6b6b;
  --accent: #8fb4ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#starfield, #graph, #overlay {
  position: fixed;
  inset: 0;
}
#starfield { z-index: 0; }
#graph    { z-index: 1; }
#overlay  { z-index: 2; pointer-events: none; }

/* radial deep-space vignette behind everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(120% 90% at 70% -10%, rgba(40, 60, 140, 0.25), transparent 60%),
    radial-gradient(100% 80% at 10% 110%, rgba(120, 40, 120, 0.18), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  pointer-events: none;
}

.gone { display: none !important; }
.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ---------------- projected node overlay (labels + halos) ---------------- */
.node-halo, .node-label {
  position: absolute;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  pointer-events: none;
}
.node-halo {
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: blur(2px);
  opacity: 0.0;
  transition: opacity 0.4s ease;
}
/* note labels wrap into a small card so long titles don't streak across the screen */
.node-label {
  max-width: 230px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 12px;
  line-height: 1.32;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: rgba(8, 11, 26, 0.66);
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  padding: 5px 9px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.25s ease;
}
/* hub + family labels are short scope names — keep them as glowing text, not cards */
.node-label.hub, .node-label.fam {
  max-width: none;
  white-space: nowrap;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 1px 4px;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.95), 0 1px 2px rgba(0, 0, 0, 0.95);
}
.node-label.hub {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}
.node-label.fam {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.node-label.show { opacity: 1; }
.node-label.pointer { pointer-events: auto; cursor: pointer; }

/* ignite animation when a new note lands during a live poll */
@keyframes ignite {
  0%   { transform: translate(-50%,-50%) scale(0.2); opacity: 0; }
  35%  { transform: translate(-50%,-50%) scale(2.4); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 0.0; }
}
.ignite-ring {
  position: absolute;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 24px 6px rgba(255,255,255,0.6);
  mix-blend-mode: screen;
  animation: ignite 1400ms ease-out forwards;
  pointer-events: none;
}

/* ---------------- HUD ---------------- */
#hud {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(3,4,12,0.78), transparent);
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 8px; user-select: none; }
.brand .mark { color: var(--accent); font-size: 20px; text-shadow: 0 0 14px var(--accent); }
.brand .word { font-weight: 800; letter-spacing: 0.22em; }
.brand .sub  { color: var(--ink-dim); letter-spacing: 0.34em; font-size: 11px; text-transform: uppercase; }

.searchwrap { flex: 1; max-width: 540px; display: flex; gap: 8px; align-items: center; }
.sem-toggle {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--panel-edge); color: var(--ink-faint);
  border-radius: 999px; padding: 8px 13px; font-size: 11.5px; letter-spacing: 0.03em; cursor: pointer;
  white-space: nowrap; backdrop-filter: blur(var(--glass-blur));
}
.sem-toggle:hover { color: var(--ink); border-color: var(--accent); }
.sem-toggle.active { background: rgba(143, 180, 255, 0.22); border-color: var(--accent); color: var(--ink); }
/* #search is a multi-line, auto-growing field (it lives in the Filter panel) — a rounded rect, not a pill,
   so wrapped queries read cleanly; the magnifier pins to the top-left as it grows. */
#search {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 13px;
  color: var(--ink);
  padding: 10px 14px 10px 36px;   /* left room for the magnifier glyph */
  outline: none;
  backdrop-filter: blur(var(--glass-blur));
  font: inherit;
  line-height: 1.45;
  resize: none;
  min-height: 42px;
  max-height: 132px;
  overflow-y: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237b86ab' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px 14px;
}
#search::placeholder { color: var(--ink-faint); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(143,180,255,0.15); }

/* two mode pills (Filter | Ask) — symmetric peers, each toggles its own slide-out panel */
.modebar { flex: 1; display: flex; justify-content: center; gap: 10px; }
.mode-pill {
  flex: 0 0 auto; border-radius: 999px; padding: 8px 16px; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.02em; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--ink-dim);
  backdrop-filter: blur(var(--glass-blur));
}
.pill-ico { width: 13px; height: 13px; vertical-align: -2px; }   /* monochrome (currentColor) — matches the ✦ / ⚙ glyphs */
.mode-pill:hover { color: var(--ink); border-color: var(--accent); }
.mode-pill.active { background: rgba(143,180,255,0.3); border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 3px rgba(143,180,255,0.12); }
/* a subtle dot on the Filter pill when filters are applied but the panel is closed */
.mode-pill.has-filters { border-color: var(--accent); color: var(--ink); }
.mode-pill.has-filters::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent); vertical-align: middle;
}
/* cinematic toggle — a bare icon button, not a labeled pill */
.icon-btn {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--panel-edge); color: var(--ink-faint);
  border-radius: 999px; width: 34px; height: 34px; font-size: 14px; line-height: 1; cursor: pointer;
  backdrop-filter: blur(var(--glass-blur));
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.icon-btn.active { background: rgba(143,180,255,0.22); border-color: var(--accent); color: var(--ink); }

.stats { margin-left: auto; color: var(--ink-dim); font-size: 12px; letter-spacing: 0.03em; text-align: right; }
/* small round icon buttons — deliberately quieter than the mode pills (e.g. reset-view: a recenter crosshair) */
.iconbtn {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--ink-faint); cursor: pointer;
  backdrop-filter: blur(var(--glass-blur));
}
.iconbtn svg { width: 14px; height: 14px; }
.iconbtn:hover { color: var(--ink); border-color: var(--accent); }
.stats b { color: var(--ink); font-weight: 650; }
.stats a.signout { color: var(--accent); text-decoration: none; }
.stats a.signout:hover { text-decoration: underline; }

/* ---------------- filter panel ---------------- */
#legend {
  position: fixed; z-index: 5; left: 18px; bottom: 18px;
  width: 240px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(var(--glass-blur));
}
.legend-head { display: flex; align-items: center; justify-content: space-between; }
.legend-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-faint); margin: 2px 0 8px; }
.clearbtn { background: none; border: 1px solid var(--panel-edge); color: var(--ink-dim); border-radius: 999px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 9px; cursor: pointer; }
.clearbtn:hover { color: var(--ink); border-color: var(--accent); }

.facet { margin-bottom: 12px; }
.facet-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-faint); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 3px 9px; font-size: 11.5px; color: var(--ink-dim);
  cursor: pointer; user-select: none; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.chip .count { color: var(--ink-faint); font-size: 10px; }
.chip.active { background: rgba(143,180,255,0.18); border-color: var(--accent); color: var(--ink); }
.facet-select {
  width: 100%; background: rgba(3,5,16,0.7); border: 1px solid var(--panel-edge); color: var(--ink-dim);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; outline: none; cursor: pointer;
}
.facet-select:focus { border-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 9px; padding: 4px 0; color: var(--ink-dim); cursor: pointer; user-select: none; font-size: 13px; }
.toggle em { color: var(--ink-faint); font-style: normal; font-size: 11px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .sw { width: 30px; height: 16px; border-radius: 999px; background: rgba(120,140,200,0.2); position: relative; transition: background 0.2s; flex: 0 0 auto; }
.toggle .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-dim); transition: transform 0.2s, background 0.2s; }
.toggle input:checked + .sw { background: rgba(143,180,255,0.5); }
.toggle input:checked + .sw::after { transform: translateX(14px); background: #fff; }
.hint { margin-top: 10px; color: var(--ink-faint); font-size: 11px; line-height: 1.6; }

/* ---------------- detail panel ---------------- */
.panel {
  position: fixed; z-index: 6; top: 64px; right: 18px; bottom: 18px;
  width: min(420px, 40vw);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 22px 22px 18px;
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: auto;
  animation: slidein 0.28s cubic-bezier(.2,.7,.2,1);
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#detail-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--panel-edge); background: transparent; color: var(--ink-dim);
  font-size: 18px; line-height: 1; cursor: pointer;
}
#detail-close:hover { color: var(--ink); border-color: var(--accent); }
.detail-scope { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
#detail-title { margin: 0 36px 8px 0; font-size: 19px; line-height: 1.25; font-weight: 700; }
.detail-meta { color: var(--ink-faint); font-size: 12px; margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-meta .chip { border: 1px solid var(--panel-edge); border-radius: 999px; padding: 2px 9px; }
.detail-body { color: var(--ink-dim); white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.7; }
.detail-body a.wl { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); cursor: pointer; }
.detail-links { margin-top: 16px; }
.detail-links .ttl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-faint); margin-bottom: 6px; }
.detail-links a { display: inline-block; margin: 0 6px 6px 0; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--panel-edge); color: var(--ink-dim); cursor: pointer; font-size: 12px; }
.detail-links a:hover { color: var(--ink); border-color: var(--accent); }

/* ---------------- login modal ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(120% 100% at 50% 30%, rgba(10,14,34,0.6), rgba(3,4,12,0.92));
  backdrop-filter: blur(6px);
}
#login-form {
  width: min(420px, 90vw);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 20px;
  padding: 34px 30px 28px;
  text-align: center;
  box-shadow: 0 30px 120px rgba(0,0,0,0.6);
}
.login-mark { font-size: 40px; color: var(--accent); text-shadow: 0 0 30px var(--accent); margin-bottom: 4px; }
#login-form h1 { margin: 4px 0 10px; font-size: 24px; letter-spacing: 0.04em; }
.login-sub { color: var(--ink-dim); font-size: 13px; margin: 0 auto 20px; max-width: 320px; }
.sso-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px; border: 1px solid rgba(255,255,255,0.5); border-radius: 12px; cursor: pointer;
  background: #fff; color: #1b1b1b; font-weight: 600; font-size: 14px; margin-bottom: 6px;
}
.sso-btn:hover { filter: brightness(0.96); }
.ms-logo {
  width: 16px; height: 16px; display: inline-block;
  background:
    linear-gradient(#f25022,#f25022) 0 0/7px 7px no-repeat,
    linear-gradient(#7fba00,#7fba00) 9px 0/7px 7px no-repeat,
    linear-gradient(#00a4ef,#00a4ef) 0 9px/7px 7px no-repeat,
    linear-gradient(#ffb900,#ffb900) 9px 9px/7px 7px no-repeat;
}
.login-or { position: relative; text-align: center; color: var(--ink-faint); font-size: 11px; margin: 12px 0; text-transform: uppercase; letter-spacing: 0.1em; }
.login-or::before, .login-or::after { content: ""; position: absolute; top: 50%; width: 36%; height: 1px; background: var(--panel-edge); }
.login-or::before { left: 0; }
.login-or::after { right: 0; }
#key {
  width: 100%; background: rgba(3,5,16,0.7); border: 1px solid var(--panel-edge);
  border-radius: 12px; color: var(--ink); padding: 12px 14px; outline: none; font-size: 14px;
  letter-spacing: 0.05em;
}
#key:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(143,180,255,0.15); }
.remember { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-faint); font-size: 12px; margin: 12px 0 18px; }
#login-go {
  width: 100%; padding: 12px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #6d97ff, #4f6ff0); color: #fff; font-weight: 700; letter-spacing: 0.04em;
  font-size: 14px; box-shadow: 0 10px 30px rgba(79,111,240,0.4);
}
#login-go:hover { filter: brightness(1.08); }
#login-go:disabled { opacity: 0.6; cursor: progress; }
.login-error { color: #ff8a8a; font-size: 12.5px; min-height: 16px; margin-top: 12px; }
.login-foot { margin-top: 22px; color: var(--ink-faint); font-size: 11px; letter-spacing: 0.08em; }

/* ---------------- time machine (lives inside the Filter panel) ---------------- */
#timebar { display: block; margin-top: 4px; }
.time-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; }
#time-play {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--panel-edge); background: rgba(143,180,255,0.14); color: var(--ink);
  cursor: pointer; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
#time-play:hover { border-color: var(--accent); }
#time-slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 60%, rgba(120,140,200,0.25) 60%); outline: none; }
#time-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px var(--accent); cursor: pointer; }
#time-slider::-moz-range-thumb { width: 15px; height: 15px; border: none; border-radius: 50%; background: #fff;
  box-shadow: 0 0 10px var(--accent); cursor: pointer; }
.time-meta { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
#time-label { font-size: 12.5px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
#time-label.live { color: var(--fam-infra); }
.time-axis { display: inline-flex; border: 1px solid var(--panel-edge); border-radius: 999px; overflow: hidden; }
.time-axis .ta { background: none; border: none; color: var(--ink-faint); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 8px; cursor: pointer; }
.time-axis .ta.active { background: rgba(143,180,255,0.22); color: var(--ink); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; z-index: 8; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 9px 18px; color: var(--ink); font-size: 13px; backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

/* ---------------- live "just landed" feed ---------------- */
/* Top-center, below the mode pills — the one zone clear of both the left slide-outs (Filter/Settings) and the
   right ones (Ask/detail), so an open panel never covers it. */
.landing {
  position: fixed; z-index: 5; top: 70px; left: 50%; transform: translateX(-50%);
  width: 300px; max-width: 60vw;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.land-card {
  pointer-events: auto; cursor: pointer; display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--panel-edge); border-left: 3px solid var(--fam, var(--accent));
  border-radius: 12px; padding: 9px 12px; backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateY(-10px);
  transition: opacity .38s ease, transform .38s cubic-bezier(.2, .7, .2, 1);
}
.land-card.in  { opacity: 1; transform: none; }
.land-card.out { opacity: 0; transform: translateY(-10px); }
.land-card:hover { border-color: var(--accent); }
.land-dot {
  flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%;
  background: var(--fam, var(--accent)); box-shadow: 0 0 10px 2px var(--fam, var(--accent));
}
.land-meta { min-width: 0; }
.land-title {
  color: var(--ink); font-size: 12.5px; font-weight: 600; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.land-sub { color: var(--ink-faint); font-size: 10.5px; letter-spacing: 0.02em; text-transform: capitalize; margin-top: 2px; }
.land-meta { flex: 1 1 auto; }   /* let the title column grow so the × sits at the right edge */
.land-close {
  flex: 0 0 auto; align-self: flex-start; margin: -2px -4px 0 0; padding: 2px 5px;
  background: none; border: none; color: var(--ink-faint); font-size: 16px; line-height: 1;
  cursor: pointer; border-radius: 6px; opacity: 0.5; transition: opacity 0.15s, color 0.15s;
}
.land-close:hover { color: var(--ink); opacity: 1; }
.sub-label { font-size: 10px; color: var(--ink-faint); letter-spacing: 0.04em; margin: 12px 0 0; }
@media (max-width: 720px) { .landing { display: none; } }

/* ---------------- entry sequence (click-to-enter gate + cinematic warp-in) ---------------- */
.intro {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  /* fully opaque — it's a curtain: the nebula settles (invisibly) behind it so we can capture the resting frame */
  background: radial-gradient(circle at 50% 42%, rgb(14, 20, 46), rgb(3, 4, 12) 70%);
  cursor: pointer; transition: opacity 1.1s ease; opacity: 1;
}
.intro.fade { opacity: 0; pointer-events: none; }
.intro-inner { text-align: center; animation: introRise 1.2s cubic-bezier(.2, .7, .2, 1); }
.intro-mark {
  font-size: 66px; line-height: 1; color: var(--accent); text-shadow: 0 0 44px var(--accent);
  animation: introPulse 3.4s ease-in-out infinite;
}
.intro-title { margin: 16px 0 28px; font-size: 30px; font-weight: 750; letter-spacing: 0.42em; color: var(--ink); }
.intro-title span { color: var(--ink-dim); font-weight: 300; }
.intro-enter {
  background: rgba(143, 180, 255, 0.14); border: 1px solid var(--accent); color: var(--ink);
  border-radius: 999px; padding: 11px 26px; font-size: 14px; font-weight: 600; letter-spacing: 0.04em;
  cursor: pointer; backdrop-filter: blur(var(--glass-blur)); transition: background 0.2s, box-shadow 0.2s;
}
.intro-enter:hover { background: rgba(143, 180, 255, 0.26); box-shadow: 0 0 0 4px rgba(143, 180, 255, 0.12); }
@keyframes introPulse { 0%, 100% { transform: scale(1); opacity: 0.88; } 50% { transform: scale(1.09); opacity: 1; } }
@keyframes introRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------------- HUD actions (ask / cinematic) ---------------- */
.hud-actions { display: flex; gap: 8px; align-items: center; }
#cinema-btn { font-size: 14px; line-height: 1; padding: 8px 11px; }

/* ---------------- Filter panel (left slide-out, peer of Ask) ---------------- */
.filterpanel {
  top: 64px; bottom: 18px; left: 18px; right: auto;
  width: min(320px, 66vw);
  display: flex; flex-direction: column; padding: 0;
  animation: slideinLeft 0.28s cubic-bezier(.2,.7,.2,1);
}
@keyframes slideinLeft { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.filter-body { flex: 1; overflow-y: auto; padding: 14px 16px 16px; }

/* ---------------- settings panel (left slide-out, peer of Filter) ---------------- */
.settingspanel {
  top: 64px; left: 18px; right: auto; bottom: auto;
  width: min(300px, 66vw);
  /* content-height when short, but never taller than the viewport — the body scrolls past the cap (the panel
     had NO overflow, so on small windows the bottom controls were simply unreachable) */
  max-height: calc(100vh - 64px - 18px);
  display: flex; flex-direction: column; padding: 0;
  animation: slideinLeft 0.28s cubic-bezier(.2, .7, .2, 1);
}
.settings-body { padding: 12px 16px 16px; min-height: 0; overflow-y: auto; }
/* segmented tab bar — splits the panel so each pane fits the default viewport without scrolling */
.settings-tabs {
  display: flex; gap: 4px; margin-bottom: 10px; padding: 3px;
  border: 1px solid var(--panel-edge); border-radius: 9px; background: rgba(143,180,255,0.05);
}
.stab {
  flex: 1; border: none; background: none; color: var(--ink-faint); cursor: pointer;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; padding: 6px 0; border-radius: 7px;
}
.stab:hover { color: var(--ink); }
.stab.active { background: rgba(143,180,255,0.16); color: var(--ink); }
.settings-body .setting-group { margin-top: 14px; }
/* custom picker (ask voice + music track) — a native <select>'s popup is OS-chrome and can't be themed, so
   the menu is ours: glass panel, optional section heads, hover rows, ✓ on the active item, per-row ▶ preview */
.voice-picker { position: relative; }
.voice-current {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
  border: 1px solid var(--panel-edge); background: rgba(143,180,255,0.06); color: var(--ink-dim);
}
.voice-current:hover { border-color: var(--accent); color: var(--ink); }
.vp-caret { opacity: 0.55; font-size: 10px; }
.voice-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 8;
  max-height: 280px; overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px;
  backdrop-filter: blur(var(--glass-blur)); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
.vp-head {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-faint);
  padding: 7px 8px 4px;
}
.vp-head:not(:first-child) { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--panel-edge); }
.vp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--ink-dim); font-size: 12.5px;
}
.vp-item:hover { background: rgba(143,180,255,0.12); color: var(--ink); }
.vp-item.sel { color: var(--ink); }
.vp-item.sel .vp-name::after { content: " ✓"; color: var(--accent); }
.vp-play {
  flex: 0 0 auto; border: none; background: none; color: var(--accent); cursor: pointer;
  font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 5px; opacity: 0.35;
}
.vp-item:hover .vp-play { opacity: 1; }
.vp-play:hover { background: rgba(143,180,255,0.18); }
.vp-play:disabled { opacity: 0.9; cursor: progress; }
.ambient-vol { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ambient-vol .vol-ico { font-size: 13px; opacity: 0.8; flex: 0 0 auto; }
.ambient-vol input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: rgba(120, 140, 200, 0.25); outline: none;
}
.ambient-vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 8px var(--accent); cursor: pointer;
}
.ambient-vol input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%; background: #fff; box-shadow: 0 0 8px var(--accent); cursor: pointer;
}
/* stack the search field over its ≈ related modifier so the field gets the full panel width */
.filterpanel .searchwrap { flex-direction: column; align-items: stretch; max-width: none; margin-bottom: 14px; gap: 8px; }
.filterpanel .searchwrap .sem-toggle { align-self: flex-start; }
.filterpanel .chat-title .mark { font-size: 13px; }

/* ---------------- Ask Kortex chat ---------------- */
.chatpanel {
  top: 64px; bottom: 18px; right: 18px;
  width: min(400px, 40vw);
  display: flex; flex-direction: column;
  padding: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--panel-edge);
}
.chat-title { flex: 1; font-weight: 700; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.chat-title .mark { color: var(--accent); text-shadow: 0 0 12px var(--accent); }
.chat-mini {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid var(--panel-edge); background: transparent; color: var(--ink-dim);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.chat-mini:hover { color: var(--ink); border-color: var(--accent); }
.chat-mini.active { background: rgba(143,180,255,0.22); border-color: var(--accent); color: var(--ink); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { color: var(--ink-faint); font-size: 12.5px; line-height: 1.6; margin: auto 0; text-align: center; }
.msg { max-width: 92%; font-size: 13.5px; line-height: 1.6; }
.msg.you { align-self: flex-end; background: rgba(143,180,255,0.16); border: 1px solid var(--panel-edge);
  color: var(--ink); border-radius: 14px 14px 4px 14px; padding: 8px 12px; }
.msg.kortex { align-self: flex-start; color: var(--ink-dim); }
.msg.kortex .body { white-space: pre-wrap; }
.msg.kortex.thinking { color: var(--ink-faint); font-style: italic; }
/* typing-style indicator: three dots breathing in sequence while Kortex consults the corpus */
.msg.thinking .dots { display: inline-block; margin-left: 5px; }
.msg.thinking .dots i {
  display: inline-block; width: 4px; height: 4px; margin: 0 1.5px; border-radius: 50%;
  background: currentColor; opacity: 0.25; vertical-align: baseline;
  animation: think-bounce 1.2s ease-in-out infinite;
}
.msg.thinking .dots i:nth-child(2) { animation-delay: 0.2s; }
.msg.thinking .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes think-bounce {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.msg .cites { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.msg .cite {
  font-size: 11px; color: var(--accent); border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 2px 9px; cursor: pointer; background: rgba(143,180,255,0.08);
  /* long slugs/titles must ellipsize INSIDE the pill — unconstrained, the text ran past the rounded border
     (flex items refuse to shrink below content without min-width: 0) */
  display: inline-block; max-width: 100%; min-width: 0; box-sizing: border-box;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg .cite:hover { border-color: var(--accent); background: rgba(143,180,255,0.2); }
.msg .walled { margin-top: 6px; color: var(--ink-faint); font-size: 11px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px 14px; border-top: 1px solid var(--panel-edge); }
#chat-input {
  flex: 1; resize: none; max-height: 120px;
  background: rgba(3,5,16,0.7); border: 1px solid var(--panel-edge); border-radius: 12px;
  color: var(--ink); padding: 9px 12px; outline: none; font: inherit; line-height: 1.4;
}
#chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(143,180,255,0.12); }
#chat-input::placeholder { color: var(--ink-faint); }
#chat-send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(180deg, #6d97ff, #4f6ff0); color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 8px 22px rgba(79,111,240,0.4);
}
#chat-send:hover { filter: brightness(1.08); }
#chat-send:disabled { opacity: 0.5; cursor: progress; }

/* ---------------- cinematic mode (hide all chrome) ---------------- */
#hud, #filter-panel, #timebar, #detail, #chat, #cinema-exit { transition: opacity 0.5s ease; }
body.cinematic #hud,
body.cinematic #filter-panel,
body.cinematic #timebar,
body.cinematic #detail,
body.cinematic #chat { opacity: 0; pointer-events: none; }
#cinema-exit {
  position: fixed; z-index: 9; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 999px;
  color: var(--ink-faint); font-size: 11px; letter-spacing: 0.06em; padding: 7px 15px; cursor: pointer;
  backdrop-filter: blur(var(--glass-blur)); opacity: 0;
}
body.cinematic #cinema-exit { opacity: 1; }
body.cinematic #cinema-exit.fade { opacity: 0; pointer-events: none; }
#cinema-exit b { color: var(--ink-dim); font-weight: 700; }

/* ---------------- meteor strike (real-time new data) ---------------- */
.meteor { position: absolute; z-index: 3; left: 0; top: 0; width: 0; height: 0; pointer-events: none;
  transition: transform 950ms cubic-bezier(.35,.02,.28,1); }
.meteor .head { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 14px 5px rgba(255,255,255,0.95), 0 0 34px 12px rgba(143,180,255,0.7); }
.meteor .tail { position: absolute; right: 0; top: -1.5px; width: 150px; height: 3px; transform-origin: right center;
  background: linear-gradient(90deg, rgba(143,180,255,0) 0%, rgba(180,205,255,0.5) 60%, rgba(255,255,255,0.95) 100%);
  border-radius: 3px; filter: blur(0.4px); }
@keyframes starburst {
  0%   { transform: translate(-50%,-50%) scale(0.2); opacity: 0; }
  18%  { opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(3.6); opacity: 0; }
}
.starburst {
  position: absolute; width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, currentColor 42%, transparent 70%);
  mix-blend-mode: screen; animation: starburst 900ms ease-out forwards; pointer-events: none;
}

@media (max-width: 720px) {
  .panel { width: auto; left: 12px; right: 12px; top: auto; bottom: 12px; height: 46vh; }
  .chatpanel, .filterpanel { height: 60vh; }
  .stats { display: none; }
}
