:root {
  --bg: #07131c;
  --bg2: #0d1f2b;
  --bg3: #12293a;
  --line: #1f3a4d;
  --text: #dbe7ee;
  --muted: #8aa0ad;
  --amber: #f0b429;
  --amber-bg: rgba(240, 180, 41, 0.12);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.10);
  --accent: #3fb6e8;
  --left: 420px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, "Segoe UI", sans-serif;
}

body { display: flex; }

#left {
  width: var(--left);
  flex: 0 0 var(--left);
  height: 100%;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

#map { flex: 1; height: 100%; background: #041018; }

section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#controls { background: var(--bg2); }
#panel { flex: 1; }

h1 { font-size: 18px; margin: 0 0 8px; letter-spacing: 0.02em; }
h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600; }
h3 { font-size: 13px; margin: 14px 0 4px; color: var(--accent); font-weight: 600; }
h3 small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }

textarea, select, button, input {
  font: inherit;
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 4px;
}
textarea { width: 100%; resize: vertical; padding: 6px 8px; }
select, input { padding: 4px 6px; }
button { padding: 5px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
#lookup-btn { margin-left: auto; background: #184a63; }

.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.spots-head { margin-top: 0; justify-content: space-between; }

.echo { margin-top: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; min-height: 1.2em; }
.echo .dd, .echo .dm { display: block; }
.note { color: var(--amber); }
.hint, .muted { color: var(--muted); }
.missing { color: var(--muted); font-style: italic; }
.error { color: var(--red); }
.loading { color: var(--muted); }

.box { padding: 8px 10px; border-radius: 4px; margin: 8px 0; }
.box.amber { background: var(--amber-bg); border: 1px solid var(--amber); color: #ffe4a3; }
.box.red { background: var(--red-bg); border: 1px solid var(--red); }

.item { padding: 6px 0; border-top: 1px dashed var(--line); }
.item:first-of-type { border-top: 0; }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 12.5px; }

details { margin-top: 4px; }
details summary { cursor: pointer; color: var(--muted); }
dl { margin: 4px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; }
dt { color: var(--muted); }
dd { margin: 0; }

#spots-list { list-style: none; margin: 8px 0 0; padding: 0; }

/* Leaflet on a dark page */
.leaflet-container { background: #041018; font: inherit; }
.leaflet-control-layers, .leaflet-bar a, .leaflet-control-attribution {
  background: var(--bg2) !important; color: var(--text) !important;
}
.leaflet-bar a { border-bottom-color: var(--line) !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-layers-toggle { filter: invert(0.85); }

/* --- Task 13: overlays, legend, saved spots --------------------------------- */
.save-form:not([hidden]) { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
[hidden] { display: none !important; }
.save-form input { width: 100%; }
#save-ok { background: #184a63; }

.spot { padding: 8px 0; border-top: 1px dashed var(--line); }
.spot .head { display: flex; align-items: center; gap: 6px; }
.spot .sp-name { flex: 1; font-weight: 600; background: transparent; border-color: transparent; padding: 2px 4px; }
.spot .sp-name:hover, .spot .sp-name:focus, .spot .sp-note:hover, .spot .sp-note:focus { border-color: var(--line); background: var(--bg3); }
.spot .sp-note { width: 100%; background: transparent; border-color: transparent; padding: 2px 4px; font-size: 12.5px; margin-top: 2px; }
.spot .sp-status { font-size: 12px; padding: 1px 4px; }
.spot .sp-status.candidate { color: var(--amber); }
.spot .sp-status.dived { color: #4fd1b3; }
.spot .sp-status.skip { color: var(--muted); }
.spot .coords { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--accent); cursor: pointer; }
.spot .coords:hover { text-decoration: underline; }
.spot .sp-del { padding: 1px 7px; color: var(--muted); }
.spot .sp-del:hover { color: var(--red); border-color: var(--red); }
.spot.active { background: rgba(63, 182, 232, 0.07); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }

.spotbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.spotbar button { padding: 2px 8px; font-size: 12px; }

.legend { background: var(--bg2); color: var(--text); padding: 8px 10px; border-radius: 4px; border: 1px solid var(--line); max-height: 60vh; overflow-y: auto; font-size: 12px; min-width: 180px; }
.legend h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend .row { margin: 2px 0; gap: 6px; }
.legend img { width: 18px; height: 18px; flex: 0 0 18px; border: 1px solid var(--line); }

.spot-dot { width: 14px; height: 14px; border-radius: 50%; background: #4fd1b3; border: 2px solid #07131c; box-shadow: 0 0 0 1.5px #4fd1b3; }
.spot-tip { background: var(--bg2); color: var(--text); border: 1px solid #4fd1b3; font-size: 12px; padding: 1px 5px; }
.spot-tip::before { border-right-color: #4fd1b3 !important; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg2); color: var(--text); }
.leaflet-popup-content { font-size: 12.5px; margin: 10px 12px; }
.leaflet-popup-content a { color: var(--accent); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* what you may do here */
.verdicts { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.verdicts td { padding: 3px 4px; border-top: 1px dashed var(--line); vertical-align: top; }
.verdicts caption { text-align: left; color: var(--muted); font-size: 12px; padding: 2px 4px; }
.v-banned { color: var(--red); font-weight: 600; }
.v-conditional { color: var(--amber); }
.v-allowed { color: #5ed39a; }
.v-no_rule { color: var(--muted); }
.tag { font-size: 10px; border: 1px solid var(--amber); border-radius: 3px; padding: 0 4px; margin-left: 4px; color: var(--amber); }
.card { border: 1px solid var(--line); border-radius: 4px; padding: 8px; margin: 8px 0; background: var(--bg2); }
.card .name { font-weight: 600; }
.card .sub, .sub.amber { color: var(--muted); font-size: 12.5px; }
.sub.amber { color: var(--amber); }
.card .entry { margin: 4px 0; }
.quote { font-size: 12px; margin: 4px 0; padding-left: 8px; border-left: 2px solid var(--line); white-space: pre-wrap; }
.unchecked li { color: var(--muted); font-size: 12px; }
.buoys li { font-size: 12.5px; }
#panel h4 { margin: 12px 0 4px; font-size: 13px; }
a.ext { color: var(--accent); }
.verdicts caption .amber { color: var(--amber); }
