:root {
  --paper: #F4F7F4;
  --card: #FFFFFF;
  --ink: #1B2624;
  --muted: #5A6964;
  --line: #D6DFD9;
  --accent: #9C3D86;
  --accent-soft: #F3E3EF;
  --on-accent: #FFFFFF;
  --yes: #23794B;
  --no: #C23B4F;
  --shadow: 0 1px 2px rgba(20, 40, 35, .08), 0 4px 14px rgba(20, 40, 35, .08);
  --sea: #BFE3EC;
  --sea-in: #9FD2E0;
  --land: #FBF6E4;
  --land-edge: #6FA9A0;
  --park: #CDE8B5;
  --foreign: #E8E6D8;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

/* Dark theme: follows the device unless Settings picks Light or Dark (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111917;
    --card: #1A2421;
    --ink: #E4ECE8;
    --muted: #98A9A2;
    --line: #2B3833;
    --accent: #DB86C8;
    --accent-soft: #3A2335;
    --on-accent: #1A0F17;
    --yes: #62C891;
    --no: #F07C8B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .3);
    --sea: #13303A;
    --sea-in: #1C4652;
    --land: #28352F;
    --land-edge: #5E9A90;
    --park: #2F4A33;
    --foreign: #1E2724;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111917;
  --card: #1A2421;
  --ink: #E4ECE8;
  --muted: #98A9A2;
  --line: #2B3833;
  --accent: #DB86C8;
  --accent-soft: #3A2335;
  --on-accent: #1A0F17;
  --yes: #62C891;
  --no: #F07C8B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .3);
  --sea: #13303A;
  --sea-in: #1C4652;
  --land: #28352F;
  --land-edge: #5E9A90;
  --park: #2F4A33;
  --foreign: #1E2724;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  padding-inline: 16px;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app {
  max-width: 1440px;
  margin-inline: auto;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding-block: calc(14px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
}
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; }
.brand { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
h1 { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 0; text-wrap: balance; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.stats b { color: var(--ink); font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.me { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); }
.me img { width: 22px; height: 22px; border-radius: 50%; }

/* Project name, switcher and member pictures in the header */
.projrow { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 2px; }
.projrow h1 { margin: 0; }
/* Start page: the Wanderly logo (pin icon + name) in place of a project name */
.projrow h1.logo { display: inline-flex; align-items: center; gap: 12px; }
.logoicon { width: 1.15em; height: 1.15em; border-radius: 26%; flex: none; box-shadow: var(--shadow); }
.projmenu { position: relative; }
.projbtn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 6px 10px 6px 12px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow);
}
.projbtn svg { width: 12px; height: 12px; transition: transform .15s; }
.projbtn[aria-expanded="true"] { border-color: var(--accent); }
.projbtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.projlist {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1500;
  min-width: 240px; max-width: min(320px, calc(100vw - 32px)); max-height: 60vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.projitem {
  width: 100%; display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  border: 0; background: none; border-radius: 8px; padding: 8px 10px; text-align: left; font-size: 14px;
}
.projitem:hover, .projitem:focus-visible { background: var(--accent-soft); outline: none; }
.projitem .tick { color: var(--accent); font-weight: 700; text-align: center; }
.projitem .pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projitem[aria-checked="true"] .pn { font-weight: 700; }
.projitem .pc { font: 400 11px var(--mono); color: var(--muted); }
.projitem.new { color: var(--accent); font-weight: 700; }
.projsep { height: 1px; background: var(--line); margin: 4px 6px; }
@media (prefers-reduced-motion: reduce) { .projbtn svg { transition: none; } }
.avatars { display: flex; align-items: center; cursor: pointer; }
.avatars:empty { display: none; }
.hav {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--paper);
  margin-left: -8px; object-fit: cover; background: var(--accent-soft);
}
.hav:first-child { margin-left: 0; }
.hav.initials, .pav.initials { display: grid; place-items: center; font: 700 12px var(--body); color: var(--ink); }
.hav.more { display: grid; place-items: center; font: 500 11px var(--mono); color: var(--ink); background: var(--line); }

/* Start page (no project open): hide the tools that only make sense inside a project */
body:not(.in-project) .inproj,
body:not(.in-project) #mapMode [data-mode="detailed"],
body:not(.in-project) #keyBtn { display: none; }

