:root {
  --bg: #0d141d; --side: #111a25; --raise: #182432; --line: #223041;
  --ink: #e7edf4; --muted: #93a2b4; --faint: #64748a;
  --accent: #e8823a; --link: #8fbdf2; --kelp: #d94801; --grey: #888c92;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, select { font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; cursor: pointer; line-height: 1.2; }
button:hover { background: var(--raise); }
select { width: 100%; padding: 6px 8px; background: var(--raise); }
select option:disabled { color: var(--faint); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- header ---- */
#topbar { height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--side); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px;
  letter-spacing: .01em; white-space: nowrap; }
.subtitle { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 14px; border-left: 1px solid var(--line); }
#lang-switch { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#lang-switch button { border: 0; border-radius: 0; padding: 4px 10px; font-size: 12px; color: var(--muted); }
#lang-switch button.on { background: var(--raise); color: var(--ink); }

/* ---- layout ---- */
#layout { display: flex; height: calc(100% - 48px); }
#sidebar { width: 372px; flex: none; overflow-y: auto; background: var(--side);
  border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#map { flex: 1; background: #0a1017; }
#sidebar section { padding: 14px 16px 16px; border-bottom: 1px solid var(--line); }
#sidebar section:last-child { border-bottom: 0; }
h2 { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); }
h3 { margin: 12px 0 5px; font-size: 12px; font-weight: 600; color: var(--ink); }
.hint, .fine { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.fine { color: var(--faint); }
.fine a { color: var(--muted); text-decoration: underline; }
.note { margin: 8px 0 0; padding: 6px 9px; border-left: 3px solid var(--accent); background: var(--raise);
  font-size: 12px; }

/* ---- timeline ---- */
.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.daynav button { padding: 2px 10px; font-size: 17px; }
#day-label { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.timeline { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tday { flex: 0 0 auto; width: 28px; padding: 2px 0 5px; border: 0; border-radius: 5px; text-align: center; line-height: 1.45;
  cursor: pointer; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tday:hover { background: var(--raise); }
.tday.on { background: var(--raise); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.tday.m1 { margin-left: 6px; }
.tday .mon { display: block; height: 13px; color: var(--faint); font-size: 9px; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap; }
.tday .dots { display: flex; justify-content: center; margin-top: 4px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2a3848; }
.dot.kelp { background: var(--kelp); } .dot.clear { background: #56708c; }
.dot.none { background: transparent; box-shadow: inset 0 0 0 1.5px #7c8a9b; }
.dot.na { background: #3a4656; }
.dot.wait { background: transparent; box-shadow: inset 0 0 0 1.5px #7c8a9b; opacity: .5; }
.legend-dots { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 12px; font-size: 11px; color: var(--faint); }
.legend-dots .dot { margin-right: 3px; }

/* ---- day summary ---- */
#day-summary { border-top: 1px solid var(--line); padding-top: 10px; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.head .name { font-weight: 600; }
.head .badge { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.head .badge.kelp { color: var(--accent); font-weight: 600; font-size: 13px; }
.rows { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 4px 0 0;
  font-size: 12px; font-variant-numeric: tabular-nums; }
.rows span:nth-child(odd) { color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tbl th { color: var(--faint); font-weight: 500; text-align: right; padding: 0 3px 3px; white-space: nowrap; }
.tbl td { padding: 3px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; white-space: normal; }
.tbl tr.off td { color: var(--faint); }

/* ---- drawn area ---- */
.areabtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.areabtns button { font-size: 12px; padding: 4px 10px; }
.areabtns button:disabled { opacity: .45; cursor: default; }
#area-done, #area-cancel { border-color: #5ad1ff; color: #5ad1ff; }
#area-panel .rows { margin-top: 6px; }
#area-panel .rows span:nth-child(even) { white-space: nowrap; text-align: right; }
#area-panel .fine { margin-top: 8px; }
#map.drawing, #map.drawing .leaflet-interactive { cursor: crosshair; }
.chartbox { position: relative; margin-top: 8px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--faint); stroke-width: 1; }
.chart .tick, .chart .unit { fill: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.chart .obs { fill: var(--faint); }
.chart .bar { fill: #8fa6bd; opacity: .28; }
.chart .c30 { fill: none; stroke: #f4b778; stroke-width: 2; }
.chart .pt { fill: var(--kelp); stroke: #fff; stroke-width: .8; }
.chart .tick.tide { fill: #7fb8d8; }
.chart .tideline { fill: none; stroke: #7fb8d8; stroke-width: 1; opacity: .6; }
.chart .tidept { fill: #7fb8d8; }
.chart .hover { stroke: var(--muted); stroke-dasharray: 2 2; }
.charttip { position: absolute; top: 4px; min-width: 140px; padding: 6px 8px; border-radius: 5px;
  background: rgba(13, 20, 29, .95); border: 1px solid var(--line); font-size: 11px; pointer-events: none; }
.charttip div { display: flex; justify-content: space-between; gap: 10px; }
.charttip span { color: var(--muted); }
.maopts { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.maopts span:first-child { margin-right: 4px; }
.maopts button { padding: 2px 8px; font-size: 12px; }
.maopts button[aria-pressed="true"] { background: #5ad1ff; color: #0d141d; border-color: #5ad1ff; }
.range { margin-top: 4px; font-size: 12px; color: var(--muted); }
.range #range-label { color: var(--ink); white-space: nowrap; }
.range .slider { position: relative; height: 22px; margin: 2px 0 0; }
.range .slider input { position: absolute; left: 0; right: 0; width: 100%; top: 0; margin: 0; background: none;
  pointer-events: none; -webkit-appearance: none; appearance: none; height: 22px; }
.range .slider::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 2px;
  background: rgba(143, 166, 189, .4); }
.range .slider input::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: #5ad1ff; border: 2px solid #0d141d; cursor: pointer; position: relative; z-index: 1; }
.range .slider input::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: #5ad1ff; border: 2px solid #0d141d; cursor: pointer; }
.range .slider input::-moz-range-track { background: none; }
.chartkeys { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.chartkeys .k { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.chartkeys .k.pt { border-radius: 50%; background: var(--kelp); width: 8px; height: 8px; }
.chartkeys .k.bar { background: rgba(143, 166, 189, .4); }
.chartkeys .k.c30 { height: 2px; vertical-align: 3px; background: #f4b778; }
.chartkeys .k.tide { border-radius: 50%; background: #7fb8d8; width: 6px; height: 6px; vertical-align: 1px; }

/* ---- downloads ---- */
.files { display: flex; flex-direction: column; font-size: 12px; gap: 3px; }

/* ---- about ---- */
.about p { margin: 0 0 8px; }
.about .research { color: var(--ink); font-weight: 600; }

/* ---- map ---- */
.leaflet-container { background: #0a1017; font: inherit; }
.timectl { background: rgba(17, 26, 37, .92); color: var(--ink); padding: 8px 10px; border-radius: 6px;
  width: min(460px, calc(100vw - 40px)); font-size: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.timectl[hidden] { display: none; }
.timectl .modes { display: flex; gap: 4px; margin-bottom: 6px; }
.timectl .modes button { padding: 2px 8px; font-size: 12px; }
.timectl .modes button[aria-pressed="true"] { background: #5ad1ff; color: #0d141d; border-color: #5ad1ff; }
.timectl .row { display: flex; align-items: center; gap: 6px; }
.timectl .row input { flex: 1; min-width: 0; accent-color: #5ad1ff; }
.timectl .step { padding: 0 8px; font-size: 16px; line-height: 20px; }
.timectl .when { margin-top: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.maplegend { background: rgba(17, 26, 37, .92); color: var(--ink); padding: 9px 11px;
  border-radius: 6px; border: 1px solid var(--line); font-size: 11px; line-height: 1.6; max-width: 210px; }
.maplegend b { font-weight: 600; display: block; }
.maplegend .ramp { width: 168px; height: 8px; border-radius: 2px; margin: 4px 0 2px; }
.maplegend .ticks { display: flex; justify-content: space-between; width: 168px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.maplegend .keys { display: flex; flex-wrap: wrap; gap: 0 10px; color: var(--muted); }
.maplegend .grow { margin: 6px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.maplegend .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.readout .leaflet-popup-content { margin: 8px 12px; font-size: 12px; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--side); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--raise); }
.leaflet-control-layers { background: var(--side); color: var(--ink); border: 1px solid var(--line) !important;
  box-shadow: none !important; border-radius: 6px; }
.leaflet-control-layers-toggle { filter: invert(1) brightness(1.6); }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 10px; font-size: 12px; }
.leaflet-control-scale-line { background: rgba(17, 26, 37, .8); color: var(--muted); border-color: var(--faint);
  text-shadow: none; font-size: 10px; }
.leaflet-control-attribution { background: rgba(13, 20, 29, .75) !important; color: var(--faint); font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted); }

@media (max-width: 800px) {
  #layout { flex-direction: column-reverse; }
  #sidebar { width: 100%; height: 52%; border-right: 0; border-top: 1px solid var(--line); }
  #map { height: 48%; flex: none; }
  .subtitle { display: none; }
  .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .maplegend { padding: 6px 8px; font-size: 11px; max-width: 190px; }
  .maplegend .grow { display: none; }
  .timectl { width: calc(100vw - 20px); padding: 6px 8px; }
  .leaflet-bottom .leaflet-control-scale { display: none; }
}
/* kelp tiles enlarged past their native zoom (or while zooming) stay sharp pixels */
.leaflet-kelp-pane canvas.leaflet-tile { image-rendering: pixelated; }
