:root {
  --bg: #000000;
  --panel: rgba(14, 14, 17, 0.72);
  --panel-solid: #0c0c0f;
  --hair: rgba(255, 255, 255, 0.08);
  --hair-strong: rgba(255, 255, 255, 0.16);
  --ink: #f2f3f5;
  --ink-dim: #9498a1;
  --ink-faint: #5b5f68;
  --radius: 13px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* accessible text alternative to the canvas — read by screen readers & crawlers */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

#map { position: fixed; inset: 0; background: var(--bg); }
#map canvas { outline: none; }

/* ---- top bar ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; z-index: 10; pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: conic-gradient(from 210deg, #e85d4a, #d6a05c, #6eb0a8, #5d96e0, #e85d4a);
  box-shadow: 0 0 0 1px var(--hair-strong), 0 0 22px rgba(93,150,224,0.28);
}
.brandtext h1 {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1;
}
.brandtext p {
  margin: 3px 0 0; font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.01em;
}
.period {
  pointer-events: auto;
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
  padding: 6px 11px; border: 1px solid var(--hair); border-radius: 8px;
  background: var(--panel); backdrop-filter: blur(10px);
}

/* ---- control panel ---- */
.panel {
  position: fixed; left: 22px; bottom: 22px; z-index: 10;
  width: 268px; padding: 16px 16px 13px;
  background: var(--panel); backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--hair); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.panel-block { margin-bottom: 15px; }
.panel-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-faint); margin-bottom: 9px; font-weight: 500;
}
.time-value { font-family: var(--mono); color: var(--ink); letter-spacing: 0; text-transform: none; }

/* commodity chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px 6px 9px; border-radius: 999px; cursor: pointer;
  font-size: 12px; color: var(--ink-dim); user-select: none;
  border: 1px solid var(--hair); background: rgba(255,255,255,0.02);
  transition: color .15s, border-color .15s, background .15s, opacity .15s;
}
.chip .dot {
  width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor; flex: 0 0 auto;
}
.chip.on { color: var(--ink); border-color: var(--hair-strong); background: rgba(255,255,255,0.05); }
.chip.off { opacity: 0.42; }
.chip.off .dot { box-shadow: none; }
.chip:hover { border-color: var(--hair-strong); }

/* value/weight segmented */
.seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--hair); border-radius: 9px;
}
.seg button {
  appearance: none; border: 0; cursor: pointer;
  font-family: var(--sans); font-size: 12px; color: var(--ink-dim);
  padding: 5px 14px; border-radius: 6px; background: transparent; transition: all .15s;
}
.seg button.on { color: #000; background: var(--ink); font-weight: 500; }

/* slider */
.slider { width: 100%; -webkit-appearance: none; appearance: none; height: 3px; border-radius: 3px;
  background: var(--hair-strong); outline: none; margin: 4px 0 2px; cursor: pointer; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 2px solid #000; box-shadow: 0 0 0 1px var(--hair-strong);
}
.slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--ink);
  border: 2px solid #000; box-shadow: 0 0 0 1px var(--hair-strong);
}

.panel-foot { border-top: 1px solid var(--hair); padding-top: 11px; }
.stat { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); line-height: 1.5; cursor: help; }
.stat b { color: var(--ink); font-weight: 500; }
.tt-note { font-size: 11.5px; color: var(--ink-dim); line-height: 1.45; }
.tt-note b { color: var(--ink); font-weight: 600; }

/* ---- tooltip ---- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  min-width: 160px; max-width: 240px; padding: 10px 12px;
  background: var(--panel-solid); border: 1px solid var(--hair-strong);
  border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  transform: translate(-50%, calc(-100% - 14px)); transition: opacity .1s;
}
.tt-route { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.tt-route .arrow { color: var(--ink-faint); }
.tt-comm { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-dim); margin-bottom: 8px; }
.tt-comm .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.tt-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.tt-rows .k { font-size: 11px; color: var(--ink-faint); }
.tt-rows .v { font-family: var(--mono); font-size: 12px; color: var(--ink); text-align: right; }

/* ---- legend / source ---- */
.legend {
  position: fixed; right: 22px; bottom: 22px; z-index: 10;
  font-size: 10.5px; color: var(--ink-faint); font-family: var(--mono);
  text-align: right; max-width: 320px; line-height: 1.5;
}
.legend a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--hair); }

@media (max-width: 640px) {
  .panel { left: 12px; right: 12px; bottom: 12px; width: auto; }
  #topbar { padding: 12px 14px; }
  .legend { display: none; }
}