/* Start page: no tab bar; the title, your projects and "Start a new project" sit in one card. */
.lobbytitle { display: none; }
body:not(.in-project) .tabs { display: none; }
body:not(.in-project) #paneProject {
  flex: 0 1 auto; gap: 0; padding: 18px 18px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
body:not(.in-project) .lobbytitle {
  display: block; margin: 0 0 14px;
  font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -.02em; color: var(--accent);
}
body:not(.in-project) #paneProject > .card { background: none; border: 0; border-radius: 0; padding: 0; }
body:not(.in-project) #newProjCard:not([hidden]) { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
body:not(.in-project) .legallinks { margin-top: 18px; }

.startcard { padding: 24px 20px; }
.startcard h2 { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -.02em; line-height: 1.1; margin: 0; }
.startcard > p { color: var(--muted); margin: 8px 0 0; }
.startform { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 12px; }
.startform input { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--paper); font-size: 16px; }
.startform .primary.big { width: 100%; }

.projcards { display: flex; flex-direction: column; gap: 8px; }
.projcard {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name go" "meta go";
  gap: 6px 10px; align-items: center; text-align: left;
  border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 12px 14px;
}
.projcard:hover, .projcard:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.projcard .pcname { grid-area: name; font-family: var(--display); font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projcard .pcmeta { grid-area: meta; display: flex; align-items: center; gap: 10px; }
.projcard .pcmeta .small { margin: 0; }
.projcard .pcmeta .hav { width: 24px; height: 24px; }
.projcard .pcgo { grid-area: go; font-size: 18px; color: var(--accent); }
.backlink { display: inline-block; margin-bottom: 8px; }

/* Project tab */
.cardtitle { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0; }
.projhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.projname { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.015em; line-height: 1.15; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.small-btn { padding: 6px 12px; font-size: 13px; flex: none; }
.inlineform { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inlineform input { flex: 1 1 160px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--paper); }
.inlineform .ghost { padding: 9px 14px; }
.invite { font: 400 12px var(--mono); color: var(--muted); }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 10px; align-items: center; }
.people .pav { grid-row: span 2; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); }
.people .pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .small { margin: 0; }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; min-height: 0; }

