:root {
  --bg: #0a0e14;
  --bg-2: #0f1620;
  --panel: #131c28;
  --panel-2: #18232f;
  --line: #223142;
  --ink: #e8eef4;
  --ink-dim: #8ea0b2;
  --ink-faint: #56697b;
  --accent: #4dd6c1;
  --accent-2: #ffcf5c;

  /* dB colour scale — quiet → loud */
  --q1: #3fb8a5; /* < 40 quiet */
  --q2: #7fce6a; /* 40–45 */
  --q3: #f2c94c; /* 45–50 */
  --q4: #f2994a; /* 50–55 */
  --q5: #eb5757; /* > 55 loud */

  --radius: 14px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(77,214,193,0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(255,207,92,0.06), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  min-height: 100vh;
}

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 22px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19,28,40,0.9), rgba(10,14,20,0.4));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 16px; }
.glyph {
  color: var(--accent);
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px;
  background: radial-gradient(circle at 50% 30%, rgba(77,214,193,0.18), transparent 70%);
  box-shadow: 0 0 24px rgba(77,214,193,0.12) inset;
}
.brand-text h1 {
  margin: 0; font-size: clamp(15px, 2.6vw, 20px); letter-spacing: 0.22em;
  font-weight: 700;
}
.brand-text p {
  margin: 3px 0 0; color: var(--ink-dim); font-size: 12.5px; letter-spacing: 0.04em;
}

.station-picker { display: flex; align-items: center; gap: 12px; }
.station-picker label {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint);
}
#station {
  appearance: none;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 11px 40px 11px 16px;
  border-radius: 10px;
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%234dd6c1' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
#station:hover { border-color: var(--accent); }

/* ---------- Map ---------- */
.mapwrap {
  max-width: 1400px; margin: clamp(20px, 4vw, 34px) auto 0;
  padding: 0 clamp(20px, 4vw, 40px);
}
.map-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.map-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }
.map-sub { margin: 4px 0 0; color: var(--ink-dim); font-size: 12.5px; font-family: var(--mono); }
.map-controls { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-dim); font-family: var(--mono); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 34px; height: 18px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s ease; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-dim); transition: transform 0.15s ease, background 0.15s ease; }
.toggle input:checked + .track { background: rgba(255,207,92,0.35); }
.toggle input:checked + .track .knob { transform: translateX(16px); background: var(--accent-2); }
.map-legend { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }
.map-legend .mk { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-left: 6px; border: 2px solid #05090e; }
.mk-fixed { background: var(--accent); }
.mk-mobile { background: var(--accent-2); }
.mk-sel { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }

#map {
  height: 340px; width: 100%;
  border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden; background: #aadaff;
  z-index: 1;
}
.leaflet-container { background: #aadaff; font-family: var(--mono); }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.8) !important; color: #556 !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: #2a6ebb !important; }
.leaflet-bar a {
  background: #fff !important; color: #222 !important;
  border-color: rgba(0,0,0,0.2) !important;
}
.leaflet-bar a:hover { background: #f2f2f2 !important; }

/* custom NMT markers */
.nmt-marker {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: #05090e; border: 2px solid #05090e;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5); cursor: pointer;
  transition: transform 0.12s ease;
}
.nmt-marker:hover { transform: scale(1.15); }
.nmt-marker.fixed { background: var(--accent); }
.nmt-marker.mobile { background: var(--accent-2); }
.nmt-marker.selected {
  background: #fff; color: #05090e;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.35), 0 4px 14px rgba(0,0,0,0.6);
  transform: scale(1.2);
}
.leaflet-popup-content-wrapper {
  background: #05090e; color: var(--ink); border: 1px solid var(--accent);
  border-radius: 10px; font-family: var(--mono);
}
.leaflet-popup-content { margin: 10px 14px; font-size: 12.5px; line-height: 1.5; }
.leaflet-popup-content b { color: var(--accent); }
.leaflet-popup-tip { background: #05090e; border: 1px solid var(--accent); }
.leaflet-popup-content .tag { color: var(--ink-faint); }

/* noise contour overlay */
.noise-overlay { image-rendering: auto; transition: none; }
.noise-overlay.adjusting {
  outline: 2px dashed var(--accent-2);
  outline-offset: -2px;
  filter: drop-shadow(0 0 6px rgba(255,207,92,0.5));
}

/* adjust button + panel */
.adjust-btn {
  background: var(--panel-2); color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: all 0.15s ease;
}
.adjust-btn:hover { border-color: var(--accent-2); color: var(--ink); }
.adjust-btn.active {
  background: rgba(255,207,92,0.15); border-color: var(--accent-2); color: var(--accent-2);
}
.adjust-panel[hidden] { display: none; }
.adjust-panel {
  max-width: 1400px; margin: 12px auto 0; padding: 12px 16px;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: rgba(255,207,92,0.06); border: 1px solid rgba(255,207,92,0.25);
  border-radius: 12px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
}
.adjust-panel .ap-hint { color: var(--accent-2); }
.adjust-panel .ap-ctl { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.adjust-panel input[type="range"] {
  accent-color: var(--accent-2); width: 150px; cursor: pointer;
}
.adjust-panel output { color: var(--accent-2); min-width: 42px; }
.adjust-panel .ap-reset {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.adjust-panel .ap-reset:hover { border-color: var(--q5); color: var(--q5); }
.contour-legend {
  max-width: 1400px; margin: 12px auto 0; padding: 0 2px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
}
.contour-legend .cl-title { color: var(--ink); font-weight: 600; letter-spacing: 0.02em; }
.contour-legend .cl-item { display: inline-flex; align-items: center; gap: 7px; }
.contour-legend .cl-sw { width: 16px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.4); }
.contour-note {
  max-width: 1400px; margin: 8px auto 0; padding: 0 2px;
  color: var(--ink-dim); font-size: 11.5px; font-family: var(--mono); line-height: 1.5;
}
.contour-note .cnote-dim { color: var(--ink-faint); }

/* ---------- Layout ---------- */
main {
  padding: clamp(20px, 4vw, 40px);
  max-width: 1400px; margin: 0 auto;
}

.loading { color: var(--ink-dim); display: flex; align-items: center; gap: 12px; padding: 60px 4px; font-family: var(--mono); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(77,214,193,0.5); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(77,214,193,0.5);} 70% { box-shadow: 0 0 0 12px rgba(77,214,193,0);} 100% { box-shadow: 0 0 0 0 rgba(77,214,193,0);} }

.error { color: var(--q5); font-family: var(--mono); padding: 40px 4px; }

/* Hour-of-day filter bar */
.hourbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px; padding: 12px 16px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 14px;
  font-family: var(--mono); font-size: 13px;
}
.hourbar .hb-label { color: var(--ink-faint); text-transform: uppercase; font-size: 11px; letter-spacing: 0.14em; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  background: transparent; color: var(--ink-dim); border: none;
  padding: 7px 15px; border-radius: 8px; cursor: pointer;
  font-family: var(--mono); font-size: 13px; transition: all 0.12s ease;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--accent); color: #05221d; font-weight: 600; }
.hb-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-dim); cursor: pointer; user-select: none; }
.hb-toggle input { accent-color: var(--accent-2); width: 15px; height: 15px; cursor: pointer; }
.hb-toggle.disabled { opacity: 0.4; cursor: not-allowed; }
.hb-window { margin-left: auto; color: var(--accent); font-size: 12.5px; }

