:root {
  --bg: #f7f7f5; --surface: #ffffff; --surface-2: #efefec; --on: #1b1b1a; --muted: #64635f; --divider: #e3e2de;
  --primary: #1a73e8; --on-primary: #fff;
  --s1: #2e7d32; --s2: #4f7fc4; --s3: #d99a1e; --s4: #e0662a; --s5: #c62828; --sq: #8e8d88;
  --angel: #fff6d6; --radius: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141414; --surface: #1f1f1e; --surface-2: #2a2a28; --on: #ecebe7; --muted: #a8a7a1; --divider: #33322f;
    --primary: #8ab4f8; --on-primary: #0b1d3a; --angel: #3a341c; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--on); }
body { font: 16px/1.45 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; }
a { color: var(--primary); }

/* app bar */
.appbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 4px; height: 64px; padding: 0 8px 0 16px; background: var(--bg); }
.appbar.sub { padding-left: 4px; }
.titles { flex: 1; min-width: 0; }
.logo { width: 36px; height: 36px; margin-right: 10px; flex: none; }
#title { font-size: 22px; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#subtitle { font-size: 13px; color: var(--muted); margin: 0; }
.icon-btn { width: 48px; height: 48px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* layout */
main { display: flex; flex-direction: column; }
#map { height: 30vh; min-height: 200px; margin: 0 16px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); z-index: 0; }
#screen { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; width: 100%; }
@media (min-width: 900px) {
  main { flex-direction: row-reverse; height: calc(100vh - 64px); }
  #map { flex: 1; height: auto; margin: 0 16px 16px 0; }
  #screen { width: 440px; flex: none; overflow-y: auto; padding-bottom: 32px; }
}
.loading { color: var(--muted); }

/* hero */
.hero { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.overline { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
.hero-top { display: flex; align-items: flex-start; gap: 12px; }
.hero h2 { font-size: 28px; line-height: 1.15; font-weight: 500; margin: 0; flex: 1; }
.meta { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.angel { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; }
.angel .face { font-size: 22px; line-height: 1.3; }
.angel p { margin: 0; background: var(--angel); padding: 10px 14px; border-radius: 4px 16px 16px 16px; font-size: 15px; }
.against { list-style: none; padding: 0; margin: 14px 0 0; }
.against li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: 15px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; border-radius: 26px; border: 0; padding: 0 24px; font-size: 16px; font-weight: 500; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-text { background: transparent; color: var(--primary); }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.hero .actions { display: flex; gap: 8px; margin-top: 18px; }
.hero .actions .btn-primary { flex: 1; }

/* score badge */
.badge { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 17px; }
.badge.lg { width: 52px; height: 52px; font-size: 22px; }
.badge.s1 { background: var(--s1); } .badge.s2 { background: var(--s2); } .badge.s3 { background: var(--s3); }
.badge.s4 { background: var(--s4); } .badge.s5 { background: var(--s5); } .badge.sq { background: var(--sq); }
.badge-wrap { flex: none; display: grid; justify-items: center; }
.badge-word { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sq); transform: translateY(1px); }
.dot.ok { background: var(--s1); } .dot.watch { background: var(--s2); } .dot.caution { background: var(--s3); } .dot.danger { background: var(--s5); }

/* lists */
h3.section { font-size: 14px; font-weight: 500; color: var(--muted); margin: 24px 4px 8px; }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 12px 16px; width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; text-decoration: none; color: inherit; }
.list > * + * { border-top: 1px solid var(--divider); }
.row:active { background: var(--surface-2); }
.row .text { flex: 1; min-width: 0; }
.row .t { font-size: 16px; }
.row .st { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--muted); font-size: 22px; flex: none; transition: transform .15s; }
.row .lead-icon { width: 40px; text-align: center; font-size: 22px; flex: none; }
.row.small { min-height: 56px; }

/* source rows (expand in place) */
details.src > summary { list-style: none; }
details.src > summary::-webkit-details-marker { display: none; }
details.src[open] > summary .chev { transform: rotate(90deg); }
details.src .more { padding: 0 16px 16px 72px; font-size: 14px; color: var(--muted); }
details.src .more p { margin: 0 0 6px; }
details.src .more p:first-child { color: var(--on); }

/* stretch summary */
.summary { background: var(--surface); border-radius: var(--radius); padding: 20px; display: flex; gap: 16px; align-items: flex-start; }
.summary p { margin: 0; }
.summary .where { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* bottom action bar (phone) */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 1000; }
.bottom-bar .btn { width: 100%; max-width: 608px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
@media (min-width: 900px) { .bottom-bar { position: static; background: none; padding: 16px 0 0; } .bottom-bar .btn { box-shadow: none; } }

/* small print + forms */
.fine { font-size: 13px; color: var(--muted); margin: 20px 4px 0; text-align: center; }
.page { background: var(--surface); border-radius: var(--radius); padding: 8px 20px 16px; font-size: 15px; }
.page h4 { margin: 16px 0 6px; font-size: 15px; }
.legend { list-style: none; padding: 0; margin: 8px 0; }
.legend li { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.legend .badge { width: 32px; height: 32px; font-size: 15px; }
.field { display: grid; gap: 6px; margin: 16px 0; font-size: 14px; color: var(--muted); }
.field input { font: inherit; font-size: 16px; color: var(--on); padding: 14px 16px; border-radius: 12px; border: 1px solid var(--divider); background: var(--bg); }

/* map pieces */
.leaflet-container { background: var(--surface-2); font: inherit; }
.pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 14px; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); box-sizing: border-box; }
.pin.s1 { background: var(--s1); } .pin.s2 { background: var(--s2); } .pin.s3 { background: var(--s3); }
.pin.s4 { background: var(--s4); } .pin.s5 { background: var(--s5); } .pin.sq { background: var(--sq); }
.gauge { position: absolute; left: 0; bottom: 8px; transform: translateX(-50%); background: #fff; color: #1b1b1a; padding: 3px 8px; border-radius: 12px; font-size: 12.5px; font-weight: 500; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.gauge-pin { overflow: visible; }
.gauge-pin::after { content: ""; position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: #1a73e8; border: 2px solid #fff; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.7) !important; }
.place { position: absolute; left: 8px; top: -9px; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: #2b2a27; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.field select { font: inherit; font-size: 16px; color: var(--on); padding: 14px 12px; border-radius: 12px; border: 1px solid var(--divider); background: var(--bg); }
.steps { padding-left: 20px; } .steps li { margin: 6px 0; }
.page code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 14px; word-break: break-all; }
.page .btn { margin: 8px 0; }
.place.below { left: 0; top: 7px; transform: translateX(-30%); }
.place.above-left { left: auto; right: 8px; top: -22px; }
.field select, .field input { width: 100%; max-width: 100%; min-width: 0; }
.time-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.time-row input[type=time] { flex: 1; font: inherit; font-size: 18px; color: var(--on); padding: 12px 14px; border-radius: 12px; border: 1px solid var(--divider); background: var(--bg); min-width: 0; }
.btn.small { height: 40px; padding: 0 12px; font-size: 14px; }
.page .btn-text { width: 100%; }
.note { background: var(--angel); padding: 8px 12px; border-radius: 10px; }
.consent { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.field textarea { font: inherit; font-size: 16px; color: var(--on); padding: 12px 14px; border-radius: 12px; border: 1px solid var(--divider); background: var(--bg); width: 100%; }
.field select[multiple] { padding: 6px; }
.field small { font-weight: 400; }
.steps .btn { margin: 8px 0 4px; width: 100%; }
.steps .fine { display: block; text-align: left; margin: 0; }
.btn[disabled] { opacity: .45; cursor: default; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); background: var(--surface-2); border-radius: 24px; padding: 4px; margin: 0 0 12px; }
.seg button { border: 0; background: transparent; height: 40px; border-radius: 20px; font-weight: 500; font-size: 15px; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--on); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
/* time rows: the time box keeps its width on phones; Remove stays small */
.time-row input[type=time] { flex: 1 1 auto; min-width: 9.5em; min-height: 52px; }
.time-row .btn { width: auto !important; flex: none; }