/* ---------- map ---------- */
.mapwrap { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); min-height: 0; background: var(--card); }
#map { position: absolute; inset: 0; font-family: var(--body); }
.leaflet-container { background: var(--sea); }
path.land { fill: var(--land); stroke: var(--land-edge); stroke-width: 2.5px; stroke-linejoin: round; }
path.foreign { fill: var(--foreign); stroke: var(--land-edge); stroke-width: 1.5px; stroke-opacity: .5; }
path.park { fill: var(--park); stroke: none; }
path.res { fill: var(--sea-in); stroke: none; }
.mapctl { position: absolute; left: 12px; bottom: 12px; z-index: 1000; display: flex; gap: 8px; align-items: stretch; }
.keybtn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; box-shadow: var(--shadow); padding: 0 14px; font-weight: 700; font-size: 13px;
}
.keybtn[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.mapkey {
  position: absolute; left: 12px; bottom: 60px; z-index: 1000;
  width: 250px; max-width: calc(100% - 24px); max-height: calc(100% - 140px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 14px;
}
.mapkey h4 { margin: 10px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.mapkey h4:first-child { margin-top: 0; }
.keylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.keylist li { display: flex; align-items: center; gap: 10px; }
.keylist small { color: var(--muted); }
.kline { flex: none; width: 28px; height: 8px; }
.kline line { stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0.1 5; opacity: .85; }
.kline.lrt line { stroke-width: 1.8; opacity: .6; }
.ksym { flex: none; width: 28px; height: 22px; display: grid; place-items: center; position: relative; }
.kdot { width: 6px; height: 6px; border-radius: 50%; background: #005EC4; opacity: .6; }
.kdot.inter { width: 9px; height: 9px; background: #5B6B66; opacity: .85; box-shadow: 0 0 0 1px #FFFFFF; }
.kbus { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; background: #FFFFFF; border: 1.5px solid #2F6FC7; color: #2F6FC7; }
.kbus svg { width: 11px; height: 11px; display: block; }
/* Small pins drawn at key size (not scaled), so they don't spill into the next row */
.kpin { display: grid; place-items: center; width: 28px; height: 30px; padding-bottom: 4px; }
.kpin .pin { width: 20px; height: 20px; border-width: 1.5px; box-shadow: none; }
.kpin .pin .emoji { font-size: 10px; }
.kpin .pin .badge { top: -7px; right: -7px; min-width: 13px; height: 13px; padding: 0 3px; font-size: 8px; line-height: 13px; }
.keylist.places { gap: 10px; }
.keylist.places .ksym { height: 30px; }

.mapmode {
  display: flex; gap: 2px; padding: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.mapmode button { border: 0; background: none; border-radius: 7px; padding: 6px 12px; font-weight: 700; font-size: 13px; color: var(--muted); }
.mapmode button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Bus stops (detailed map) */
.transit { background: none; border: 0; }
.transit .tsym {
  display: grid; place-items: center;
  width: 16px; height: 16px; margin: 1px; border-radius: 4px;
  background: #FFFFFF; border: 1.5px solid #2F6FC7; color: #2F6FC7;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.transit .tsym svg { width: 11px; height: 11px; display: block; }

/* MRT/LRT station names (both maps), shown when zoomed in */
.stlabel { background: none; border: 0; pointer-events: none; }
.stlabel span {
  position: absolute; left: 7px; top: 0; transform: translateY(-50%);
  white-space: nowrap; font: 700 11px var(--body); color: var(--muted);
  text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper), 0 0 3px var(--paper);
  display: none;
}
#map.show-stations .stlabel span { display: block; }
#map.streets-on .stlabel span { color: #44524D; text-shadow: 0 0 3px #FFFFFF, 0 0 3px #FFFFFF, 0 0 3px #FFFFFF; }
/* Map name popups (stations, bus stops), styled like the app's cards */
.leaflet-tooltip.wtip {
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 7px 11px; font: 400 12px/1.35 var(--body); white-space: nowrap;
}
.leaflet-tooltip.wtip.leaflet-tooltip-top::before { border-top-color: var(--line); }
.leaflet-tooltip.wtip.leaflet-tooltip-bottom::before { border-bottom-color: var(--line); }
.wtip .tipname { display: block; font-family: var(--display); font-weight: 700; font-size: 14px; }
.wtip .tipsub { display: block; color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: .04em; margin-top: 1px; }
.wtip .tiphint { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
/* No focus box around map shapes (station tap areas) when clicked */
.leaflet-container path.leaflet-interactive:focus { outline: none; }

.maplabel { background: none; border: 0; pointer-events: none; }
.maplabel span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; color: var(--muted); }
.maplabel.area span { font: 700 10px var(--body); letter-spacing: .16em; opacity: .7; }
.maplabel.water span { font: italic 400 12px var(--body); letter-spacing: .06em; opacity: .75; }
.mapwrap.adding .leaflet-container { cursor: crosshair; }
.mbtn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); }
.addbtn { position: absolute; top: 12px; left: 12px; z-index: 1000; padding: 8px 14px; font-weight: 700; background: var(--accent); color: var(--on-accent); border-color: transparent; }
.mapwrap.adding .addbtn { background: var(--card); color: var(--ink); border-color: var(--line); }
.hint { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); z-index: 1000; background: var(--ink); color: var(--paper); padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow); }

/* pins */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--card);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.pin .emoji { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.pin.sel { background: var(--accent); }
.pin.draft { background: var(--accent-soft); border-style: dashed; }
.pin .badge {
  position: absolute; top: -8px; right: -8px;
  transform: rotate(45deg);
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--yes); color: var(--card);
  font: 700 10px/18px var(--mono); text-align: center;
}
.pin.out { background: var(--line); border-color: var(--muted); opacity: .7; }
.pin.out .emoji { filter: grayscale(1); opacity: .7; }
.pin.out.sel { background: var(--muted); opacity: 1; }
.pin-wrap.out .plabel { color: var(--muted); text-decoration: line-through; }
.plabel {
  position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font: 700 12px var(--body); color: var(--ink);
  text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper), 0 0 3px var(--paper);
  display: none; pointer-events: none;
}
.show-labels .plabel, .pin-wrap.selected .plabel, .pin-wrap:hover .plabel { display: block; }

/* ---------- panel ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; flex: none; }
.tabs button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 10px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 500 11px/18px var(--mono); text-align: center; }
.pane { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; padding: 2px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }

.intro h2, .place h2, .form h2 { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.015em; line-height: 1.15; margin: 0; text-wrap: balance; }
.intro p { margin: 6px 0 0; color: var(--muted); }
.intro .primary { margin-top: 12px; }
.phead { display: flex; gap: 12px; align-items: flex-start; }
.bigicon { flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; font-size: 28px; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.coords { font: 400 12px var(--mono); color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.coords a { color: var(--accent); margin-left: 6px; font-family: var(--body); font-size: 12px; }
.blurb { margin: 12px 0 0; }
.srcnote { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }
.acts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.acts li { display: flex; gap: 8px; align-items: baseline; }
.acts li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transform: translateY(-2px); }

.votebtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vbtn { padding: 10px 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; }
.vbtn.yes[aria-pressed="true"] { background: var(--yes); border-color: var(--yes); color: var(--card); }
.vbtn.no[aria-pressed="true"] { background: var(--no); border-color: var(--no); color: var(--card); }
.vbtn.yes:hover { border-color: var(--yes); }
.vbtn.no:hover { border-color: var(--no); }
.vbtn:disabled { opacity: .5; cursor: not-allowed; }
.vnote { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.tbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line); margin-top: 12px; }
.tbar .y, .mini .y { background: var(--yes); }
.tbar .n, .mini .n { background: var(--no); }
.voters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.voters h4 { margin: 0 0 6px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.voters .yh { color: var(--yes); }
.voters .nh { color: var(--no); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.chips li { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
.chips img { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.chips span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips .none { color: var(--muted); }
.danger { background: none; border: 1.5px solid var(--no); color: var(--no); border-radius: 10px; padding: 7px 14px; font-weight: 700; font-size: 13px; }
.danger:hover, .danger.armed { background: var(--no); color: var(--card); }
.danger:disabled { opacity: .6; cursor: wait; }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row2 .ghost { padding: 7px 14px; font-size: 13px; }
.delrow { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.delrow .small:empty { display: none; }
.bulk { display: flex; flex-direction: column; gap: 6px; }
.bulk:not(:empty) { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.rank h3 { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0 0 8px; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { width: 100%; display: grid; grid-template-columns: 28px 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 6px; border: 0; border-radius: 10px; background: none; text-align: left; }
.row:hover { background: var(--paper); }
.row[aria-current="true"] { background: var(--accent-soft); }
.row .pos { font: 500 12px var(--mono); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.row .ic { font-size: 22px; text-align: center; }
.row .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ar { display: block; font-size: 12px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ct { font: 500 12px var(--mono); font-variant-numeric: tabular-nums; display: flex; gap: 6px; }
.ct .y { color: var(--yes); }
.ct .n { color: var(--no); }
.row.out .ic { filter: grayscale(1); opacity: .55; }
.row.out .nm { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.row.out .ar { text-decoration: none; font-weight: 700; color: var(--no); display: block; }
.row.out .ct, .row.out .mini { opacity: .6; }
.outnote { margin: 0 0 12px; padding: 8px 10px; border-radius: 10px; background: var(--line); color: var(--ink); font-size: 13px; }
.place.out .bigicon { filter: grayscale(1); opacity: .6; }
.row .mini { grid-column: 3 / 5; display: flex; height: 4px; border-radius: 999px; overflow: hidden; background: var(--line); }
.empty { color: var(--muted); margin: 0; }

/* ---------- forms ---------- */
.form label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
.form input, .form textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--paper); }
.form textarea { min-height: 96px; resize: vertical; }
/* Time and date boxes: iPhones draw them wider, taller and centred, poking out of the form.
   Make them look like the other text boxes. */
