:root {
  --bg: #060912;
  --panel: #0F1420;
  --card: #151B29;
  --card-2: #0E131E;
  --line: #222A3D;
  --line-2: #263049;
  --fg: #E9ECF2;
  --muted: #A0A9BC;
  --faint: #8C95A8;
  --amber: #F3B649;
  --amber-ink: #1A1405;
  --blue: #8FC1F7;
  --blue-ink: #0A1220;
  --orange: #F0A070;
  --cyan: #6CC4E8;
  --tab-h: calc(58px + env(safe-area-inset-bottom));
  --top: calc(env(safe-area-inset-top) + 8px);
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.night { filter: grayscale(1) sepia(1) saturate(5) hue-rotate(-35deg) brightness(0.85); }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
input, textarea, select { font-family: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.round {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 22px; border: 1px solid var(--line-2);
  background: rgba(14, 19, 30, 0.92); color: var(--fg); padding: 0;
}
.round[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }
.round.sm { border: 0; background: #1A2133; }
.round svg, .pill svg, .tabs svg { display: block; }

.topbar {
  position: absolute; left: 12px; right: 12px; top: var(--top);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  z-index: 3;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border-radius: 20px; border: 1px solid var(--line-2); background: rgba(14, 19, 30, 0.92);
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--fg);
}
.pill.warp { border-color: var(--amber); color: var(--amber); }
.pill.dir { min-height: 44px; border-radius: 22px; }

.sliderbar {
  position: absolute; left: 12px; right: 12px; top: calc(var(--top) + 52px);
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 4px 14px;
  border-radius: 26px; border: 1px solid var(--line-2); background: rgba(14, 19, 30, 0.92);
  z-index: 3;
}
.sliderbar .play {
  width: 40px; height: 40px; flex: none; margin-left: -8px; border: 0; border-radius: 20px;
  background: var(--amber); color: var(--amber-ink); display: inline-flex; align-items: center; justify-content: center;
}
.slider-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.slider-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.slider-labels #sMid { color: var(--amber); }
input[type=range] { width: 100%; accent-color: var(--amber); margin: 4px 0 2px; height: 24px; }

.rightcol {
  position: absolute; right: 12px; top: calc(var(--top) + 116px);
  display: flex; flex-direction: column; gap: 8px; z-index: 3;
}
.menu {
  position: absolute; right: 64px; top: calc(var(--top) + 116px); z-index: 4;
  padding: 8px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(14, 19, 30, 0.96);
  display: flex; flex-direction: column; gap: 2px; min-width: 190px;
}
.menu label { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; font-size: 14px; border-radius: 8px; }
.menu input { width: 18px; height: 18px; accent-color: var(--amber); }

.legend {
  position: absolute; left: 12px; top: calc(var(--top) + 116px); z-index: 2;
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 10px; max-width: calc(100% - 24px);
  border-radius: 12px; background: rgba(14, 19, 30, 0.8); font-size: 11px; color: #C3CAD8; pointer-events: none;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }

.sky-tip {
  position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(14, 19, 30, 0.95);
  font-size: 12px; line-height: 16px; white-space: nowrap;
}
.sky-tip b { font-size: 13px; }
.sky-tip .m { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* Panel */
.sheet {
  position: absolute; left: 0; right: 0; bottom: var(--tab-h); height: 0;
  display: flex; flex-direction: column; overflow: hidden; z-index: 5;
  border-radius: 24px 24px 0 0; border-top: 1px solid transparent; background: var(--panel);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.45);
  transition: height 0.28s ease;
}
.sheet.open { border-top-color: var(--line-2); }
.sheet.dragging { transition: none; }
.sheet-handle { flex: none; height: 26px; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: #3A4560; }
.sheet-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px 8px 16px; }
.sheet-title { flex: 1; min-width: 0; touch-action: none; cursor: grab; }
.sheet-title h2 { margin: 0; font-size: 19px; line-height: 24px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-title .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 24px; }
.pane { display: flex; flex-direction: column; gap: 12px; }
.pad, .sec-head.pad { padding: 0 16px; }

.tabs {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--tab-h); z-index: 6;
  display: flex; padding: 4px 8px env(safe-area-inset-bottom); background: #0B0F18; border-top: 1px solid #1E2638;
}
.tabs button {
  flex: 1; min-height: 50px; border: 0; background: transparent; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500;
}
.tabs button[aria-pressed="true"] { color: var(--amber); }

/* Cards and rows */
.card { padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.card.hot { border-color: #3A3320; }
.card h3, .sec-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 2px; }
.src { font-size: 11px; color: var(--faint); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--fg); text-align: left;
}
.row .t { width: 62px; flex: none; font-family: var(--mono); font-size: 12px; line-height: 16px; }
.row .t .d { color: var(--muted); display: block; }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .main b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main span { font-size: 12px; color: var(--muted); }
.row.hot { border-color: #3A3320; }
.row.sel { border-color: var(--blue); }
.chip { flex: none; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.chip.blue { background: var(--blue); color: var(--blue-ink); }
.chip.amber { background: var(--amber); color: var(--amber-ink); }
.chip.out-amber { border-color: var(--amber); color: var(--amber); }
.chip.out { border-color: #3A4560; color: #C3CAD8; }
.chip.s1 { background: var(--blue); color: var(--blue-ink); }
.chip.s2 { background: var(--amber); color: var(--amber-ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
  border-radius: 14px; border: 1px solid #2A3550; background: #1A2133; color: var(--fg); font-size: 14px; font-weight: 500;
  white-space: nowrap; text-decoration: none;
}
.btn.primary { border: 0; background: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.filters { display: flex; gap: 6px; }
.filters button { min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--card); color: var(--fg); font-size: 14px; font-weight: 500; }
.filters button[aria-pressed="true"] { background: var(--fg); color: #0A0D14; border-color: var(--fg); }
.notice { padding: 12px 14px; border-radius: 14px; border: 1px dashed #3A4560; background: var(--card-2); font-size: 13px; line-height: 18px; color: #C3CAD8; }
.notice b { color: var(--fg); }
.notice button { margin-top: 8px; }

/* Score */
.score { display: flex; align-items: center; gap: 14px; }
.score .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.score .big { font-size: 17px; font-weight: 600; }

/* Embed */
.embed-wrap { width: 100%; min-width: 350px; }
#astroEmbed { width: 100%; min-height: 120px; }

/* Launch timeline */
.tl { display: flex; flex-direction: column; }
.tl-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border-radius: 8px; }
.tl-row.active { background: #1E2740; }
.tl-row.past { color: var(--faint); }
.tl-row .a { width: 50px; flex: none; font-family: var(--mono); font-size: 12px; }
.tl-row .b { width: 62px; flex: none; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tl-row .c { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-row .chip { min-width: 40px; text-align: center; font-size: 10px; }

/* Settings dialog */
dialog {
  width: min(520px, calc(100% - 24px)); max-height: calc(100% - 48px); padding: 0;
  border-radius: 20px; border: 1px solid var(--line-2); background: var(--panel); color: var(--fg);
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 20px; }
.dlg h2 { margin: 0; font-size: 20px; }
.dlg .field { display: flex; flex-direction: column; gap: 6px; }
.dlg label { font-size: 13px; color: var(--muted); }
.dlg input, .dlg select {
  width: 100%; min-width: 0;
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--card-2); color: var(--fg); font-size: 16px;
}
.dlg .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.dlg .hint { font-size: 12px; color: var(--faint); line-height: 17px; }
.dlg .hint a { color: var(--blue); }

.toast {
  position: absolute; left: 50%; bottom: calc(var(--tab-h) + 16px); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px; background: #1E2740; border: 1px solid var(--line-2);
  font-size: 13px; line-height: 18px; text-align: center;
}
