:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #17202a; --muted: #5b6673; --line: #dde2e8;
  --accent: #2f6fd0; --danger: #b42318;
  --confirmed: #1f9d55; --plausible: #d97706; --unidentified: #6b7280; --ft8: #2f6fd0;
  --sea: #dce9f5; --land: #f3efe4; --land-line: #b9b2a0; --ring: #8aa4c0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151a; --panel: #1a2027; --text: #e6e9ed; --muted: #9aa5b1; --line: #2c343d;
    --accent: #6ea2f0; --danger: #f97066;
    --sea: #13233a; --land: #2a2f36; --land-line: #4b535d; --ring: #3d5878;
  }
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted, .help { color: var(--muted); }
.help { font-size: 0.85rem; margin: 0.25rem 0; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-sub { font-weight: 400; color: var(--muted); font-size: 0.9rem; margin-left: 0.4rem; }
.account { display: flex; align-items: center; gap: 0.9rem; font-size: 0.95rem; }
form.inline { display: inline; margin: 0; }

button, .button { font: inherit; padding: 0.4rem 0.8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button.is-primary, .button.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.is-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
a.danger { color: var(--danger); margin-left: auto; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: #fff; text-transform: capitalize; }
.badge.is-confirmed { background: var(--confirmed); }
.badge.is-plausible { background: var(--plausible); }
.badge.is-unidentified { background: var(--unidentified); }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.3rem; vertical-align: -0.05rem; }
.dot.is-confirmed { background: var(--confirmed); }
.dot.is-plausible { background: var(--plausible); }
.dot.is-ft8 { background: var(--ft8); width: 0.5rem; height: 0.5rem; }

/* Map page */
body.is-map { height: 100vh; display: flex; flex-direction: column; }
.mapview { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.mapcol { display: flex; flex-direction: column; min-height: 0; padding: 0.6rem; gap: 0.5rem; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.toggle { font-size: 0.9rem; white-space: nowrap; }
.maparea { flex: 1; position: relative; min-height: 320px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--sea); }
.map { position: absolute; inset: 0; width: 100%; height: 100%; }
.map[hidden] { display: none; }
.footnote { font-size: 0.78rem; color: var(--muted); margin: 0; }
.origin-label { font-size: 0.75rem; }

.listcol { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 0.8rem; }
.summary p { margin: 0.2rem 0 0.5rem; font-size: 0.88rem; }
.filters { margin-bottom: 0.5rem; }
.catches { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.catch { border: 1px solid var(--line); border-left: 4px solid var(--unidentified); border-radius: 6px; padding: 0.55rem 0.7rem; cursor: pointer; }
.catch.is-confirmed { border-left-color: var(--confirmed); }
.catch.is-plausible { border-left-color: var(--plausible); }
.catch.is-selected { outline: 2px solid var(--accent); }
.catch:focus-visible { outline: 2px solid var(--accent); }
.catch-head { display: flex; gap: 0.6rem; align-items: center; font-size: 0.9rem; }
.catch .station { margin: 0.3rem 0 0.1rem; font-size: 1rem; }
.catch p { margin: 0.15rem 0; font-size: 0.87rem; }
.catch .meta { color: var(--muted); }
.catch .evidence { margin-top: 0.35rem; }
.catch .note { color: var(--muted); font-style: italic; }
.catch .nopin { color: var(--muted); font-size: 0.8rem; }
.catch .edit { font-size: 0.85rem; }

/* Azimuthal SVG */
.az-sea { fill: var(--sea); }
.az-land { fill: var(--land); stroke: var(--land-line); stroke-width: 0.5; }
.az-grat { fill: none; stroke: var(--ring); stroke-opacity: 0.25; stroke-width: 0.5; }
.az-ring { fill: none; stroke: var(--ring); stroke-dasharray: 3 4; stroke-width: 0.8; }
.az-rim { fill: none; stroke: var(--ring); stroke-width: 1.2; }
.az-label { font-size: 10px; fill: var(--muted); }
.az-compass { font-size: 11px; font-weight: 600; fill: var(--muted); }
.az-path { stroke-width: 1.5; opacity: 0.7; }
.az-path.is-selected { stroke-width: 3; opacity: 1; }
.az-path.is-confirmed { stroke: var(--confirmed); }
.az-path.is-plausible { stroke: var(--plausible); stroke-dasharray: 6 5; }
.az-pin { stroke: #fff; stroke-width: 2; cursor: pointer; }
.az-pin.is-confirmed { fill: var(--confirmed); }
.az-pin.is-plausible { fill: var(--plausible); }
.az-pinlabel { font-size: 11px; fill: var(--text); paint-order: stroke; stroke: var(--sea); stroke-width: 3px; }
.az-ft8 { fill: var(--ft8); fill-opacity: 0.6; }
.az-origin { fill: #7c3aed; }
.az-btn { cursor: pointer; }
.az-btn rect { fill: var(--panel); stroke: var(--line); }
.az-btn text { font-size: 11px; fill: var(--text); }
.az-btn.is-on rect { fill: var(--accent); stroke: var(--accent); }
.az-btn.is-on text { fill: #fff; }

/* Forms and plain pages */
.page { max-width: 920px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 460px; }
.alert { background: #fdecea; color: #7a1c13; border: 1px solid #f5c2bd; padding: 0.6rem 0.8rem; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .alert { background: #3a1714; color: #fcd7d3; border-color: #6b2620; } }
.field { display: flex; flex-direction: column; gap: 0.2rem; margin: 0.4rem 0; flex: 1 1 160px; }
.field.is-wide { flex: 2 1 260px; }
.field.check { flex-direction: row; align-items: center; gap: 0.4rem; flex: 0 0 auto; align-self: center; }
.field-label { font-size: 0.85rem; font-weight: 600; }
input, select, textarea { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.row { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-start; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0.8rem 0; padding: 0.6rem 0.9rem; }
legend { font-weight: 600; padding: 0 0.3rem; }
.status-option { display: grid; grid-template-columns: auto auto 1fr; gap: 0.5rem; align-items: center; margin: 0.3rem 0; }
.picker { height: 280px; border: 1px solid var(--line); border-radius: 6px; margin-top: 0.4rem; }
.actions { display: flex; gap: 1rem; align-items: center; }
.steps li { margin-bottom: 1rem; }
.qr svg { background: #fff; padding: 6px; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
table.changes { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.changes th, table.changes td { text-align: left; padding: 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.changes pre { white-space: pre-wrap; word-break: break-word; font-size: 0.75rem; max-width: 420px; }

@media (max-width: 860px) {
  body.is-map { height: auto; }
  .mapview { grid-template-columns: 1fr; }
  .maparea { min-height: 60vh; }
  .listcol { border-left: 0; border-top: 1px solid var(--line); }
}
