:root {
  --bg: #0b1120;
  --panel: rgba(15, 23, 42, 0.86);
  --border: rgba(148, 163, 184, 0.18);
  --fg: #e5e7eb;
  --title: #f9fafb;
  --muted: #94a3b8;
  --faint: #64748b;
  --blue: #3b82f6;
  --orange: #f97316;
  --gap: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 13px/1.4 Inter, system-ui, sans-serif; overflow: hidden; }
#map { position: absolute; inset: 0; }
a { color: var(--blue); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }

.panel { position: absolute; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0; }
.label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  margin: 10px 0 6px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; }
label.check { flex-direction: row; align-items: center; gap: 6px; margin: 8px 0; color: var(--fg); }

button, .button, select, input { font: inherit; color: var(--fg); border-radius: 8px; border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.8); padding: 6px 10px; }
button, .button { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s; }
button:hover, .button:hover { border-color: var(--muted); }
button svg, .button svg { width: 15px; height: 15px; }
button.ghost, .button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover, .button.ghost:hover { color: var(--fg); background: rgba(148, 163, 184, 0.12); }
button.outline { border-color: var(--blue); color: #93c5fd; background: transparent; }
button.outline.active { background: var(--blue); color: white; }
button.primary { background: var(--blue); border-color: var(--blue); color: white; font-weight: 600; }
button.accent { background: var(--orange); border-color: var(--orange); color: white; font-weight: 600; }
input { width: 100%; }
select { cursor: pointer; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--muted);
  justify-content: center; padding: 6px 4px; font-size: 12px; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--blue); color: white; }

#controls { top: var(--gap); left: var(--gap); padding: 12px 14px; max-width: 440px; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { color: var(--orange); font-size: 26px; font-weight: 700; line-height: 1; }
h1 { font-size: 16px; margin: 0; color: var(--title); font-weight: 600; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
#variable { font-weight: 500; }
#region-text { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.popover { width: 300px; padding: 12px 14px; z-index: 5; }
#region-menu { top: 150px; left: var(--gap); }
#display-menu { top: 150px; left: var(--gap); }

#legend { top: var(--gap); right: var(--gap); width: 270px; padding: 12px 14px; }
.legend-title { display: flex; justify-content: space-between; font-weight: 600; color: var(--title); }
#busy { color: var(--orange); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.spinner { width: 12px; height: 12px; border: 2px solid rgba(249, 115, 22, .3); border-top-color: var(--orange);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#colorbar { height: 12px; border-radius: 6px; margin: 8px 0 4px; }
.ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.stats { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.stats b { color: var(--fg); font-weight: 600; }

#time { left: var(--gap); right: var(--gap); bottom: var(--gap); padding: 8px 14px 6px; }
.time-top { display: flex; justify-content: space-between; height: 18px; font-size: 12px; }
#readout { color: var(--muted); }
#selection { color: var(--orange); font-weight: 600; }
#timeline { width: 100%; height: 46px; display: block; cursor: crosshair; touch-action: none; }
#time .hint { margin: 2px 0 0; font-size: 11px; }

#overview { position: absolute; left: var(--gap); bottom: 170px; width: 170px; height: 83px; cursor: pointer;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5)); }
#coords { position: absolute; right: var(--gap); bottom: 128px; padding: 4px 8px; border-radius: 6px;
  background: var(--panel); color: var(--fg); font-size: 12px; font-variant-numeric: tabular-nums; }
#coords:empty { display: none; }
body.globe #overview { display: none; }
#projection { position: absolute; left: var(--gap); bottom: 128px; background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0, 0, 0, .4); }
.maplibregl-ctrl-bottom-right { bottom: 160px; }

/* the time series at a point: a card tied to the point by a line */
.pin { position: relative; width: 0; height: 0; }
.pin .dot { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: white; border: 3px solid var(--orange); }
.pin > svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.pin line { stroke: var(--orange); stroke-width: 1.5; }
.card { position: absolute; width: 440px; height: 250px; resize: both; overflow: hidden; min-width: 320px; min-height: 200px; padding: 10px 12px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); cursor: default; }
.card header { cursor: move; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card h3 { margin: 0; font-size: 13px; color: var(--title); }
.card .hint { margin: 1px 0 0; white-space: pre-line; }
.card header .tools { display: flex; align-items: center; gap: 4px; }
.card select { padding: 2px 6px; font-size: 12px; }
.card .chart { margin-top: 4px; }
.card .u-over { cursor: pointer; }
.card.compact { width: 300px; height: auto; min-height: 0; resize: none; }
.card.compact .chart { display: none; }
.card .expand { margin-top: 6px; padding: 3px 10px; font-size: 12px; font-weight: 500; background: transparent;
  color: var(--orange); border-color: rgba(249, 115, 22, 0.6); }
.card .expand:hover { background: rgba(249, 115, 22, 0.15); border-color: var(--orange); }
.card .expand svg { width: 13px; height: 13px; }
.card:not(.compact) .expand { display: none; }
.card .hint .spinner { display: inline-block; vertical-align: middle; }
.tip { position: absolute; pointer-events: none; white-space: nowrap; padding: 3px 7px; border-radius: 6px; z-index: 5;
  background: rgba(2, 6, 23, 0.9); border: 1px solid var(--orange); color: var(--fg); font-size: 11px; }
.card .loading { height: 180px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.uplot { font-family: Inter, system-ui, sans-serif; }
.card.transect { position: fixed; right: var(--gap); bottom: 170px; width: 600px; height: 320px; z-index: 3; }
.tip.floating { position: fixed; z-index: 10; display: none; }
.tip table { border-collapse: collapse; margin-top: 2px; }
.tip th { color: var(--orange); font-weight: 500; text-align: right; padding: 0 0 1px 10px; }
.tip td { text-align: right; padding: 0 0 0 10px; font-variant-numeric: tabular-nums; }
.tip td:first-child, .tip th:first-child { padding: 0; }
.tip .picked tr:not(:first-child):not(.on) { opacity: 0.45; }
.tip tr.on td { color: #fff; font-weight: 600; background: rgba(255, 255, 255, 0.08); }
.tip tr.on i { height: 5px; }
.tip i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; }

dialog.panel { position: fixed; color: var(--fg); padding: 16px 20px; max-width: 720px; width: calc(100% - 40px); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog header { display: flex; justify-content: space-between; align-items: center; }
dialog h2 { margin: 0; font-size: 16px; color: var(--title); }
dialog h3 { font-size: 13px; color: var(--title); margin: 14px 0 4px; }
dialog pre[class*="language-"] { background: rgba(2, 6, 23, .7); margin: 8px 0; }
dialog pre { background: rgba(2, 6, 23, .7); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  overflow: auto; font-size: 12px; max-height: 50vh; }
dialog table { border-collapse: collapse; width: 100%; margin: 8px 0; }
dialog th, dialog td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
dialog td + td, dialog th + th { text-align: right; }

#toast { left: 50%; transform: translateX(-50%); top: var(--gap); padding: 10px 14px; border-color: var(--orange);
  z-index: 10; max-width: 480px; }
