/* V5 — Stars & Dust frontend */

html, body {
  margin: 0; padding: 0;
  background: #0c0d1a;
  color: #c8cad8;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  height: 100%;
}

#scene { position: fixed; inset: 0; }

/* ── Header ──────────────────────────────────────────── */
.hdr {
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: rgba(12, 13, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(47, 49, 70, 0.5);
  z-index: 30;
}
.hdr-left { display: flex; align-items: baseline; gap: 14px; }
.hdr-left .logo {
  font-weight: 600; font-size: 14px; letter-spacing: .04em;
  color: #fff; text-transform: uppercase;
}
.hdr-left .version {
  font-size: 11px; color: #7c3aed;
  text-transform: uppercase; letter-spacing: .12em;
}
.hdr-nav { display: flex; gap: 8px; }
.nav-link, .nav-btn {
  padding: 6px 12px;
  border: 1px solid #2f3146;
  border-radius: 6px;
  background: transparent;
  color: #8b8fa8;
  font-size: 12px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all .18s;
}
.nav-link:hover, .nav-btn:hover {
  color: #fff; border-color: #7c3aed;
}
.nav-link.active {
  color: #fff; border-color: #7c3aed; background: rgba(124, 58, 237, 0.18);
}

/* ── Side panels ────────────────────────────────────── */
.panel {
  position: fixed;
  top: 70px;
  width: 320px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: rgba(12, 13, 26, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(47, 49, 70, 0.5);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 12px;
  line-height: 1.55;
  z-index: 20;
}
.panel-left  { left: 18px; width: 360px; }
.panel-right { right: 18px; width: 380px; max-height: calc(100vh - 90px); overflow-y: auto; }
.panel-left  { max-height: calc(100vh - 90px); overflow-y: auto; }
.panel-left::-webkit-scrollbar { width: 6px; }
.panel-left::-webkit-scrollbar-track { background: transparent; }
.panel-left::-webkit-scrollbar-thumb { background: rgba(124,58,237,.25); border-radius: 3px; }
/* Скрываем стандартный scrollbar когда не нужен */
.panel-right::-webkit-scrollbar { width: 6px; }
.panel-right::-webkit-scrollbar-track { background: transparent; }
.panel-right::-webkit-scrollbar-thumb { background: rgba(124,58,237,.25); border-radius: 3px; }

.panel-title {
  font-size: 10px; font-weight: 600;
  color: #7c3aed;
  text-transform: uppercase; letter-spacing: .14em;
  margin-bottom: 10px;
}
.panel-content {
  color: #b6b9cc;
}
.panel-content p { margin: 0 0 10px 0; }
.panel-content b, .panel-content strong { color: #e1e2ed; font-weight: 600; }

/* ── Legend rows (per cluster) ──────────────────────── */
.legend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(47, 49, 70, 0.4);
  cursor: default;
  transition: background .15s;
}
.legend-row:last-child { border-bottom: none; }
.legend-row:hover { background: rgba(124, 58, 237, 0.06); border-radius: 4px; padding-left: 4px; }
.legend-chip {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.legend-text {
  flex: 1; min-width: 0;
}
.legend-text .name {
  display: block;
  color: #e1e2ed; font-weight: 500; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.legend-text .count {
  display: block; color: #8b8fa8; font-size: 10px;
}

/* ── Segment switcher ───────────────────────────────── */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: #14152a;
  border-radius: 6px;
  padding: 3px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: #8b8fa8;
  padding: 6px 4px;
  font-size: 11px;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.seg-btn:hover { color: #fff; }
.seg-btn.active {
  background: rgba(124, 58, 237, 0.22);
  color: #fff;
}

/* ── Article card ───────────────────────────────────── */
.card {
  position: fixed;
  bottom: 18px; left: 18px; right: auto;
  width: min(560px, calc(50vw - 30px));
  max-height: 40vh; overflow-y: auto;
  background: rgba(15, 17, 30, 0.96);
  border: 1px solid #2f3146;
  border-radius: 10px;
  padding: 18px 22px 22px;
  z-index: 25;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.card.hidden { display: none; }
.card-close {
  position: absolute; top: 6px; right: 10px;
  background: transparent; border: none;
  color: #8b8fa8; font-size: 24px; cursor: pointer;
  line-height: 1;
}
.card-close:hover { color: #fff; }
.card h3 { margin: 0 0 8px 0; font-size: 15px; color: #fff; line-height: 1.35; }
.card .meta { font-size: 11px; color: #8b8fa8; margin-bottom: 8px; }
.card .meta b { color: #e1e2ed; font-weight: 500; }

/* ── Loading ────────────────────────────────────────── */
#loading {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 13px; color: #8b8fa8; z-index: 100;
}

/* ── Cluster labels (DOM, projected from 3D) ────────── */
.cluster-label {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 13px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  text-shadow:
    0 0 10px currentColor,
    0 0 24px currentColor,
    0 2px 6px rgba(0, 0, 0, 0.95);
}
.cluster-label .sub {
  display: block;
  font-size: 10px; font-weight: 400;
  letter-spacing: .04em; text-transform: none;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

@media (max-width: 900px) {
  .panel-left, .panel-right {
    width: calc(100vw - 36px);
    max-height: 30vh;
  }
  .panel-right { right: 18px; top: auto; bottom: 18px; }
}

/* ── Display mode (вторичный экран — только сцена + штамп) ── */
body.display-mode { cursor: none; }
body.display-mode .hdr,
body.display-mode .panel,
body.display-mode .card,
body.display-mode #loading { display: none !important; }
body.display-mode #scene { inset: 0; }

.display-stamp {
  position: fixed;
  top: 28px; left: 36px;
  z-index: 20;
  font-size: 13px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(167, 139, 250, .85);
  font-weight: 500;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(124, 58, 237, .5);
  display: none;
}
.display-stamp b {
  display: block;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .08em;
  color: #fff;
  margin-top: 4px;
  text-shadow: 0 0 14px rgba(124, 58, 237, .7);
}
.display-stamp .v {
  display: block;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .12em;
  color: rgba(167, 139, 250, .55);
  margin-top: 6px;
}
body.display-mode .display-stamp { display: block; }

/* Display-button + dot indicator в шапке controller'а */
.display-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: #ef4444;
  margin-left: 5px;
  vertical-align: middle;
  transition: background .2s;
}
.display-dot.connected { background: #34d399; }

/* ── L1-zoom: legend rows clickable ─────────────────────────── */
.legend-row-clickable {
  cursor: pointer;
  position: relative;
}
.legend-row-clickable .legend-arrow {
  color: #6b6f8a;
  font-size: 18px;
  font-weight: 300;
  margin-left: 4px;
  transition: transform .15s, color .15s;
}
.legend-row-clickable:hover .legend-arrow {
  color: #fff;
  transform: translateX(2px);
}

/* ── Breadcrumb (видимо в L1) ────────────────────────────────── */
.breadcrumb {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(12, 13, 26, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(124, 58, 237, 0.4);
  border-radius: 22px;
  font-size: 12px;
}
.breadcrumb .back-btn {
  background: rgba(124, 58, 237, 0.14);
  border: 1px solid #7c3aed;
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.breadcrumb .back-btn:hover {
  background: rgba(124, 58, 237, 0.32);
}
.breadcrumb .bc-sep { color: #6b6f8a; }
.breadcrumb .bc-current {
  font-weight: 600;
  letter-spacing: .04em;
}

body.display-mode .breadcrumb { display: none !important; }

.cluster-label-clickable { transition: opacity .15s; }
.cluster-label-clickable:hover { opacity: 1 !important; transform: translate(-50%, -50%) scale(1.05); }

/* Подсветка активной мета-строки в легенде L1 (touch-toggle) */
.legend-meta-row { cursor: pointer; }
.legend-meta-row.active-meta {
  background: rgba(124, 58, 237, 0.18);
  border-radius: 4px;
}
.legend-meta-row.active-meta .name {
  color: #fff;
}

/* Layout radio + sliders */
.layout-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 11px;
}
.layout-opt input { margin: 0; cursor: pointer; }
.layout-opt span { color: #b6b9cc; }
.layout-opt input:checked + span { color: #fff; font-weight: 500; }
.layout-opt i { color: #6b6f8a; font-style: normal; font-size: 10px; }

.viz-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 10.5px;
}
.viz-label { color: #8b8fa8; }
.viz-row input[type=range] {
  width: 100%;
  height: 3px;
  background: #2f3146;
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}
.viz-row input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7c3aed;
  cursor: pointer;
  border: 1px solid #fff;
}
.viz-val {
  color: #c8cad8;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 10.5px;
}

/* Section titles в правой панели */
.section-title {
  font-size: 10px; color: #7c3aed; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  margin: 0 0 6px;
}
.layout-radio { font-size: 11px; color: #b6b9cc; }

/* Каждая опция layout/checkbox: title + small description */
.layout-opt {
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 1px;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s;
}
.layout-opt:hover { background: rgba(124,58,237,.07); }
.layout-opt input { grid-row: 1 / span 2; align-self: center; margin: 0; cursor: pointer; }
.layout-opt span { color: #b6b9cc; font-size: 11.5px; }
.layout-opt input:checked ~ span { color: #fff; font-weight: 500; }
.layout-opt small {
  grid-column: 2;
  color: #6b6f8a;
  font-size: 10px;
  font-style: italic;
  line-height: 1.3;
}
.layout-opt input:checked ~ small { color: #a78bfa; }

.hint-italic {
  margin-top: 4px;
  font-size: 10px;
  color: #8b8fa8;
  font-style: italic;
}
.hr-dashed {
  border: none;
  border-top: 1px dashed rgba(47, 49, 70, 0.4);
  margin: 14px 0;
}
.block-title {
  color: #8b8fa8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 0 4px;
}

/* Параметры визуализации — расширенный grid с hint */
.viz-row {
  display: grid;
  grid-template-columns: 130px 1fr 36px;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  padding: 6px 0;
  font-size: 11px;
}
.viz-label {
  grid-row: 1;
  grid-column: 1;
  color: #c8cad8;
  font-weight: 500;
}
.viz-row input[type=range] {
  grid-row: 1;
  grid-column: 2;
  width: 100%;
  height: 3px;
  background: #2f3146;
  outline: none;
  border-radius: 2px;
  cursor: pointer;
  appearance: none;
}
.viz-row input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #7c3aed;
  cursor: pointer;
  border: 1px solid #fff;
  box-shadow: 0 0 6px rgba(124,58,237,.6);
}
.viz-val {
  grid-row: 1;
  grid-column: 3;
  color: #c8cad8;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 10.5px;
}
.viz-hint {
  grid-row: 2;
  grid-column: 1 / span 3;
  font-size: 9.5px;
  color: #6b6f8a;
  font-style: italic;
  margin-top: 1px;
}

/* Плавающая кнопка «Центр» — низ по центру; card теперь слева, не перекрывает */
.floating-btn {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: rgba(12, 13, 26, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(124, 58, 237, 0.45);
  border-radius: 24px;
  color: #c8cad8;
  font-size: 12px;
  font-family: Inter, sans-serif;
  letter-spacing: .04em;
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.floating-btn:hover {
  border-color: #7c3aed;
  color: #fff;
  box-shadow: 0 4px 24px rgba(124, 58, 237, 0.35);
}
.floating-btn:active { transform: translateX(-50%) scale(0.97); }
.floating-btn-icon {
  font-size: 16px;
  line-height: 1;
  color: #a78bfa;
}
.floating-btn-label {
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .14em;
}

body.display-mode .floating-btn { display: none !important; }
