:root {
  --bg: #05070d;
  --bg2: #0a0e18;
  --panel: #0c111b;
  --line: #1a2232;
  --line2: #2a3448;
  --text: #e6ebf5;
  --muted: #9ba7bd;
  --faint: #7c88a1;
  --accent: #ffb547;
  --accent2: #62d0ff;
  --accent-ink: #ffb547;
  --accent2-ink: #62d0ff;
  --header-bg: rgba(5, 7, 13, 0.82);
  --chip-bg: #111827;
  --control-bg: #0e1420;
  --input-bg: #070a12;
  --dialog-bg: #0d1220;
  --tooltip-bg: rgba(8, 11, 20, 0.94);
  --hover: rgba(255, 181, 71, 0.08);
  --note-bg: rgba(98, 208, 255, 0.07);  --note-ink: #bfe9ff;
  --warm-bg: rgba(255, 181, 71, 0.08);  --warm-ink: #ffe2b0;
  --thumb: rgba(140, 170, 220, 0.25);
  --ic-line: #7aa0e6;  --ic-text: #c9d4ec;  --ic-mw: rgba(190, 205, 255, 0.45);
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  color-scheme: dark;
}
/* Light theme: the sky map and the vertical line stay night-dark (they are the sky); the frame turns light. */
:root[data-theme="light"] {
  --bg: #f3f4f7;
  --bg2: #e9ecf1;
  --panel: #ffffff;
  --line: #e1e4ea;
  --line2: #c9cfd9;
  --text: #13161d;
  --muted: #4b5364;
  --faint: #5c6576;
  --accent-ink: #9a5600;
  --accent2-ink: #0a679c;
  --header-bg: rgba(243, 244, 247, 0.9);
  --chip-bg: #ffffff;
  --control-bg: #ffffff;
  --input-bg: #ffffff;
  --dialog-bg: #ffffff;
  --tooltip-bg: rgba(255, 255, 255, 0.97);
  --hover: rgba(255, 181, 71, 0.16);
  --note-bg: #e9f5fc;  --note-ink: #0b4a6e;
  --warm-bg: #fff3df;  --warm-ink: #6e4100;
  --thumb: rgba(20, 30, 50, 0.22);
  --ic-line: #4a6fb5;  --ic-text: #39435a;  --ic-mw: rgba(60, 80, 140, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 18px clamp(16px, 3vw, 36px) 8px;
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.logo { color: var(--text); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; display: inline-flex; align-items: center; }
.logo-mark { width: 30px; height: 30px; margin-left: -4px; flex: none; }
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tag { margin: 0; padding-left: 14px; border-left: 1px solid var(--line2); color: var(--muted); font-size: 13px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.timebar { display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line2); background: var(--chip-bg);
  cursor: pointer; white-space: nowrap; font-size: 14px;
}
.chip:hover { border-color: rgba(255, 181, 71, 0.5); }
.chip svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; }
.chip.icon { padding: 0 10px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.chip.time { font-family: var(--mono); font-size: 13px; min-width: 150px; justify-content: center; }
.chip.time.offset { border-color: rgba(98, 208, 255, 0.6); }
select.chip { appearance: none; padding: 0 12px; font-family: var(--mono); font-size: 13px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff5a5a; animation: pulse 2s infinite; }
.time.offset .live-dot { background: var(--accent2); animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
#loc-label { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- layout ---------- */
.layout {
  display: grid; gap: 16px;
  padding: 8px clamp(16px, 3vw, 36px) 24px;
  grid-template-columns: minmax(0, 1fr) 300px 360px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "hero hero side"
    "dome column side";
  align-items: start;
}
.hero { grid-area: hero; padding: 8px 4px 4px; }
.dome-wrap { grid-area: dome; }
.column-wrap { grid-area: column; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 16px; grid-row: 1 / span 2; }

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "hero side" "dome side" "column side";
  }
  .side { grid-row: 1 / span 3; }
  .column-wrap .column { height: 640px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "hero" "dome" "column" "side"; }
  .side { grid-row: auto; }
  .tag { display: none; }
  .top { padding-top: 12px; padding-bottom: 10px; }
  .controls { width: 100%; justify-content: space-between; }
  .chip.time { min-width: 0; }
  #loc-label { max-width: 130px; }
}

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.panel-head { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: 0.01em; }
.hint { color: var(--faint); font-size: 13px; }
.hint.small { margin: 8px 0 0; }

