:root {
  --bg: #eef7f7; --card: #ffffff; --ink: #0f2a2e; --mute: #5b7378; --line: #d4e6e6;
  --accent: #0e9aa7; --accent2: #2f6fed; --accent-ink: #ffffff; --ok: #1a9e6a; --soft: #e3f1f1; --pulse: rgba(14,154,167,.35);
  --grad: linear-gradient(135deg, #14b8a6 0%, #0ea5c6 55%, #2f6fed 100%);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a181c; --card: #102529; --ink: #e9f5f5; --mute: #8fb1b5; --line: #1e3a40; --soft: #163039; --accent: #2dd4bf; --accent2: #60a5fa; --accent-ink: #062226; --pulse: rgba(45,212,191,.45);
    --grad: linear-gradient(135deg, #2dd4bf 0%, #22b8d6 55%, #60a5fa 100%); }
}
/* JJ's phone: blush and bashful. */
:root[data-who="jj"] {
  --bg: #fcf4f6; --card: #ffffff; --ink: #2b1a22; --mute: #7d6370; --line: #f1dbe3;
  --accent: #e0607e; --accent2: #c43d7b; --accent-ink: #ffffff; --ok: #1a9e6a; --soft: #f8e7ec; --pulse: rgba(224,96,126,.35);
  --grad: linear-gradient(135deg, #f7a8c4 0%, #e8708f 50%, #c43d7b 100%);
}
@media (prefers-color-scheme: dark) {
  :root[data-who="jj"] { --bg: #1b1015; --card: #27181f; --ink: #fbeef3; --mute: #bb98a7; --line: #3d2733; --soft: #33202a; --accent: #f28aa6; --accent2: #f7b3c8; --accent-ink: #2b1a22; --pulse: rgba(242,138,166,.45);
    --grad: linear-gradient(135deg, #f7b3c8 0%, #f28aa6 50%, #e0607e 100%); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.screen { min-height: 100%; }

/* login */
#login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; display: grid; gap: 14px; }
.mark { font-size: 40px; font-weight: 800; letter-spacing: -.03em; }
.mark span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 600; margin-left: 2px; }
.login-card p { margin: 0; color: var(--mute); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--mute); }
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.err { color: var(--accent); min-height: 1em; font-size: 14px; }

/* buttons */
.primary { background: var(--grad); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; box-shadow: 0 6px 18px -8px var(--pulse); }
.primary:disabled { opacity: .5; }
.ghost { background: var(--soft); padding: 12px 16px; border-radius: 14px; font-weight: 600; }
.small { padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--mute); }
.icon svg { width: 18px; height: 18px; }

/* header */
.now::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); }
.now { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: calc(env(safe-area-inset-top) + 14px) 18px 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.now-name { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.now-sub { font-size: 13px; color: var(--mute); margin-top: 2px; }
.now-actions { display: flex; gap: 8px; flex-shrink: 0; }
.now-actions button { padding: 10px 14px; font-size: 14px; }

main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
h2 { font-size: 15px; margin: 18px 0 8px; color: var(--mute); font-weight: 600; letter-spacing: .02em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 10px; }
.muted { color: var(--mute); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* route */
.stop { display: grid; grid-template-columns: 28px 1fr; gap: 12px; margin-bottom: 8px; }
.stop .rail { display: flex; flex-direction: column; align-items: center; }
.stop .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--line); margin-top: 16px; flex-shrink: 0; }
.stop .line { width: 2px; flex: 1; background: var(--line); margin-top: 4px; }
.stop.done .dot { background: var(--ok); box-shadow: 0 0 0 2px var(--ok); }
.stop.current .dot { background: var(--accent); box-shadow: 0 0 0 2px var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 2px var(--accent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 2px var(--accent); } }
.stop .card { margin: 0; }
.stop.current .card { border-color: var(--accent); box-shadow: 0 10px 30px -18px var(--pulse); }
.stop.done .card { opacity: .6; }
.stop-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stop-name { font-weight: 700; font-size: 17px; }
.unit { font-size: 12px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.unit.travel { color: var(--mute); background: var(--soft); }
.blurb { font-size: 14px; color: var(--mute); margin: 6px 0 0; line-height: 1.45; }
.fac { font-size: 13px; color: var(--mute); margin: 6px 0 0; line-height: 1.4; }
.fac b { color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 13px; padding: 6px 10px; border-radius: 999px; background: var(--soft); }
.chip.done { text-decoration: line-through; opacity: .55; }
.stop-actions { display: flex; gap: 8px; margin-top: 12px; }
.opt { font-size: 11px; color: var(--mute); border: 1px dashed var(--line); padding: 2px 7px; border-radius: 999px; }

/* list */
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check { width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--line); display: grid; place-items: center; flex-shrink: 0; background: transparent; }
.check svg { width: 16px; height: 16px; opacity: 0; }
.item.done .check { background: var(--ok); border-color: var(--ok); }
.item.done .check svg { opacity: 1; stroke: #fff; }
.item.done .text { text-decoration: line-through; color: var(--mute); }
.item .text { flex: 1; }
.item .by { font-size: 12px; color: var(--mute); }
.add { display: flex; gap: 8px; margin-top: 10px; }
.add input { flex: 1; padding: 10px 12px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.group-head .stop-name { font-size: 16px; }
.filter { display: flex; gap: 6px; margin-bottom: 8px; }
.filter button { padding: 8px 12px; border-radius: 999px; background: var(--soft); font-size: 14px; }
.filter button.on { background: var(--grad); color: #fff; }
.badge { position: absolute; top: 4px; right: calc(50% - 22px); font-size: 10px; background: var(--accent2); color: #fff; border-radius: 999px; padding: 1px 5px; min-width: 16px; text-align: center; font-weight: 700; }
.badge:empty { display: none; }

/* wish */
.wish { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.wish:last-child { border-bottom: 0; }
.wish .text { font-weight: 600; }
.wish .note { white-space: pre-wrap; font-size: 14px; color: var(--mute); }
.wish .meta { font-size: 12px; color: var(--accent); }
.wish.done .text { text-decoration: line-through; color: var(--mute); }
textarea { min-height: 70px; resize: vertical; }
.form { display: grid; gap: 10px; }

/* map */
.mapbox { height: 300px; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.leaflet-container { font-family: var(--sans); }
.ring { width: 100%; height: auto; display: block; }
.ring .wedge { fill: var(--soft); stroke: var(--bg); stroke-width: 1.2; }
.ring .wedge.target { fill: color-mix(in srgb, var(--accent) 38%, var(--soft)); }
.ring .wedge.optional { fill: color-mix(in srgb, var(--accent) 16%, var(--soft)); }
.ring .wedge.done { fill: color-mix(in srgb, var(--ok) 30%, var(--soft)); }
.ring .wedge.current { fill: var(--accent); animation: glow 1.6s infinite; }
@keyframes glow { 50% { filter: brightness(1.25); } }
.ring text { font-family: var(--sans); fill: var(--ink); font-size: 9px; font-weight: 700; pointer-events: none; }
.ring text.sub { font-weight: 500; fill: var(--mute); font-size: 8px; }
.ring .poi { fill: var(--accent); }
.ring .poi.other { fill: var(--mute); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--mute); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.hint { font-size: 13px; color: var(--mute); margin-top: 8px; }

/* tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs a { position: relative; display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--mute); font-size: 11px; font-weight: 600; min-width: 64px; padding: 4px 0; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: 90vw; }

/* settings block */
.settings { display: grid; gap: 10px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: var(--mute); }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

/* quick add */
.quick { display: flex; gap: 8px; margin-bottom: 12px; }
.quick input { flex: 1; padding: 12px 14px; }
.quick button { white-space: nowrap; }
.mv { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: var(--soft); color: var(--mute); max-width: 120px; }
select.mv { appearance: none; -webkit-appearance: none; border: 0; }

/* travel */
.travel { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 14px; }
.travel .big { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.travel .leg { display: flex; gap: 8px; align-items: baseline; margin-top: 4px; color: var(--mute); font-size: 13px; }
.travel .leg b { color: var(--ink); min-width: 42px; }
.travel .warn { color: var(--accent); font-weight: 600; margin-top: 6px; }
.status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.status span { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--soft); color: var(--mute); }
.status span.bad { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

/* notes */
.note-card { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.note-card:last-child { border-bottom: 0; }
.note-card .text { font-weight: 600; }
.note-card .body { white-space: pre-wrap; font-size: 14px; color: var(--mute); }
.note-card .tags { font-size: 12px; color: var(--accent); }
.note-card.done .text { text-decoration: line-through; color: var(--mute); }
.note-card img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.note-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-pick { display: flex; gap: 8px; align-items: center; }
.photo-pick img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.tagline { font-size: 12px; color: var(--mute); }
input[type=file] { display: none; }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--card); width: min(720px, 100%); max-height: 80vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.snack { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.snack:last-child { border-bottom: 0; }
.snack .row b { flex: 1; }
.snack .gf { font-size: 13px; color: var(--mute); }
.snack .meta { font-size: 12px; color: var(--mute); }
.open { color: var(--ok); font-weight: 700; font-size: 12px; }
.closed { color: var(--accent); font-weight: 700; font-size: 12px; }

.who { display: flex; gap: 8px; }
.who button { flex: 1; padding: 14px; border-radius: 14px; background: var(--soft); font-weight: 700; font-size: 16px; border: 2px solid transparent; }
.who button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--soft)); }
.who button[data-who="JJ"] { color: #c43d7b; }
.who button[data-who="Josh"] { color: #0e9aa7; }

/* hops between stops */
.hop { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: center; margin: -2px 0 8px; }
.hop-icon { text-align: center; font-size: 16px; line-height: 1; }
.hop-text { font-size: 13px; color: var(--mute); background: var(--soft); border-radius: 999px; padding: 6px 12px; justify-self: start; }
.hop-text b { color: var(--ink); }
.emoji { font-size: 15px; margin-right: 2px; }

/* trips */
.trip { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.trip:last-child { border-bottom: 0; }
.trip .name { font-weight: 700; font-size: 16px; }
.trip.on .name::before { content: '● '; color: var(--accent); }
.trip .meta { font-size: 12px; color: var(--mute); }
.trip .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.day-head { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 14px 0 8px 40px; }
.bstop { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bstop:last-child { border-bottom: 0; }
.bstop .em { font-size: 18px; text-align: center; }
.bstop .nm { font-weight: 600; }
.bstop .sub { font-size: 12px; color: var(--mute); }
.bstop .ctl { display: flex; gap: 2px; }
.bstop .ctl button { width: 34px; height: 34px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.geo-results { display: grid; gap: 4px; }
.geo-results button { text-align: left; background: var(--soft); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.geo-results button.on { outline: 2px solid var(--accent); }
.chat { display: grid; gap: 8px; max-height: 50vh; overflow: auto; padding: 4px 0; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 16px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.msg.user { background: var(--grad); color: #fff; justify-self: end; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--soft); justify-self: start; border-bottom-left-radius: 4px; }
.msg pre { background: color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 8px; padding: 8px; overflow: auto; font-size: 11px; max-height: 160px; }
.msg .plan-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); margin-top: 6px; }
.typing { color: var(--mute); font-size: 13px; font-style: italic; }

.share { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.share button { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--soft); border: 1.5px solid transparent; }
.share button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--soft)); }
details summary::-webkit-details-marker { display: none; }

/* journey graphics */
.strip { display: flex; gap: 2px; height: 18px; border-radius: 6px; overflow: hidden; margin: 8px 0 6px; }
.seg { display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; letter-spacing: .02em; min-width: 6px; border-radius: 3px; }
.seg.walk { border: 1.5px dashed var(--line); color: var(--mute); }
.legs { display: grid; gap: 6px; margin-top: 4px; }
.travel .leg { display: flex; gap: 8px; align-items: center; color: var(--mute); font-size: 13px; }
.travel .leg.alt { opacity: .8; margin-top: 4px; }
.lbadge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.lbadge.walk { background: var(--soft); color: var(--mute); font-weight: 600; }
.spill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: var(--ink); }
.spill i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.spill b { font-weight: 700; }
.spill.ok b { color: var(--ok); }
.spill.warn { background: #fff4d6; color: #6b4a00; }
.spill.bad { background: #ffe1e1; color: #8a1a1a; }
@media (prefers-color-scheme: dark) { .spill.warn { background: #3d2f08; color: #ffd98a; } .spill.bad { background: #4a1414; color: #ffb4b4; } }
.salert { border-radius: 12px; padding: 8px 10px; margin-top: 8px; display: grid; gap: 4px; border-left: 4px solid; }
.salert.warn { border-color: #e0a100; background: color-mix(in srgb, #ffcc33 14%, var(--card)); }
.salert.bad { border-color: #d12a2a; background: color-mix(in srgb, #ff4d4d 12%, var(--card)); }
.sreason { font-size: 13px; line-height: 1.4; }
.who-said { font-size: 11px; font-weight: 700; color: var(--accent2); margin-bottom: 2px; }