/* Overall summary strip */
.overview {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 30px;
}
.tile {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.tile .k { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.tile .v { font-family: var(--mono); font-size: 26px; font-weight: 600; margin-top: 6px; }
.tile .v small { font-size: 13px; color: var(--ink-dim); font-weight: 400; margin-left: 3px; }
.tile .sub { color: var(--ink-dim); font-size: 12px; margin-top: 4px; }

/* ---------- Year card ---------- */
.year {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px clamp(16px, 3vw, 28px);
  margin-bottom: 24px;
}
.year-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 20px;
}
.year-title { display: flex; align-items: baseline; gap: 16px; }
.year-title h2 {
  margin: 0; font-size: clamp(30px, 6vw, 46px); font-weight: 700;
  letter-spacing: -0.01em; line-height: 1;
  background: linear-gradient(180deg, var(--ink), var(--ink-dim));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.year-stats { display: flex; gap: 26px; flex-wrap: wrap; }
.year-stat { text-align: right; }
.year-stat .k { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.year-stat .v { font-family: var(--mono); font-size: 19px; font-weight: 600; margin-top: 3px; }
.year-stat .delta {
  font-family: var(--mono); font-size: 11px; font-weight: 600; margin-top: 3px;
  letter-spacing: 0.02em; min-height: 14px;
}
.year-stat .delta.up { color: var(--q5); }      /* louder than last year */
.year-stat .delta.down { color: var(--accent); } /* quieter */
.year-stat .delta.flat { color: var(--ink-faint); }
.year-stat .delta.none { visibility: hidden; }

/* chart */
.chart-wrap { position: relative; }
.chart {
  width: 100%; height: 200px; display: block;
  border-bottom: 1px solid var(--line);
}
.month-axis {
  display: grid; grid-template-columns: repeat(12, 1fr);
  margin-top: 8px;
}
.month-axis span {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  text-align: center; letter-spacing: 0.05em;
}

.bar { cursor: pointer; }
.bar:hover { filter: brightness(1.35); }
.gridline { stroke: var(--line); stroke-width: 1; }
.gridlabel { fill: var(--ink-faint); font-family: var(--mono); font-size: 10px; }

/* ---------- Legend ---------- */
.legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 4px 0 30px; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 30; pointer-events: none;
  background: #05090e; border: 1px solid var(--accent);
  padding: 9px 12px; border-radius: 9px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
}
.tooltip .d { color: var(--ink-dim); }
.tooltip .db { color: var(--accent); font-weight: 600; font-size: 15px; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 18px clamp(16px, 4vw, 44px) 30px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint); font-size: 12px; font-family: var(--mono);
}
.footer code { color: var(--accent); }

@media (max-width: 620px) {
  .year-stats { gap: 16px; }
  .year-stat { text-align: left; }
}
