:root {
  --bg: #070b16;
  --bg-soft: #0b1122;
  --panel: #0d1428;
  --panel-edge: #1d2a4a;
  --ink: #e8edf8;
  --ink-dim: #93a0bd;
  --accent: #8ab4ff;
  --grid: #16223d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0 20px 30px;
  background:
    radial-gradient(1200px 600px at 70% -10%, #101a36 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, #0d1530 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ---------- шапка ---------- */
.home-link {
  display: inline-block;
  margin: 0 0 10px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  transition: color .15s;
}
.home-link:hover { color: var(--accent); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 40px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 26px 6px 14px;
}

.brand h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #dfe9ff, #8ab4ff 70%, #c9a7ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 14.5px;
  max-width: 640px;
}

.controls { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; }

.ctl { display: flex; flex-direction: column; gap: 7px; }
.ctl > span { font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }

select {
  appearance: none;
  background: var(--bg-soft) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238ab4ff' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  border-radius: 9px;
  padding: 10px 38px 10px 14px;
  font-size: 15px;
  min-width: 260px;
  cursor: pointer;
  transition: border-color .15s;
}
select:hover, select:focus { border-color: var(--accent); outline: none; }

.seg { display: flex; border: 1px solid var(--panel-edge); border-radius: 9px; overflow: hidden; }
.seg button {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  padding: 10px 14px;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--panel-edge); }
.seg button.active { background: #16223f; color: #fff; }
.seg button:not(.active):hover { color: var(--ink); }

/* ---------- вкладки режимов ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 10px 6px 20px;
  border-bottom: 1px solid var(--panel-edge);
}
.tabs button {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  padding: 12px 22px 13px;
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: #fff; border-bottom-color: var(--accent); }

.view { display: none; }
.view.active { display: block; animation: fadein .35s ease both; }

/* ---------- вкладка мифов ---------- */
.myths-wrap {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 30px;
  padding: 4px 4px 10px;
}

.myths-index {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  font-size: 13.5px;
  padding-right: 6px;
}
.myths-index .ix-group {
  margin: 14px 0 4px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #74839f;
}
.myths-index .ix-group:first-child { margin-top: 2px; }
.myths-index button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 13.5px;
  padding: 3px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.myths-index button:hover { color: var(--ink); background: #131c33; }
.myths-index button.sel {
  color: #fff;
  background: #16223f;
  box-shadow: inset 2px 0 0 var(--accent);
}
.myths-index button.in-app::after {
  content: " ·";
  color: var(--accent);
}

.myths-body { max-width: 860px; }
.myth-group { margin-bottom: 34px; }
.myth-group-title {
  font-size: 19px;
  font-weight: 650;
  color: #dfe9ff;
  margin: 0 0 4px;
}
.myth-group-season {
  font-size: 12.5px;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin: 0 0 12px;
}
.myth-lead {
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.68;
  font-style: italic;
  border-left: 3px solid var(--panel-edge);
  padding: 6px 0 6px 16px;
  margin: 0 0 18px;
}
.myth-lead p { margin: 0 0 8px; }
.myth-lead p:last-child { margin-bottom: 0; }

.myth-entry {
  background: #0e1526;
  border: 1px solid #1a2643;
  border-left: 3px solid transparent;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
  scroll-margin-top: 18px;
  transition: border-color .2s, background .2s;
}
.myth-entry.selected {
  border-left-color: var(--accent);
  background: #111a30;
}
.myth-entry h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 650;
  color: #e6edfb;
}
.myth-entry h3 .lat {
  font-weight: 400;
  font-size: 12.5px;
  color: #74839f;
  margin-left: 8px;
}
.myth-entry p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.68;
  color: #c3cde3;
}
.myth-tail {
  color: var(--ink-dim);
  font-size: 13.5px;
  font-style: italic;
  margin: 10px 2px 0;
}
.myth-note {
  margin-top: 26px;
  border-top: 1px solid var(--panel-edge);
  padding-top: 14px;
  color: var(--ink-dim);
  font-size: 13.5px;
  line-height: 1.65;
}
.myth-note b { color: #9fb2d8; }

@media (max-width: 900px) {
  .myths-wrap { grid-template-columns: 1fr; }
  .myths-index { position: static; max-height: none; }
}

/* ---------- статистика ---------- */
.stats {
  margin: 0 6px 12px;
  color: var(--ink-dim);
  font-size: 14px;
}
.stats b { color: var(--ink); font-weight: 600; }

/* ---------- сцена ---------- */
.stage {
  border-radius: 16px;
  border: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, #0a101f, #0a0f1e);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
  padding: 6px;
  overflow-x: auto;
}

svg#viz { display: block; width: 100%; height: auto; min-width: 980px; }

/* панельные подписи */
.panel-title { font-size: 15px; font-weight: 600; fill: #c6d3ef; letter-spacing: 0.14em; }
.panel-sub   { font-size: 12.5px; fill: #74839f; letter-spacing: 0.02em; }

.const-line { stroke: #3c4a6e; stroke-width: 1.1; fill: none; opacity: .85; }

.star-label { font-size: 13.5px; fill: #b9c4dc; paint-order: stroke; stroke: #070b16; stroke-width: 3px; }
.dist-label { font-size: 11.5px; fill: #7c8aa6; paint-order: stroke; stroke: #070b16; stroke-width: 3px; }

.tick-label { font-size: 12px; fill: #74839f; }
.axis-title { font-size: 13px; fill: #93a0bd; letter-spacing: 0.06em; }

.connector { stroke-width: 1.1; opacity: .38; }
.connector.hl { opacity: 1; stroke-width: 1.8; }

.star-label.hl { fill: #ffffff; font-weight: 600; }
.dist-label.hl { fill: #dfe7ff; }
.star-dot.hl, .dist-dot.hl { filter: drop-shadow(0 0 6px currentColor); }

.star-dot, .dist-dot { cursor: pointer; transition: r .12s; }

.field-star { opacity: .72; cursor: pointer; }
.field-star.hl { opacity: 1; filter: drop-shadow(0 0 5px currentColor); }

.halo { transition: opacity .12s; }

.g-group { animation: fadein .45s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- легенда / футер ---------- */
.legend {
  margin: 14px 8px 0;
  color: var(--ink-dim);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.dot-demo {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #9db7ff 60%, #4f6bd0);
  box-shadow: 0 0 8px #9db7ff88;
  display: inline-block; flex: none;
}
.dash-demo {
  width: 46px; height: 0;
  border-top: 2px dashed #8ab4ffaa;
  display: inline-block; flex: none; margin: 0 4px;
}

.foot {
  margin: 22px 8px 0;
  color: #5c6883;
  font-size: 12.5px;
}
.foot a { color: #7f9dd8; text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ---------- карточка-обёртка блоков ---------- */
.panel-card {
  border-radius: 16px;
  border: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, #0a101f, #0a0f1e);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
  padding: 20px 22px 14px;
  overflow-x: auto;
}

.orbit-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 34px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 10px;
}
.orbit-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  color: #dfe9ff;
}
.orbit-head p {
  margin: 5px 0 0;
  color: var(--ink-dim);
  font-size: 13.5px;
  max-width: 660px;
}

.orbit-ctl { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#orbit-play {
  background: #16223f;
  color: #fff;
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s;
  white-space: nowrap;
}
#orbit-play:hover { border-color: var(--accent); }

svg#orbit-viz { display: block; width: 100%; height: auto; min-width: 980px; }

.ray-line { stroke: #43507a; stroke-width: 1; stroke-dasharray: 5 6; fill: none; }
.ray-tick { stroke: #56639a; stroke-width: 1.2; }
.ray-tick-label {
  font-size: 11.5px;
  fill: #8fa0c4;
  paint-order: stroke;
  stroke: #070b16;
  stroke-width: 3px;
}
.earth-dot { fill: #6ea8ff; stroke: #cfe1ff; stroke-width: 1; }
.earth-label { font-size: 12.5px; fill: #9db7ff; }

/* ---------- блок дрейфа созвездия ---------- */
#drift-viz { display: block; width: 100%; height: auto; min-width: 980px; }
#drift-play, #drift-back, #drift-reset {
  background: #16223f;
  color: #fff;
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s;
  white-space: nowrap;
}
#drift-reset {
  background: transparent;
  color: var(--ink-dim);
}
#drift-play:hover:not(:disabled), #drift-back:hover:not(:disabled), #drift-reset:hover { border-color: var(--accent); }
#drift-play:disabled, #drift-back:disabled {
  opacity: .45;
  cursor: default;
}
#drift-readout {
  color: var(--ink-dim);
  font-size: 14px;
  min-width: 120px;
  white-space: nowrap;
}
.trail-line { fill: none; opacity: .22; stroke-width: 1.1; }
.trail-line.past { stroke-dasharray: 3 4; opacity: .3; }
.trail-tick { opacity: .5; }
.ghost-dot { fill: none; stroke: #74839f; stroke-width: 1; opacity: .8; }
.end-ring { fill: none; opacity: .55; stroke-width: 1.3; }

/* ---------- тултип ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: rgba(10, 16, 32, 0.96);
  border: 1px solid #2b3c66;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .7);
  max-width: 280px;
  backdrop-filter: blur(4px);
}
.tooltip .t-name { font-size: 15px; font-weight: 650; }
.tooltip .t-bayer { color: var(--accent); font-weight: 400; }
.tooltip .t-con { color: var(--ink-dim); font-size: 12px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 18px; }
.tooltip .t-row span:first-child { color: var(--ink-dim); }
.tooltip .t-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- мобильная раскладка главного блока ---------- */
#viz.mobile .star-label { font-size: 15px; }
#viz.mobile .dist-label { font-size: 13px; }
#viz.mobile .tick-label { font-size: 13px; }
#viz.mobile .axis-title { font-size: 14px; }
#viz.mobile .panel-title { font-size: 16.5px; }
#viz.mobile .panel-sub { font-size: 13px; }

@media (max-width: 900px) {
  html, body { padding: 0 12px 24px; }
  .topbar { padding: 16px 2px 10px; }
  .brand h1 { font-size: 24px; }
  .tagline { font-size: 13px; }
  .controls { gap: 12px; width: 100%; }
  .ctl { width: 100%; }
  select { width: 100%; min-width: 0; }
  .stats { margin: 0 2px 10px; font-size: 13px; }
  .stage { padding: 2px; }
  svg#viz { min-width: 0; }
  .tabs { margin: 8px 2px 14px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 10px 14px 11px; font-size: 14px; white-space: nowrap; }
  .panel-card { padding: 14px 14px 10px; }
  .orbit-head { gap: 10px; }
  .orbit-head h2 { font-size: 18px; }
  .orbit-head p { font-size: 12.5px; }
  .orbit-ctl { width: 100%; align-items: stretch; }
  .orbit-ctl .seg { flex: 1; }
  .orbit-ctl .seg button { flex: 1; padding: 10px 6px; }
  .legend { margin: 10px 2px 0; font-size: 12.5px; }
}
