:root {
  --bg: #050816;
  --bg-2: #0b1230;
  --panel: rgba(18, 26, 60, 0.62);
  --panel-border: rgba(140, 160, 255, 0.16);
  --text: #e7ebff;
  --muted: #9aa3c7;
  --accent: #8fb3ff;
  --accent-2: #ffd27a;
  --line: rgba(143, 179, 255, 0.55);
  --radius: 16px;
  --max: 1160px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: radial-gradient(ellipse at 20% -10%, #1b2a6b 0%, transparent 55%),
              radial-gradient(ellipse at 110% 30%, #3a1b5c 0%, transparent 45%),
              linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
  background-attachment: fixed;
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

a { color: var(--accent); }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(5, 8, 22, 0.6);
  border-bottom: 1px solid var(--panel-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.logo svg { width: 28px; height: 28px; }

.site-header nav {
  display: flex;
  gap: 20px;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--text); }

/* ---------- Hero ---------- */

.hero {
  padding: 64px 0 32px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.15;
  background: linear-gradient(90deg, #fff, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  max-width: 640px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ---------- Фильтры ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters button {
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.filters button:hover { color: var(--text); }
.filters button[aria-pressed="true"] {
  color: #0b1230;
  background: var(--accent);
  border-color: var(--accent);
}

.search {
  flex: 1 1 220px;
  max-width: 320px;
  font: inherit;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--muted); }

/* ---------- Сетка карточек ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card[hidden] { display: none; }

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(143, 179, 255, 0.5);
  box-shadow: 0 12px 40px -12px rgba(110, 140, 255, 0.45);
  outline: none;
}

.card-art {
  aspect-ratio: 4 / 3;
  padding: 18px 28px;
  background: radial-gradient(circle at 50% 40%, rgba(70, 90, 200, 0.25), transparent 70%);
  border-bottom: 1px solid var(--panel-border);
}

.card-body { padding: 16px 18px 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--accent-2);
  border: 1px solid rgba(255, 210, 122, 0.35);
}

.latin {
  margin: 2px 0 8px;
  color: var(--accent);
  font-style: italic;
  font-size: 0.9rem;
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 0 64px;
}

/* ---------- Схема ---------- */

.diagram {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.diagram-lines line {
  stroke: var(--line);
  stroke-width: 0.7;
  stroke-linecap: round;
}

.diagram .glow { fill: rgba(170, 195, 255, 0.18); }
.diagram .core { fill: #fff; filter: drop-shadow(0 0 1.5px #bcd0ff); }

.diagram text {
  fill: var(--muted);
  font-size: 3.6px;
  font-family: inherit;
  pointer-events: none;
}

.diagram-star { cursor: default; }
.diagram-star:hover .core { fill: var(--accent-2); }
.diagram-star:hover text { fill: var(--text); }

.card:hover .diagram-lines line { stroke: rgba(255, 210, 122, 0.7); }

/* ---------- Детальная страница ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 28px 0 8px;
  color: var(--muted);
  text-decoration: none;
}
.back:hover { color: var(--text); }

.detail-head h1 {
  margin: 0;
  font-size: clamp(2rem, 5.5vw, 3rem);
  line-height: 1.15;
}

.detail-head .latin { font-size: 1.1rem; margin-top: 4px; }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 28px;
  margin: 24px 0;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  padding: 20px 22px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--accent-2);
}

.panel p { margin: 0 0 12px; }
.panel p:last-child { margin-bottom: 0; }

.diagram-panel {
  padding: 28px;
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle at 50% 45%, rgba(70, 90, 200, 0.28), transparent 70%), var(--panel);
}

.diagram-panel .diagram text { font-size: 3.4px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.stats div {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
}

.stats dt {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats dd {
  margin: 4px 0 0;
  font-weight: 600;
}

.side { display: grid; gap: 20px; }

.content { display: grid; gap: 20px; margin-bottom: 32px; }

.facts {
  margin: 0;
  padding-left: 20px;
}
.facts li { margin-bottom: 8px; }
.facts li::marker { color: var(--accent); }

.star-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.star-list li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed var(--panel-border);
}
.star-list li:last-child { border-bottom: 0; }
.star-list .mag { color: var(--muted); font-variant-numeric: tabular-nums; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 48px;
}

.pager a {
  display: block;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: border-color .2s;
}
.pager a:hover { border-color: var(--accent); }
.pager strong { display: block; color: var(--text); font-size: 1rem; }
.pager .next { text-align: right; }

.not-found {
  text-align: center;
  padding: 80px 0;
}

/* ---------- Трансляция ---------- */

.hero-compact { padding: 48px 0 24px; }

.live-panel,
.iss-panel { margin-bottom: 24px; }

.live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.live-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4d5e;
  box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(255, 77, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0); }
}

.pill-link {
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-decoration: none;
  transition: color .2s, border-color .2s;
}
.pill-link:hover { color: var(--text); border-color: var(--accent); }

.video {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.note[hidden] { display: none; }

.iss-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.iss-map {
  height: 420px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #0b0f1f;
}
.iss-map[hidden] { display: none; }

.iss-stats dd { font-variant-numeric: tabular-nums; }

.iss-icon {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 210, 122, 0.18);
  border: 2px solid var(--accent-2);
  box-shadow: 0 0 18px rgba(255, 210, 122, 0.6);
}
.iss-icon span {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-2);
}

.leaflet-container { font-family: inherit; }

/* Тёмная версия стандартных тайлов OpenStreetMap */
.iss-map .leaflet-tile-pane {
  filter: invert(1) hue-rotate(200deg) brightness(0.85) contrast(0.9) saturate(0.5);
}
.leaflet-control-attribution {
  background: rgba(5, 8, 22, 0.7) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

@media (max-width: 860px) {
  .iss-layout { grid-template-columns: 1fr; }
  .iss-map { height: 320px; }
  .stats.iss-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .site-header nav a:first-child { display: none; }
  .hero-compact { padding: 32px 0 16px; }
  .live-head { flex-direction: column; align-items: stretch; }
  .pill-link { text-align: center; }
  .iss-map { height: 260px; }
  .stats.iss-stats { grid-template-columns: 1fr 1fr; }
}

/* ---------- Подвал ---------- */

.site-footer {
  border-top: 1px solid var(--panel-border);
  padding: 20px 0 28px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Адаптив ---------- */

@media (max-width: 860px) {
  .detail-layout { grid-template-columns: 1fr; }
  .diagram-panel { max-width: 520px; width: 100%; margin: 0 auto; }
}

@media (max-width: 560px) {
  .hero { padding: 40px 0 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex: none; max-width: none; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .card { flex-direction: row; }
  .card-art {
    flex: 0 0 112px;
    aspect-ratio: auto;
    padding: 12px;
    border-bottom: 0;
    border-right: 1px solid var(--panel-border);
  }
  .card-body { padding: 12px 14px; }
  .card h2 { font-size: 1.05rem; }
  .summary { font-size: 0.88rem; }
  .stats { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .diagram-panel { padding: 16px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .card:hover { transition: none; transform: none; }
  .live-dot { animation: none; }
}