input[type="time"], input[type="date"] {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
  min-height: 40px; line-height: 1.4; text-align: left; color: var(--ink);
}
input[type="time"]::-webkit-date-and-time-value, input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="time"]::-webkit-calendar-picker-indicator, input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.icons { display: flex; flex-wrap: wrap; gap: 6px; }
.icons button { width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); font-size: 19px; padding: 0; }
.icons button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.factions { display: flex; gap: 8px; margin-top: 14px; }
.primary { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; }
.primary:disabled { opacity: .6; cursor: wait; }
.primary.big { padding: 12px 20px; font-size: 16px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; text-decoration: underline; font-size: 13px; }
.err { color: var(--no); font-size: 13px; margin: 8px 0 0; }
.small { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.note { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; }

/* ---------- chat ---------- */
.chatcard { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.msgs { list-style: none; margin: 0; padding: 14px 14px 6px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; min-height: 220px; }
.msg { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
.msg .av { width: 28px; height: 28px; border-radius: 50%; }
.msg .who { font-size: 13px; font-weight: 700; }
.msg .when { font: 400 11px var(--mono); color: var(--muted); margin-left: 6px; }
.msg .body { margin: 1px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg .body a { color: var(--accent); }
.msg.added .body { color: var(--muted); }
.msg.added .body b { color: var(--ink); }
.assist { margin: 0 14px 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.assist p { margin: 0; }
.assist .row2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.assist .primary, .assist .ghost { padding: 6px 12px; font-size: 13px; }
.assist .atplace { display: flex; flex-direction: column; gap: 6px; }
.assist .atplace .eyebrow { margin: 4px 0 0; }
.assist .atplace .results { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.results button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: center; }
.results button:hover { border-color: var(--accent); }
.results b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { display: flex; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea {
  flex: 1; min-width: 0; height: 42px; min-height: 42px; max-height: 132px; resize: none; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--paper);
  font: 400 15px/1.4 var(--body); color: var(--ink);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea::-webkit-scrollbar { width: 6px; }
.composer textarea::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.composer textarea::-webkit-scrollbar-button { display: none; }
.composer .primary { padding: 10px 16px; height: 42px; }
.chatfoot { margin: 0; padding: 0 14px 12px; font: 400 12px/1.45 var(--body); color: var(--muted); }
.paddr { margin: 2px 0 0; font-size: 13px; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- itinerary ---------- */
#paneItin .card > .small { margin: 4px 0 10px; }
#itinAddBtn { margin-top: 12px; }
.itinlist { display: flex; flex-direction: column; }
.itinday { margin: 14px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.itinday:first-child { margin-top: 4px; }
.stop { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.itinday + .stop { border-top: 0; }
.stoptime { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); padding-top: 2px; }
.stophead { display: flex; align-items: center; gap: 8px; }
.stopicon { font-size: 18px; }
.itinplace { font-weight: 700; font-size: 15px; text-align: left; overflow-wrap: anywhere; }
button.itinplace { font-size: 15px; }
.meet { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.meet p { margin: 0; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 4px; font-size: 13px; }
.meet b { font-weight: 700; }
.stopnotes { margin: 6px 0 0; font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.stop .msgacts { margin-top: 6px; }
.itinform { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.itinform h2 { font-family: var(--display); font-weight: 700; font-size: 18px; margin: 0; }
.itinform .eyebrow { margin: 16px 0 2px; }
.itinform .small { margin: 8px 0 0; }
.formrow { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 8px; }
.form select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--paper); color: var(--ink); }
/* place name + rename, and voting status */
.pheadtext { min-width: 0; flex: 1; }
.namerow { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.renamebtn { font-size: 12px; }
.renameform { margin: 0 0 4px; }
.votestatus { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; }
.votestatus p { margin: 0; font-size: 13px; }
.roundlabel { font-weight: 700; color: var(--accent); }
.deadline { font-weight: 700; }
.ended { font-weight: 700; padding: 8px 10px; border-radius: 10px; }
.ended.in { color: var(--yes); background: color-mix(in srgb, var(--yes) 12%, transparent); }
.ended.out { color: var(--muted); background: var(--line); }
.pastround { color: var(--muted); padding-left: 10px; border-left: 2px solid var(--line); }
.votectl { margin-top: 12px; }
.votectl .small { margin: 0; }
.row .ar.deadlinetag { color: var(--accent); font-weight: 700; }
.limitsel { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--paper); color: var(--ink); font-size: 14px; }
.form .limitnote { margin: 6px 0 0; }
.limitrow { align-items: center; }
.nolimit { color: var(--muted); }
.limitform { margin-top: 2px; }
.limitform .limitsel { flex: 1 1 180px; width: auto; min-width: 0; }
.votectl .limitsel { margin: 2px 0 4px; }

.fieldlabel { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
.fixeddate { margin: 0; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; font-size: 14px; }
.tickrow { display: flex !important; align-items: center; gap: 10px; margin: 16px 0 4px !important; font-weight: 700; cursor: pointer; }
.tickrow input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.tripline { margin: 0 0 6px; font-size: 13px; }
.tripline.missing { padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); }
.confirmzone { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.confirmzone .small { margin: 0; }
.confirmed { margin: 0; font-weight: 700; color: var(--yes); }
.row .ar.confirmedtag { color: var(--yes); font-weight: 700; }
.projcard { grid-template-areas: "name go" "dates go" "meta go"; }
.projcard .pcdates { grid-area: dates; font-size: 12px; color: var(--muted); }
.tripdates { font-size: 14px; }
.startform.compact { margin: 10px 0 0; }
.startform.compact input { padding: 9px 12px; font-size: 15px; border-radius: 10px; }
.startform .formrow.dates { margin: 0; grid-template-columns: 1fr 1fr; }
.startform .formrow.dates label { display: block; font-size: 13px; font-weight: 700; margin: 0 0 4px; }
.startform .formrow.dates input { width: 100%; }
.formrow .span2 { grid-column: 1 / -1; margin: 0; }

.checklist { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; }
.checklist li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checklist li.empty { display: block; border: 0; color: var(--muted); }
.checklist input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.checklist label { cursor: pointer; min-width: 0; }
.checklist .restitle { display: block; overflow-wrap: anywhere; }
.checklist .small { display: block; margin: 2px 0 0; }
.checklist li.done .restitle { text-decoration: line-through; color: var(--muted); }

/* chat moderation */
.msgacts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; }
.msgbtn { background: none; border: 0; padding: 0; font-size: 12px; color: var(--muted); text-decoration: underline; }
.msgbtn:hover { color: var(--ink); }
.msgbtn.armed { color: var(--no); font-weight: 700; }
.msgnote { font-size: 12px; color: var(--muted); }
.flag { font-size: 11px; font-weight: 700; color: var(--no); background: color-mix(in srgb, var(--no) 14%, transparent); border-radius: 999px; padding: 1px 8px; }

/* leave / delete / account */
.confirmbox { display: flex; flex-direction: column; gap: 6px; }
.confirmbox .small:empty { display: none; }
#deleteBox .row2 { margin-top: 2px; }
.legallinks { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.legallinks a, .legal a { color: var(--accent); }

/* ---------- settings ---------- */
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 50%; box-shadow: var(--shadow);
}
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:hover { border-color: var(--accent); }
.settings {
  position: fixed; inset: 0; z-index: 1900; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--paper) 70%, transparent); backdrop-filter: blur(4px);
}
.settingscard {
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 20px 20px 24px;
}
.settingshead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settingshead h2 { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -.02em; margin: 0; }
.settingshead .iconbtn { box-shadow: none; font-size: 14px; }
.settingscard > .small { margin: 2px 0 0; }
.settingscard h3 { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 4px; }
.settingscard a { color: var(--accent); }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setrow:last-of-type { border-bottom: 0; }
.setlabel { font-weight: 700; font-size: 14px; min-width: 0; }
.setlabel small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.seg { display: flex; flex: none; gap: 2px; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.switch {
  position: relative; flex: none; width: 44px; height: 26px; padding: 0;
  border: 0; border-radius: 999px; background: var(--line); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.smallbtn { flex: none; padding: 6px 14px; font-size: 13px; }

/* Profile panel */
.profilehead { display: flex; align-items: center; gap: 14px; margin: 16px 0 10px; }
.profilehead img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex: none; }
.profname { font-family: var(--display); font-weight: 700; font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.profilehead .small { margin: 2px 0 0; overflow-wrap: anywhere; }
.deleterow { flex-direction: column; align-items: stretch; gap: 8px; }
#deleteBox { display: flex; flex-direction: column; gap: 6px; }
.linkrow { color: var(--ink); text-decoration: none; }
.linkrow:hover .setlabel { color: var(--accent); }
.linkrow > span:last-child { color: var(--muted); font-size: 18px; }

/* Header profile chip (opens the Profile panel) */
button.me { font: inherit; cursor: pointer; }
button.me:hover { border-color: var(--accent); }
.melink { color: var(--accent); font-weight: 700; text-decoration: underline; font-size: 13px; }
@media (max-width: 480px) {
  .setrow:has(.seg) { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* map options from Settings */
#map.no-stnames .stlabel span { display: none !important; }
#map.labels-always .plabel { display: block; }

/* ---------- sign-in gate ---------- */
.gate { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px); }
.gatecard { max-width: 420px; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); text-align: center; }
.gatecard h2 { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -.02em; margin: 4px 0 8px; }
.gatecard p { color: var(--muted); margin: 0 0 18px; }
.gatecard .err { margin: 14px 0 0; }
.gatecard .legal { margin: 18px 0 0; font-size: 12px; }
.inapp {
  text-align: left; margin: 0 0 14px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--no) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--no) 40%, var(--line));
  font-size: 13px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.inapp p { margin: 0; color: var(--ink); }
.agecheck {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; color: var(--ink); cursor: pointer;
}
.agecheck input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
#signIn:disabled { opacity: .45; cursor: not-allowed; }

/* Privacy Policy and Terms of Use pages */
body.docpage { height: auto; }
.doc { max-width: 68ch; margin-inline: auto; padding-block: 32px 64px; }
.doc .back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px 12px;
  font-weight: 700; font-size: 13px; text-decoration: none;
}
.doc .back:hover { border-color: var(--accent); }
.doc h1 { margin-top: 12px; }
.doc .updated { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.doc h2 { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; margin: 32px 0 8px; text-wrap: balance; }
.doc p, .doc li { line-height: 1.65; }
.doc ul { padding-left: 20px; }
.doc li + li { margin-top: 4px; }
.doc a { color: var(--accent); }
.doc .tablewrap { overflow-x: auto; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.doc th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.doc .callout { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2100; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

@media (max-width: 860px) {
  html, body { height: auto; }
  .app { height: auto; }
  .main { grid-template-columns: 1fr; }
  .mapwrap { height: min(62vh, 540px); }
  .panel, .pane { overflow: visible; }
  .msgs { max-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}

/* ---------- phones ----------
   Keep this section last so it overrides the desktop styles above.
   When adding new UI, check it here too. */
@media (max-width: 860px) {
  .mapwrap { height: min(58svh, 520px); }
  .msgs { max-height: 55svh; }
}
@media (max-width: 600px) {
  /* iPhones zoom into text boxes with text under 16px, so use 16px. */
  input, textarea, select { font-size: 16px !important; }

  /* Header: stack, smaller title, compact profile chip. */
  .top { flex-direction: column; align-items: stretch; gap: 10px; }
  h1 { font-size: 24px; }
  .sub { font-size: 13px; }
  .projrow { gap: 8px; }
  .projbtn { padding: 7px 10px; }
  .stats { justify-content: space-between; gap: 8px 12px; }
  .stats .me { margin-left: auto; }
  #meName { display: none; }
  .me { padding: 3px 12px 3px 3px; min-height: 36px; }
  .iconbtn { width: 38px; height: 38px; }

  /* Map controls: finger-sized, and the key fits the screen. */
  .addbtn { top: 10px; left: 10px; padding: 8px 12px; font-size: 14px; }
  .hint { top: 58px; white-space: normal; text-align: center; width: max-content; max-width: calc(100% - 24px); }
  .mapctl { left: 10px; bottom: 10px; }
  .mapmode button { padding: 8px 12px; }
  .keybtn { padding: 0 14px; min-height: 38px; }
  .mapkey { left: 10px; right: 10px; width: auto; bottom: 58px; max-height: calc(100% - 120px); }

  /* Panel */
  .tabs button { padding: 10px 6px; font-size: 14px; }
  .card { padding: 14px; }
  .row { padding: 10px 6px; }
  .vbtn { padding: 12px 8px; }
  .danger, .row2 .ghost { min-height: 38px; }
  .msgbtn { padding: 4px 0; }
  .composer { padding: 10px 12px 12px; }

  /* Settings and Profile panels fill most of the screen. */
  .settings { padding: 10px; align-items: end; }
  .settingscard { max-height: calc(100svh - 20px); border-radius: 16px; padding: 18px 16px 22px; }
  .setrow:has(.seg) { flex-direction: column; align-items: flex-start; }
  .seg button { padding: 8px 12px; }

  /* Legal pages */
  .doc { padding-block: 20px 48px; }

  /* Itinerary: four tabs fit; time column narrower; form fields stack. */
  .tabs button { padding: 10px 4px; font-size: 13px; }
  .stop { grid-template-columns: 54px minmax(0, 1fr); }
  .formrow { grid-template-columns: 1fr; }
  .startform .formrow.dates { grid-template-columns: 1fr 1fr; }
  .tickrow input { width: 22px; height: 22px; }
  .checklist li { padding: 11px 0; }
  .checklist input[type="checkbox"] { width: 22px; height: 22px; }
}
