:root {
  --brand: #0A6B54;
  --brand-ink: #ffffff;
  --navy: #112337;
  --bg: #f5f7f6;
  --card: #ffffff;
  --ink: #16212b;
  --muted: #5d6b75;
  --line: #dde3e1;
  --soft: #e7f2ee;
  --hot: #b3261e;
  --warm: #a35a00;
  --ok: #0A6B54;
  --focus: #1a73e8;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3fb897;
    --brand-ink: #06231b;
    --navy: #cfe0f2;
    --bg: #0f1418;
    --card: #182027;
    --ink: #e6ecef;
    --muted: #9aa8b1;
    --line: #2a353d;
    --soft: #16302a;
    --hot: #f2867c;
    --warm: #f0b25c;
    --ok: #3fb897;
    --focus: #8ab4f8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 1.05rem; margin: 24px 0 8px; color: var(--navy); }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 8px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.brand { color: var(--brand-ink); font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.dot { width: 14px; height: 14px; background: var(--brand-ink); transform: rotate(45deg); border-radius: 2px; }
.who { font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.who select { font-size: .85rem; padding: 2px 4px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
main:focus { outline: none; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { text-align: center; padding: 12px 4px; font-size: .9rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--brand); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 8px; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--soft); color: var(--brand); white-space: nowrap;
}
.badge.hot { background: color-mix(in srgb, var(--hot) 15%, transparent); color: var(--hot); }
.badge.warm { background: color-mix(in srgb, var(--warm) 15%, transparent); color: var(--warm); }
.badge.grey { background: var(--line); color: var(--muted); }

.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--brand); border-radius: 10px; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn.danger { border-color: var(--hot); color: var(--hot); background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.inline input { width: auto; min-height: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { margin: 0; font-weight: 500; }
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choices span {
  display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); cursor: pointer;
}
.choices input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.choices input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.stop { display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.num {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--soft); color: var(--brand);
}
.num.done { background: var(--brand); color: var(--brand-ink); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0 12px; }
.chips button {
  flex: none; font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--navy); color: var(--card); border-color: var(--navy); }

.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; max-width: 90%; }
.msg.mine { align-self: flex-end; background: var(--soft); }
.msg .meta { font-size: .75rem; color: var(--muted); display: flex; gap: 8px; justify-content: space-between; }
.msg p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chatform { display: flex; gap: 8px; margin-top: 8px; }
.chatform textarea { min-height: 44px; height: 44px; }

.visit { border-left: 4px solid var(--brand); }
.visit p { white-space: pre-wrap; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .875rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { margin: 0; padding-left: 18px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.4rem; color: var(--navy); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.warn { background: color-mix(in srgb, var(--warm) 12%, var(--card)); border-color: color-mix(in srgb, var(--warm) 40%, var(--line)); }

#toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: var(--card); padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
label.pickbtn { width: 100%; margin: 0; color: var(--brand-ink); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 8px 0; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--soft); display: block; }
.photos figcaption { display: flex; justify-content: space-between; gap: 6px; margin-top: 4px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--hot); cursor: pointer; text-decoration: underline; }
.signin { max-width: 420px; margin: 8vh auto 0; }
.signin .brandmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--brand); margin-bottom: 16px; }
.signin .brandmark .dot { background: var(--brand); }
.signin .btn { width: 100%; margin-top: 18px; }
.err { color: var(--hot); font-weight: 600; margin-top: 10px; min-height: 1.5em; }
body.signed-out .tabs, body.signed-out .top { display: none; }
body.signed-out { padding-bottom: 0; }
.who .linkbtn { color: var(--brand-ink); font-size: .85rem; }
.link-out { display: flex; gap: 8px; margin-top: 8px; }
.link-out input { font-size: .8rem; }

/* map */
:root { --m-open: #ffffff; --m-contacted: #6b7c93; --m-hot: #e08a1e; --m-meeting: #0A6B54; --m-skip: #b9c2c7; --line-strong: #9fb0aa; }
@media (prefers-color-scheme: dark) { :root { --m-open: #f2f5f4; --m-contacted: #8fa1b8; --m-hot: #f0a64a; --m-meeting: #3fb897; --m-skip: #4a565d; --line-strong: #4f5d64; } }
#map { height: 62vh; min-height: 340px; border-radius: var(--radius); border: 1px solid var(--line); margin: 8px 0; z-index: 0; }
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.leaflet-popup-content { margin: 12px; }
.pop strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.pop .small { margin-top: 3px; }
.popactions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.popactions .btn { color: var(--brand-ink); }
.popactions .btn.ghost { color: var(--brand); }
.popactions a:first-child { grid-column: 1 / -1; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); vertical-align: baseline; }
.mapfilters select { min-height: 40px; padding: 6px 10px; font-size: .9rem; }
.tabs { grid-template-columns: repeat(5, 1fr); }
.tabs a { font-size: .82rem; padding: 12px 2px; }
