:root {
  --bg: #0f1720;
  --panel: #161f2b;
  --line: #263241;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #4aa3ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 320px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

#collapse {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

/* Collapsed: keep only the header (title + generated time) visible. */
#panel.collapsed > section,
#panel.collapsed > footer {
  display: none;
}

#panel header h1 {
  font-size: 17px;
  margin: 0 0 2px;
}

#panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}

#generated { margin: 0; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.hint { font-size: 11px; color: var(--muted); margin: 6px 0 0; }

.windows { display: flex; flex-wrap: wrap; gap: 6px; }
.windows button {
  flex: 1 1 0;
  min-width: 60px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.windows button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #04121f;
  font-weight: 600;
}

.series { display: flex; flex-direction: column; gap: 5px; }
.series .bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.series .bar-row .t { width: 42px; color: var(--muted); }
.series .track { flex: 1; height: 14px; background: #0c131c; border-radius: 4px; overflow: hidden; }
.series .fill { height: 100%; border-radius: 4px; }
.series .mm { width: 56px; text-align: right; font-variant-numeric: tabular-nums; }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; cursor: pointer; }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-top: 8px; }
select {
  background: #0c131c; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}

.legend { display: flex; flex-direction: column; gap: 3px; }
.legend .item { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.legend .sw { width: 18px; height: 12px; border-radius: 3px; }

#panel footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}

/* Mobile: dock the panel as a bottom sheet so the map stays the hero. */
@media (max-width: 560px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  }
  /* Collapsed sheet shrinks to just the header, revealing the full map. */
  #panel.collapsed {
    max-height: none;
  }
}
