:root {
  --bg: #05060c;
  --panel: rgba(14, 18, 32, 0.82);
  --panel-border: rgba(120, 140, 200, 0.18);
  --text: #e8ecf6;
  --muted: #8891a8;
  --nasa: #4aa3ff;
  --esa: #4be0b0;
  --jaxa: #ff7a6b;
  --accent: #ffcf4d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  overflow: hidden;
}

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

#sky { display: block; width: 100%; height: 100%; cursor: grab; }
#sky:active { cursor: grabbing; }

#topbar { position: absolute; top: 14px; left: 18px; pointer-events: none; }
#topbar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.02em; }
#topbar h1 span { color: var(--muted); font-weight: 300; }
#clock {
  margin-top: 3px; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted);
}
#clock .live { color: var(--esa); font-weight: 600; }
#clock .sim { color: var(--accent); font-weight: 600; }

#panel {
  position: absolute;
  top: 14px; right: 14px;
  width: 236px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  font-size: 13px;
}
#panel section { padding: 9px 0; border-bottom: 1px solid var(--panel-border); }
#panel section:last-of-type { border-bottom: none; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; }
.row > span { color: var(--muted); white-space: nowrap; }
.row select, .row input[type="range"] { flex: 1; min-width: 0; }
.toggles { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

select, input[type="search"] {
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 4px 7px; font-size: 12px;
}
input[type="search"] { width: 100%; }

.toggle { display: flex; align-items: center; gap: 7px; margin: 6px 0; cursor: pointer; }
.legend-title { color: var(--muted); margin-bottom: 5px; }
.agency::before { content: ""; width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: auto; }
.agency.nasa::before { background: var(--nasa); }
.agency.esa::before { background: var(--esa); }
.agency.jaxa::before { background: var(--jaxa); }

#objlist { list-style: none; margin: 8px 0 0; padding: 0; max-height: 190px; overflow-y: auto; }
#objlist li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 7px; cursor: pointer; font-size: 12px;
}
#objlist li:hover { background: rgba(255,255,255,0.06); }
#objlist li.sel { background: rgba(74,163,255,0.16); }
#objlist .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#objlist .sub { color: var(--muted); margin-left: auto; font-size: 11px; }

.info { margin-top: 10px; padding: 10px; background: rgba(255,255,255,0.04); border-radius: 10px; font-size: 12px; line-height: 1.5; }
.info.hidden { display: none; }
.info h3 { margin: 0 0 4px; font-size: 14px; }
.info .agency-tag { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11px; margin-bottom: 6px; }
.info dt { color: var(--muted); }
.info dl { margin: 4px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }

/* ---- timeline ---- */
#timeline {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px 14px;
  background: linear-gradient(to top, rgba(5,6,12,0.92), rgba(5,6,12,0));
}
.tl-controls { display: flex; align-items: center; gap: 8px; flex: none; }
#playBtn, #nowBtn {
  background: rgba(255,255,255,0.08); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; line-height: 1;
}
#playBtn.playing { background: var(--accent); color: #05060c; border-color: var(--accent); }
#nowBtn { font-size: 12px; }

.tl-track {
  position: relative; flex: 1; height: 30px; cursor: pointer;
  background: rgba(255,255,255,0.05); border-radius: 8px;
  border: 1px solid var(--panel-border);
}
.tl-fill { position: absolute; top: 0; bottom: 0; left: 0; background: rgba(74,163,255,0.12); border-radius: 8px 0 0 8px; }
.tl-head { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); pointer-events: none; }
.tl-head::after { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
#tlEvents { position: absolute; inset: 0; pointer-events: none; }
.tl-ev { position: absolute; top: 4px; width: 2px; height: 22px; background: var(--esa); opacity: 0.75; }
.tl-ev.past { background: var(--muted); opacity: 0.5; }
.tl-tip {
  position: absolute; bottom: 34px; transform: translateX(-50%);
  background: rgba(14,18,32,0.96); border: 1px solid var(--panel-border);
  border-radius: 7px; padding: 5px 9px; font-size: 11px; white-space: nowrap; pointer-events: none;
}
.tl-tip.hidden { display: none; }
.tl-tip .d { color: var(--muted); }

@media (max-width: 680px) {
  #panel { width: 190px; font-size: 12px; }
  #timeline { flex-wrap: wrap; gap: 8px; }
  .tl-track { order: 2; width: 100%; flex-basis: 100%; }
}