/* ---------- hero ---------- */
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
#headline {
  margin: 0; font-size: clamp(22px, 3vw, 34px); line-height: 1.3; font-weight: 700; letter-spacing: -0.02em;
  text-wrap: pretty; word-break: keep-all;
}
#headline b, .subline b { color: var(--accent-ink); font-weight: 700; }
#headline b.place { color: var(--accent2-ink); }
.subline { margin: 10px 0 0; color: var(--muted); font-size: 15px; max-width: 1100px; text-wrap: pretty; word-break: keep-all; }
.subline b { color: var(--text); font-weight: 600; }
.hl-link { cursor: pointer; border-bottom: 1px dashed currentColor; }

/* ---------- dome ---------- */
.dome { position: relative; width: 100%; aspect-ratio: 1; max-height: 78vh; margin: 0 auto; touch-action: none; }
.dome canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.zoom { position: absolute; right: 6px; top: 6px; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line2); background: var(--control-bg);
  cursor: pointer; font-size: 18px; line-height: 1;
}
.zoom button:hover { border-color: var(--accent); }
.tooltip {
  position: absolute; pointer-events: none; padding: 6px 9px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  background: var(--tooltip-bg); border: 1px solid var(--line2); white-space: nowrap; transform: translate(12px, -50%);
}
.tooltip .t-sub { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--control-bg); color: var(--text); font-size: 13px; cursor: pointer;
}
.legend button:hover { border-color: rgba(255, 181, 71, 0.5); }
.legend button[aria-pressed="false"] { color: var(--faint); background: transparent; border-style: dashed; }
.legend button[aria-pressed="false"] span { text-decoration: line-through; }
.legend button[aria-pressed="false"] i { opacity: 0.25; box-shadow: none; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); font-style: normal; }
.legend i.ic-line { width: 12px; height: 2px; border-radius: 1px; background: var(--ic-line); box-shadow: none; }
.legend i.ic-text { width: auto; height: auto; background: none; box-shadow: none; font-size: 11px; font-weight: 700; color: var(--ic-text); }
.legend i.ic-mw { width: 14px; height: 8px; background: var(--ic-mw); border-radius: 4px; }
.legend .sep { width: 1px; height: 18px; background: var(--line2); margin: 0 4px; }
.legend-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--muted); align-items: center; }
.legend-foot .shadow-note i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #62d0ff; opacity: 0.35; margin-right: 6px; }
.count { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--faint); }

/* collapsible panel */
details.fold > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2::before { content: '▸'; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform 0.15s; }
details.fold[open] > summary h2::before { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 10px; }

/* ---------- column ---------- */
.column { position: relative; height: min(78vh, 900px); min-height: 560px; }
.column canvas { width: 100%; height: 100%; display: block; cursor: pointer; }

/* ---------- side lists ---------- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.facts dd .mono { font-family: var(--mono); font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 2px 10px; align-items: center;
  padding: 8px 6px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.list li:hover, .list li.sel { background: var(--hover); }
.list li.empty { display: block; color: var(--faint); cursor: default; font-size: 13px; }
.list li.empty:hover { background: none; }
.list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.list .dot.off { opacity: 0.35; }
.list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .nm small { color: var(--faint); margin-left: 6px; font-size: 12px; }
.list .val { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.list .val b { color: var(--text); font-weight: 600; }
.list .below { opacity: 0.45; }
.list .sub { grid-column: 2 / span 2; color: var(--faint); font-size: 12.5px; margin-top: -2px; }

.close { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.close:hover { color: var(--text); }
#detail-panel { border-color: rgba(255, 181, 71, 0.35); }
#detail .kind { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--c, var(--line2)); color: var(--c, var(--muted)); margin-bottom: 8px; }
#detail .big { font-size: 20px; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.01em; }
#detail .alt-name { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
#detail .note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--note-bg); color: var(--note-ink); font-size: 14px; }
#detail .note.warm { background: var(--warm-bg); color: var(--warm-ink); }
#detail .links { margin-top: 10px; font-size: 12.5px; }

/* ---------- footer ---------- */
.foot { padding: 4px 4px 16px; color: var(--faint); font-size: 12.5px; }
.foot p { margin: 4px 0; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line2); border-radius: 16px; background: var(--dialog-bg); color: var(--text);
  padding: 22px; width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.loc-form h2 { margin: 0 0 14px; font-size: 18px; }
