/* APP demo. Palette borrowed from a nautical chart: shoal-water paper, deep-channel ink, buoy yellow. */

:root {
  --ink: #0f3540;
  --ink-soft: #46666e;
  --water: #dcebe8;
  --water-deep: #c3dcd7;
  --paper: #fbfdfc;
  --line: #c9dad6;
  --buoy: #f5b700;
  --buoy-deep: #d99e00;
  --clear: #14866a;
  --watch: #b86e00;
  --watch-fill: #e89a1c;
  --alert: #c8323c;
  --offline: #7d8c90;
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(15, 53, 64, .08), 0 8px 24px rgba(15, 53, 64, .10);
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  font: 400 16px/1.5 var(--body); color: var(--ink); background: var(--water);
  font-variant-numeric: tabular-nums;
}
body[data-view="map"] { height: 100dvh; overflow: hidden; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--buoy); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 5000; border-radius: 6px; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-soft); }
.unit { font-weight: 400; font-size: .8125rem; color: var(--ink-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: .9375rem; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--ink:hover:not(:disabled) { background: #0a2830; }
.btn--buoy { background: var(--buoy); border-color: var(--buoy); color: var(--ink); }
.btn--buoy:hover { background: var(--buoy-deep); border-color: var(--buoy-deep); }
.btn--alert { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn--alert:hover { background: #a82831; }
.btn--danger { color: var(--alert); }
.btn--danger:hover { border-color: var(--alert); }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, .35); color: #fff; }
.btn--ghost:hover { border-color: #fff; }
.btn--onalert { background: #fff; border-color: #fff; color: var(--alert); min-height: 34px; padding: 4px 14px; }
.btn--center { display: flex; margin: 0 auto; }
.link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.link:hover { color: var(--clear); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap;
  min-height: var(--topbar-h); padding: 8px 20px; background: var(--ink); color: #fff; z-index: 1200; position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-name { font: 800 1.5rem/1 var(--display); letter-spacing: .02em; }
.brand-full { font-size: .875rem; color: #a9c6c9; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .25); }
.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
  color: #cfe0e2; text-decoration: none; font-weight: 600; font-size: .9375rem;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current] { color: var(--ink); background: var(--water); }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--alert); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 300px; padding: 6px;
  background: var(--paper); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; }
.menu button:hover { background: var(--water); }
.menu strong { display: block; font-weight: 600; }
.menu small { color: var(--ink-soft); font-size: .8125rem; }

/* ---------- alert banner ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--alert); color: #fff; z-index: 1100; position: relative; }
.banner p { flex: 1; font-weight: 600; }
.banner-pulse { width: 12px; height: 12px; border-radius: 50%; background: #fff; flex: none; animation: blink 1.2s ease-in-out infinite; }
.banner.is-new { animation: bannerIn .5s cubic-bezier(.2, .9, .3, 1); }
@keyframes bannerIn { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- map view ---------- */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-map { flex: 1; min-height: 0; display: grid; grid-template-columns: 400px 1fr; }
.panel { background: var(--paper); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.map-wrap { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--water-deep); font-family: var(--body); }
.map-tools { position: absolute; top: 14px; right: 14px; z-index: 900; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.map-btn {
  min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); font-weight: 600; font-size: .875rem; box-shadow: 0 1px 4px rgba(15, 53, 64, .18);
}
.map-btn:hover { border-color: var(--ink-soft); }
.map-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.legend {
  position: absolute; left: 14px; bottom: 22px; z-index: 900; display: flex; gap: 14px; padding: 8px 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; font-size: .8125rem; font-weight: 500;
  box-shadow: 0 1px 4px rgba(15, 53, 64, .18);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.leaflet-container a { color: var(--ink); }
.leaflet-tooltip { font: 600 .8125rem var(--body); color: var(--ink); border: 0; border-radius: 6px; box-shadow: var(--shadow); padding: 5px 9px; }
.leaflet-bar a { color: var(--ink); }

.pip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--offline); }
.pip--clear { background: var(--clear); }
.pip--watch { background: var(--watch-fill); }
.pip--alert { background: var(--alert); }

/* buoy markers */
.buoy { position: relative; display: grid; place-items: center; width: 34px; height: 34px; }
.buoy-dot {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #fff; background: var(--offline); color: #fff; font: 800 12px/1 var(--body);
  box-shadow: 0 1px 5px rgba(15, 53, 64, .5); transition: width .2s, height .2s;
}
.buoy--clear .buoy-dot { background: var(--clear); }
.buoy--watch .buoy-dot { background: var(--watch-fill); color: var(--ink); }
.buoy--alert .buoy-dot { background: var(--alert); }
.buoy.is-selected .buoy-dot { width: 30px; height: 30px; font-size: 15px; box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(15, 53, 64, .5); }
.buoy-ring { position: absolute; inset: 6px; border-radius: 50%; pointer-events: none; }
.buoy--alert .buoy-ring { border: 3px solid var(--alert); animation: ripple 1.6s ease-out infinite; }
@keyframes ripple { from { transform: scale(.8); opacity: .9; } to { transform: scale(3.4); opacity: 0; } }

/* ---------- list ---------- */
.list-head { position: sticky; top: 0; z-index: 2; padding: 20px 20px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.summary { font: 600 1.25rem/1.25 var(--display); margin-bottom: 14px; text-wrap: balance; }
.summary.is-alert { color: var(--alert); }
input[type="search"], .field input, .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; min-height: 32px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--paper); font-size: .8125rem; font-weight: 600;
}
.chip:hover { border-color: var(--ink-soft); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-count { opacity: .65; font-weight: 500; }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 20px; border: 0; background: none; text-align: left; }
.row:hover { background: #eef5f3; }
.row--alert { background: #fbecec; }
.row--alert:hover { background: #f7dfe0; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-name { font-weight: 600; }
.row-sub { font-size: .8125rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-status { font-size: .8125rem; font-weight: 600; color: var(--ink-soft); }
.row-status--clear { color: var(--clear); }
.row-status--watch { color: var(--watch); }
.row-status--alert { color: var(--alert); }
.empty { padding: 32px 20px; color: var(--ink-soft); text-align: center; display: grid; gap: 14px; justify-items: center; }

/* ---------- detail ---------- */
.detail { padding: 14px 20px 28px; display: grid; gap: 22px; }
.detail h3 { font: 600 1rem/1.3 var(--display); margin-bottom: 10px; }
.back { justify-self: start; border: 0; background: none; padding: 6px 8px 6px 0; font-weight: 600; font-size: .875rem; color: var(--ink-soft); }
.back:hover { color: var(--ink); }
.back span { font-size: 1.125rem; margin-right: 2px; }
.detail-head { margin-top: -12px; }
.detail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-title h2 { font: 700 1.625rem/1.15 var(--display); text-wrap: balance; }
.detail-place { margin-top: 6px; color: var(--ink-soft); font-size: .9375rem; }
.sep { opacity: .5; padding: 0 2px; }
.status { flex: none; margin-top: 4px; padding: 3px 10px; border-radius: 6px; font-size: .8125rem; font-weight: 700; color: #fff; background: var(--offline); }
.status--clear { background: var(--clear); }
.status--watch { background: var(--watch-fill); color: var(--ink); }
.status--alert { background: var(--alert); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tags li { padding: 2px 10px; border-radius: 12px; background: var(--water); font-size: .8125rem; font-weight: 500; }
.notice { padding: 12px 14px; border-radius: 8px; background: #eef1f2; color: var(--ink-soft); font-size: .9375rem; }
.notes { margin-top: 12px; padding-left: 12px; border-left: 3px solid var(--buoy); color: var(--ink-soft); font-size: .9375rem; }

.readings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reading {
  display: grid; gap: 4px; width: 100%; height: 100%; padding: 12px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.reading:hover { border-color: var(--ink-soft); }
.reading.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.reading-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.reading-name { font-size: .8125rem; font-weight: 600; line-height: 1.25; }
.reading-level { font-size: .75rem; font-weight: 700; color: var(--clear); white-space: nowrap; }
.reading-value { font: 700 1.375rem/1.2 var(--display); }
.reading--watch .reading-level { color: var(--watch); }
.reading--alert { background: #fbecec; border-color: #e9b4b8; }
.reading--alert .reading-level, .reading--alert .reading-value { color: var(--alert); }
.reading--offline .reading-level, .reading--offline .reading-value { color: var(--offline); }
.reading--offline .reading-value { font-size: 1rem; }
.meter { position: relative; display: block; height: 6px; margin-top: 4px; border-radius: 3px; background: var(--water); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--clear); transition: width .9s linear; }
.reading--watch .meter-fill { background: var(--watch-fill); }
.reading--alert .meter-fill { background: var(--alert); }
.meter-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--paper); }
.meter-mark--alert { background: var(--ink); opacity: .55; }

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--water); }
.seg button { border: 0; background: none; padding: 4px 10px; min-height: 30px; border-radius: 6px; font-size: .8125rem; font-weight: 600; color: var(--ink-soft); }
.seg button.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 53, 64, .2); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-zone-alert { fill: rgba(200, 50, 60, .07); }
.chart-zone-watch { fill: rgba(232, 154, 28, .09); }
.chart-line-alert { stroke: var(--alert); stroke-width: 1; stroke-dasharray: 4 3; }
.chart-line-watch { stroke: var(--watch-fill); stroke-width: 1; stroke-dasharray: 4 3; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: #fff; stroke-width: 2; fill: var(--ink); }
.chart-dot--alert { fill: var(--alert); }
.chart-dot--watch { fill: var(--watch-fill); }
.chart-tick { font: 500 10px var(--body); fill: var(--ink-soft); }
.chart-label { font: 600 10px var(--body); }
.chart-label--alert { fill: var(--alert); }
.chart-label--watch { fill: var(--watch); }
.chart-note { margin-top: 8px; font-size: .8125rem; color: var(--ink-soft); }

.facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9375rem; }
.facts dt { color: var(--ink-soft); flex: none; }
.facts dd { text-align: right; font-weight: 500; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

/* incident + timeline */
.incident { padding: 16px; border-radius: 12px; border: 1.5px solid var(--alert); background: #fdf3f3; display: grid; gap: 12px; }
.incident h3 { margin: 0; font: 700 1.125rem/1.25 var(--display); color: var(--alert); }
.incident-sub { font-size: .875rem; color: var(--ink-soft); margin-top: -8px; }
.incident--done { border-color: var(--clear); background: #eef8f4; }
.incident--done h3 { color: var(--clear); }
.timeline { display: grid; }
.timeline li { position: relative; display: flex; align-items: baseline; gap: 12px; padding: 0 0 12px 0; color: var(--ink-soft); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: -4px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li.is-done::before { background: var(--ink); }
.timeline-mark { position: relative; top: 3px; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); }
.is-done .timeline-mark { background: var(--ink); border-color: var(--ink); }
.is-done .timeline-mark::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.is-next .timeline-mark { border-color: var(--alert); animation: blink 1.2s ease-in-out infinite; }
.timeline-label { flex: 1; font-size: .9375rem; }
.is-done .timeline-label { color: var(--ink); font-weight: 600; }
.is-next .timeline-label { color: var(--ink); }
.timeline-time { font-size: .8125rem; }

/* ---------- pages ---------- */
.page { flex: 1; background: var(--paper); }
.page-inner { width: min(1040px, 100%); margin: 0 auto; padding: 48px 24px 80px; }
.page h1 { font: 700 clamp(2rem, 4.4vw, 3.25rem)/1.05 var(--display); letter-spacing: -.01em; text-wrap: balance; }
.page h2 { font: 700 1.5rem/1.2 var(--display); margin-bottom: 16px; }
.page-lede { margin-top: 16px; max-width: 62ch; font-size: 1.125rem; color: var(--ink-soft); }
#alerts-body section { margin-top: 40px; }
.alert-card { display: grid; gap: 10px; max-width: 560px; margin-bottom: 16px; }
.quiet { display: grid; gap: 14px; justify-items: start; padding: 20px; border-radius: 12px; background: #eef8f4; border: 1.5px solid #b9dfd1; max-width: 640px; }
.log li { display: flex; gap: 24px; justify-content: space-between; padding: 18px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.log h3 { font: 600 1.125rem/1.3 var(--display); }
.log-main { flex: 1 1 320px; display: grid; gap: 4px; }
.log-main p { color: var(--ink-soft); font-size: .9375rem; }
.log-facts { display: flex; gap: 28px; }
.log-facts dt { font-size: .8125rem; color: var(--ink-soft); }
.log-facts dd { font: 600 1.125rem var(--display); }

.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.hero-copy { display: grid; gap: 20px; justify-items: start; }
.hero-copy .page-lede { margin-top: 0; }
.diagram { background: #eaf3f1; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.diagram svg { display: block; width: 100%; height: auto; }
.about-block { margin-top: 64px; }
.flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; counter-reset: flow; }
.flow li { counter-increment: flow; padding-top: 16px; border-top: 3px solid var(--ink); }
.flow li::before { content: counter(flow); display: block; font: 800 2.25rem/1 var(--display); color: var(--buoy-deep); margin-bottom: 8px; }
.flow h3 { font: 700 1.25rem/1.2 var(--display); margin-bottom: 6px; }
.flow p { color: var(--ink-soft); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-size: .8125rem; color: var(--ink-soft); font-weight: 600; background: #f1f7f5; }
tbody th { font-weight: 600; white-space: nowrap; }
td:nth-child(n+3) { white-space: nowrap; font-weight: 500; }
.fine { margin-top: 10px; font-size: .875rem; color: var(--ink-soft); max-width: 72ch; }
.note-block { padding: 24px; border-radius: 12px; background: #fff7dc; border: 1.5px solid #f0d88a; }
.note-block h2 { font-size: 1.25rem; margin-bottom: 8px; }
.note-block p { max-width: 72ch; }
.guide { border-top: 1px solid var(--line); padding-top: 20px; }
.guide summary { font: 700 1.25rem var(--display); cursor: pointer; }
.guide ol { list-style: decimal; padding-left: 24px; margin-top: 16px; display: grid; gap: 10px; max-width: 72ch; }

/* ---------- dialogs ---------- */
.dialog { padding: 0; border: 0; border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 80px rgba(15, 53, 64, .35); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: visible; }
.dialog::backdrop { background: rgba(15, 53, 64, .55); }
.sheet { display: flex; flex-direction: column; width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.sheet--small { width: min(420px, calc(100vw - 24px)); }
.sheet--wide { width: min(720px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; }
.sheet-head h2 { font: 700 1.375rem/1.2 var(--display); }
.x { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; font-size: 1.5rem; line-height: 1; color: var(--ink-soft); }
.x:hover { background: var(--water); color: var(--ink); }
.sheet-body { padding: 4px 24px 20px; overflow-y: auto; display: grid; gap: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.foot-note { margin-right: auto; font-size: .875rem; color: var(--ink-soft); }
.lede { color: var(--ink-soft); }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: .875rem; font-weight: 600; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--alert); font-size: .875rem; font-weight: 500; }
#place-error { color: var(--ink-soft); }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.choices legend { font-size: .875rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice:hover { border-color: var(--ink-soft); }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input { margin-top: 4px; accent-color: var(--ink); }
.choice strong { display: block; font-weight: 600; }
.choice small { color: var(--ink-soft); font-size: .8125rem; line-height: 1.35; display: block; }

.steps { display: flex; gap: 8px; padding: 0 24px 12px; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 3px solid var(--line); font-size: .875rem; font-weight: 600; color: var(--ink-soft); }
.steps span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--ink); font-size: .75rem; flex: none; }
.steps .is-current { border-color: var(--buoy); color: var(--ink); }
.steps .is-current span { background: var(--buoy); }
.steps .is-done { border-color: var(--ink); color: var(--ink); }
.steps .is-done span { background: var(--ink); color: #fff; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-row input { flex: 1 1 200px; }
.results { border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; max-height: 180px; overflow-y: auto; }
.results li + li { border-top: 1px solid var(--line); }
.results button { width: 100%; padding: 10px 12px; border: 0; background: #fff; text-align: left; font-size: .875rem; }
.results button:hover { background: var(--water); }
.pickmap-wrap { position: relative; }
.pickmap { height: min(340px, 38dvh); border-radius: 12px; border: 1.5px solid var(--line); background: var(--water-deep); cursor: crosshair; z-index: 0; }
.pick-toggle { position: absolute; top: 10px; right: 10px; z-index: 500; }

.scan { position: relative; width: 150px; height: 150px; margin: 8px auto; display: grid; place-items: center; }
.scan span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--line); }
.scan span:nth-child(2) { inset: 24px; }
.scan span:nth-child(3) { inset: 48px; }
.scan i { width: 22px; height: 22px; border-radius: 50%; background: var(--buoy); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(15, 53, 64, .4); }
.scan.is-scanning span { border-color: var(--buoy-deep); animation: scan 1.6s ease-out infinite; }
.scan.is-scanning span:nth-child(2) { animation-delay: .25s; }
.scan.is-scanning span:nth-child(3) { animation-delay: .5s; }
@keyframes scan { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(1.15); opacity: 0; } }
.demo-note { text-align: center; font-size: .8125rem; color: var(--ink-soft); }
.devices { display: grid; gap: 8px; }
.devices button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; text-align: left; }
.devices button:hover { border-color: var(--ink); }
.device-main { flex: 1; display: grid; }
.device-main small { color: var(--ink-soft); }
.device-go { font-weight: 600; font-size: .875rem; text-decoration: underline; text-underline-offset: 3px; }
.device-bars { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.device-bars i { width: 5px; border-radius: 1px; background: var(--line); }
.device-bars i:nth-child(1) { height: 8px; } .device-bars i:nth-child(2) { height: 14px; } .device-bars i:nth-child(3) { height: 20px; }
.device-bars--3 i, .device-bars--2 i:nth-child(-n+2), .device-bars--1 i:nth-child(1) { background: var(--clear); }
.checks { display: grid; gap: 10px; }
.checks li { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); }
.checks li.is-done, .checks li.is-busy { color: var(--ink); }
.check-mark { position: relative; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.is-busy .check-mark { border-color: var(--buoy-deep); border-top-color: transparent; animation: spin .7s linear infinite; }
.is-done .check-mark { background: var(--clear); border-color: var(--clear); }
.is-done .check-mark::after, .connected-mark::after { content: ''; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.connected { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 24px 0; }
.connected h3 { font: 700 1.375rem var(--display); }
.connected p { color: var(--ink-soft); max-width: 40ch; }
.connected-mark { position: relative; width: 56px; height: 56px; border-radius: 50%; background: var(--clear); }
.connected-mark::after { left: 20px; top: 11px; width: 13px; height: 25px; border-width: 0 4px 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 6000; max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 500; box-shadow: var(--shadow);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 1080px) { .brand-full { display: none; } }
@media (max-width: 860px) {
  .topbar { padding: 8px 12px; gap: 6px 12px; }
  .nav { order: 3; width: 100%; margin: 0; }
  .nav a { flex: 1; justify-content: center; padding: 6px 8px; }
  .topbar-actions { margin-left: auto; }
  .topbar .btn { min-height: 36px; padding: 6px 10px; font-size: .875rem; }
  .banner { padding: 8px 12px; font-size: .9375rem; }
  .view-map { grid-template-columns: 1fr; grid-template-rows: 40dvh 1fr; }
  .map-wrap { order: -1; }
  .panel { border-right: 0; border-top: 1px solid var(--line); }
  .legend { display: none; }
  .map-tools { top: 10px; right: 10px; }
  .hero { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .page-inner { padding: 32px 18px 64px; }
  .sheet-head, .sheet-body, .sheet-foot { padding-left: 16px; padding-right: 16px; }
  .steps { padding: 0 16px 10px; }
  .steps li { font-size: .75rem; }
}
@media (max-width: 420px) {
  .brand-name { font-size: 1.25rem; }
  .steps li:not(.is-current) { flex: 0 0 auto; }
  .steps li:not(.is-current) { font-size: 0; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .buoy--alert .buoy-ring { opacity: .6; transform: scale(1.6); }
}

/* Calm the street map a little so the buoys stay the loudest thing on it. */
.tiles-chart { filter: saturate(.8) contrast(.96); }