.loc-form button {
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2); background: var(--control-bg); cursor: pointer;
}
.loc-form button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 650; }
#geo-btn { width: 100%; }
.geo-msg { min-height: 1em; margin: 8px 0; font-size: 12.5px; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.presets button { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 999px; }
.latlon { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.latlon label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.latlon input { height: 38px; border-radius: 10px; border: 1px solid var(--line2); background: var(--input-bg); padding: 0 10px; font-family: var(--mono); font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- segmented toggle ---------- */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 999px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--hover); color: var(--accent-ink); }
.seg-hint { margin: -4px 0 8px; }
.list .rank { grid-column: 1; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.badge { display: inline-block; font-size: 11.5px; padding: 0 7px; margin-left: 6px; border-radius: 999px; border: 1px solid var(--c); color: var(--c); opacity: 0.85; vertical-align: 1px; }

/* ---------- wide screens: page fits the window, only the right column scrolls ---------- */
@media (min-width: 1281px) and (min-height: 700px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  .top { flex: none; }
  .layout {
    flex: 1; min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    padding-bottom: 16px;
  }
  .dome-wrap, .column-wrap { display: flex; flex-direction: column; min-height: 0; }
  .dome { flex: 1; min-height: 0; aspect-ratio: auto; max-height: none; }
  .column { flex: 1; min-height: 0; height: auto; }
  .side {
    min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding-right: 6px; margin-right: -6px;
    scrollbar-width: thin; scrollbar-color: var(--thumb) transparent;
  }
  .side::-webkit-scrollbar { width: 6px; }
  .side::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 3px; }
}

/* ---------- badge legend ---------- */
.badge-group + .badge-group { margin-top: 14px; }
.badge-group h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.badge-row { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: baseline; padding: 5px 0; font-size: 13px; }
.badge-row .badge { margin: 0; white-space: nowrap; }
.badge-row .desc { color: var(--muted); line-height: 1.45; }
.badge-row .n { font-family: var(--mono); font-size: 12.5px; color: var(--faint); text-align: right; }
.badge-row .n.has { color: var(--text); }

/* ---------- compact sticky header on phones ---------- */
@media (max-width: 860px) {
  .top { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; }
  .controls { display: contents; }
  .top { grid-template-columns: 1fr auto auto; }
  #lang-btn { grid-column: 2; grid-row: 1; }
  #loc-btn { grid-column: 3; grid-row: 1; }
  .timebar { grid-column: 1 / 3 !important; grid-row: 2; }
  #theme-btn { grid-column: 3; grid-row: 2; justify-self: end; }
  .timebar { grid-column: 1 / -1; justify-content: space-between; }
  .timebar .chip.time { flex: 1 1 auto; min-width: 96px; padding: 0 8px; }
  .timebar .chip.icon { padding: 0 8px; }
  .timebar select.chip { padding: 0 8px; }
}

.chip.lang { font-size: 12.5px; font-weight: 600; padding: 0 11px; }
.con-link { color: inherit; border-bottom: 1px dashed rgba(255, 181, 71, 0.55); }
.con-link:hover { text-decoration: none; border-bottom-style: solid; }

/* ---------- visitor counter ---------- */
.hero-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 6px; }
.hero-top .eyebrow { margin: 0; }
.stats { margin: 0; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 13px; }
.stats .live-dot { width: 6px; height: 6px; background: #4ade80; }
.stats .sep { color: var(--faint); }

#geo-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#geo-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

/* theme toggle: show the icon of the theme you would switch to */
.chip.icon-only { width: 36px; padding: 0; justify-content: center; }
.chip.icon-only svg { width: 17px; height: 17px; stroke: var(--text); fill: none; stroke-width: 1.8; stroke-linecap: round; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }
/* satellite name in the headline takes its badge colour; data colours are darkened for text on light */
#headline b.hl-link { color: var(--c); }
:root[data-theme="light"] #headline b.hl-link, :root[data-theme="light"] .badge, :root[data-theme="light"] #detail .kind {
  color: color-mix(in oklab, var(--c) 52%, #000);
  border-color: color-mix(in oklab, var(--c) 60%, #000);
}
:root[data-theme="light"] .loc-form button.primary { color: #1a1205; }

.logo { white-space: nowrap; }
/* very narrow phones: keep the header to two rows */
@media (max-width: 400px) {
  .logo { font-size: 18px; }
  .logo-mark { width: 26px; height: 26px; }
  #loc-btn { padding: 0 10px; gap: 4px; }
  #loc-btn svg { display: none; }
  #loc-label { max-width: 96px; }
  .chip.lang { padding: 0 9px; }
}
