/* Mobile app shell. Phone: one screen at a time, bottom tab bar, map full screen on its tab,
   pushed screens slide in from the right, sheets rise from the bottom.
   Desktop (≥ 900px): the same app in a 420px column with the map always beside it.
   Monochrome UI; the two people get their own colors, travel modes keep theirs. */
:root {
  --bg: #f2f2f4; --surface: #ffffff; --subtle: #f2f2f4; --emphasis: #e5e5ea;
  --border: #e3e3e8; --border-strong: #c9c9d1;
  --fg: #111114; --muted: #6b6b75; --faint: #a0a0aa;
  --inverted: #111114; --on-inverted: #fafafa;
  --a: #ea580c; --b: #0d9488; --heart: #e11d48;
  --glass: rgb(255 255 255 / 0.82);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 10px 30px -8px rgb(0 0 0 / 0.18);
  --font-display: "Cal Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --tile-filter: grayscale(1) contrast(0.92) brightness(1.04);
  --tab-h: 58px;
  --tab-total: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  --bar-h: calc(52px + env(safe-area-inset-top, 0px));
  --gutter-l: max(20px, env(safe-area-inset-left, 0px));
  --gutter-r: max(20px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b; --surface: #19191c; --subtle: #222226; --emphasis: #2c2c31;
    --border: #2a2a2f; --border-strong: #3c3c43;
    --fg: #f4f4f5; --muted: #a1a1aa; --faint: #71717a;
    --inverted: #f4f4f5; --on-inverted: #111113;
    --a: #fb923c; --b: #2dd4bf; --heart: #fb7185;
    --glass: rgb(25 25 28 / 0.82);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px -8px rgb(0 0 0 / 0.6);
    --tile-filter: invert(1) grayscale(1) brightness(0.8) contrast(0.95);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --surface: #19191c; --subtle: #222226; --emphasis: #2c2c31;
  --border: #2a2a2f; --border-strong: #3c3c43;
  --fg: #f4f4f5; --muted: #a1a1aa; --faint: #71717a;
  --inverted: #f4f4f5; --on-inverted: #111113;
  --a: #fb923c; --b: #2dd4bf; --heart: #fb7185;
  --glass: rgb(25 25 28 / 0.82);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px -8px rgb(0 0 0 / 0.6);
  --tile-filter: invert(1) grayscale(1) brightness(0.8) contrast(0.95);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
button, label, .tabbar, .seg, .chips { -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 8px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
p { margin: 0; }
h1, h2 { margin: 0; font-weight: 400; }

/* ---------- shell ---------- */
.app { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.screens { position: absolute; inset: 0 0 var(--tab-total) 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); pointer-events: auto; }
body:not([data-tab="story"]) #scr-story,
body:not([data-tab="people"]) #scr-people { display: none; }
#scr-map { display: none; }
.screen.show { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px var(--gutter-r) 48px var(--gutter-l); display: flex; flex-direction: column; gap: 16px; }

/* top bar: compact title fades in once the large title scrolls away */
.bar { flex: none; height: var(--bar-h); padding: env(safe-area-inset-top, 0px) var(--gutter-r) 0 var(--gutter-l); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .2s, background .2s; position: relative; z-index: 2; }
.bar-title { grid-column: 2; font-weight: 600; font-size: 16px; opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; }
.bar-actions { grid-column: 3; justify-self: end; display: flex; gap: 2px; }
.bar.compact { border-bottom-color: var(--border); background: var(--glass); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); }
.bar.compact .bar-title { opacity: 1; }
.large-title { font: 400 34px/1.1 var(--font-display); letter-spacing: 0.005em; padding-top: 2px; margin-bottom: 2px; }
.sub { color: var(--muted); margin-top: -8px; font-weight: 500; }
.back { grid-column: 1; justify-self: start; display: inline-flex; align-items: center; gap: 2px; height: 44px; margin-left: -8px; padding-right: 8px; font-weight: 500; font-size: 16px; }
.back svg { width: 24px; height: 24px; }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--fg); }
.icon-btn:active { background: var(--emphasis); }
.icon-btn svg.i { width: 21px; height: 21px; }

/* tab bar */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; height: var(--tab-total); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); display: grid; grid-template-columns: repeat(3, 1fr); background: var(--glass); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); border-top: 1px solid var(--border); pointer-events: auto; z-index: 20; }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.tabbar svg { width: 25px; height: 25px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.tabbar button.on { color: var(--fg); }
.tabbar button.on svg { stroke-width: 2.2; }
.tabbar button[data-tab="story"].on svg { fill: var(--heart); stroke: var(--heart); }
/* The two-people mark, when active, in the two people's colours like the map pins. */
.tabbar button[data-tab="story"].on svg.if-pair { stroke: none; }
.tabbar button[data-tab="story"].on svg.if-pair circle { fill: var(--a); opacity: 0.9; }
.tabbar button[data-tab="story"].on svg.if-pair circle + circle { fill: var(--b); }
.tabbar button:active svg { transform: scale(.88); }

/* pushed screen */
.push { z-index: 15; transform: translateX(100%); transition: transform .34s cubic-bezier(.32,.72,0,1); box-shadow: -8px 0 30px rgb(0 0 0 / 0.12); bottom: var(--tab-total); }
.push.open { transform: none; }

/* ---------- map pane ---------- */
#mapPane { position: fixed; left: 0; right: 0; top: 0; bottom: var(--tab-total); z-index: 1; visibility: hidden; }
body[data-tab="map"] #mapPane { visibility: visible; z-index: 12; }
#map { position: absolute; inset: 0; background: var(--bg); }
.map-top { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); left: var(--gutter-l); right: var(--gutter-r); display: flex; justify-content: center; z-index: 600; pointer-events: none; }
.map-top .seg { pointer-events: auto; }
.glass { background: var(--glass) !important; backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); box-shadow: var(--shadow); }

.carousel { position: absolute; left: 0; right: 0; bottom: 16px; z-index: 600; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 28px 8px; scroll-padding-inline: 28px; scrollbar-width: none; overscroll-behavior-x: contain; }
.carousel::-webkit-scrollbar { display: none; }
.ccard { flex: 0 0 min(100% - 56px, 380px); scroll-snap-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; min-height: 76px; display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; text-align: left; transition: border-color .15s, transform .15s; }
.ccard.sel { border-color: var(--fg); }
.ccard:active { transform: scale(.985); }
.ccard .m { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ccard .m b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard .m span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard.wide { grid-template-columns: 1fr auto; }
.ccard .actions { display: flex; gap: 6px; align-items: center; }
.ccard .heart-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--subtle); display: grid; place-items: center; }
.ccard .heart-ic svg { width: 22px; height: 22px; fill: var(--heart); }

/* ---------- common pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.group.pad { padding: 16px 18px; }
.group-title { font: 600 13px/1 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 24px 4px -4px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.group-title span { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; color: var(--faint); }
.cell { width: 100%; min-height: 66px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; text-align: left; padding: 12px 16px; border-top: 1px solid var(--border); transition: background .1s; }
.cell:first-child { border-top: 0; }
.cell:active { background: var(--subtle); }
.cell.off { opacity: .4; }
.cell-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cell-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--subtle); display: grid; place-items: center; color: var(--fg); }
.cell .end { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chev { color: var(--faint); width: 18px; height: 18px; }
.cell .bar-line { grid-column: 2 / -1; height: 4px; border-radius: 2px; background: var(--subtle); overflow: hidden; margin-top: 6px; }
.cell .bar-line i { display: block; height: 100%; border-radius: 2px; }
.tile { width: 46px; display: flex; flex-direction: column; align-items: center; border-radius: 12px; background: var(--subtle); padding: 6px 0 5px; line-height: 1; }
.tile b { font: 400 20px/1 var(--font-display); margin: 2px 0 3px; }
.tile .mo { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--heart); }
.tile .yr { font-size: 10px; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.twin { width: 12px; height: 12px; border-radius: 50%; flex: none; background: linear-gradient(90deg, var(--a) 50%, var(--b) 50%); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pdot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.pdot.a { background: var(--a); } .pdot.b { background: var(--b); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); transition: transform .1s, opacity .1s, background .1s; white-space: nowrap; }
.btn:active { transform: scale(.97); background: var(--subtle); }
.btn.primary { background: var(--inverted); border-color: var(--inverted); color: var(--on-inverted); }
.btn.primary:active { opacity: .85; background: var(--inverted); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 22px; padding: 0 8px; border-radius: 7px; background: var(--subtle); color: var(--fg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.warn { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.warn { background: #3b2a0a; color: #fbbf24; } }
:root[data-theme="dark"] .pill.warn { background: #3b2a0a; color: #fbbf24; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--emphasis); border-radius: 12px; max-width: 100%; }
.seg button { min-height: 34px; padding: 0 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; flex: 1; }
.seg button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.seg.full { display: flex; width: 100%; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.stat { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { display: block; font: 400 24px/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ---------- story ---------- */
.couple-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); margin-top: -8px; flex-wrap: wrap; }
.couple-chip .amp { color: var(--faint); margin: 0 2px; }
.couple-chip .pill { margin-left: 6px; }
.hero { padding: 18px 0 10px; }
.big { font: 400 104px/0.9 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero-line { font: 400 26px/1.2 var(--font-display); margin-top: 14px; text-wrap: balance; max-width: 18ch; }
.hero-sub { color: var(--muted); margin-top: 12px; line-height: 1.5; }
.hero-sub b { color: var(--fg); font-weight: 600; }
.closest { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px; text-align: left; width: 100%; }
.closest:active { background: var(--subtle); }
.kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--heart); }
.closest b { font: 400 30px/1.2 var(--font-display); margin-top: 2px; }
.closest > span:not(.kicker):not(.link) { color: var(--muted); font-size: 14px; }
.closest .link { display: inline-flex; align-items: center; gap: 2px; margin-top: 10px; font-weight: 600; font-size: 14px; }
.closest .link svg { width: 16px; height: 16px; }

.score { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.score p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ring { position: relative; width: 64px; height: 64px; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--emphasis); }
.ring .val { stroke: var(--heart); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.22,1,.36,1); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 400 21px/1 var(--font-display); }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.badge { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; min-width: 0; }
.badge .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--inverted); color: var(--on-inverted); }
.badge b { font-size: 14px; font-weight: 600; line-height: 1.25; }
.badge span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.badge.locked { background: transparent; border-style: dashed; }
.badge.locked .ic { background: var(--emphasis); color: var(--faint); }
.badge.locked b { color: var(--muted); }

.onboard { display: flex; flex-direction: column; gap: 14px; padding: 8px 0 12px; }
.onboard-art { width: 120px; height: 64px; }
.onboard h2 { font: 400 30px/1.15 var(--font-display); text-wrap: balance; }
.onboard > p { color: var(--muted); }
.steps { margin: 4px 0 8px; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; color: var(--muted); }
.steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 700; color: var(--fg); font-size: 14px; }
.steps li > span { padding-top: 4px; } /* first line centred on the 30px number */
.steps b { color: var(--fg); font-weight: 600; }

/* ---------- people ---------- */
.person { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.person-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 400 20px/1 var(--font-display); color: #fff; flex: none; }
.avatar.a { background: var(--a); } .avatar.b { background: var(--b); }
.pname { flex: 1; min-width: 0; border: 0; background: transparent; font: 400 22px/1.2 var(--font-display); padding: 4px 0; border-bottom: 1.5px dashed transparent; border-radius: 0; }
.pname:focus { outline: 0; border-bottom-color: var(--border-strong); }
.pstatus { color: var(--muted); font-size: 14px; }
.pstatus.err { color: #dc2626; }
.person-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prose { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; }
.prose b { color: var(--fg); }
.note { background: transparent; border-style: dashed; }
code { font-size: 12.5px; background: var(--subtle); padding: 1px 5px; border-radius: 5px; }

/* ---------- person timeline ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 8px 0; }
.cal-title { font-size: 17px; }
.cal-title b { font-weight: 600; }
.cal-title span { color: var(--muted); font-weight: 500; }
.cal-nav { display: flex; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.weekdays span { font-size: 12px; font-weight: 600; color: var(--faint); text-align: center; padding-bottom: 4px; }
.day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 500; color: var(--faint); position: relative; font-variant-numeric: tabular-nums; }
.day.avail { color: var(--fg); font-weight: 600; background: var(--subtle); }
.day.inrange { background: var(--emphasis); }
.day.sel { background: var(--inverted); color: var(--on-inverted); }
.day.today::after { content: ""; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 34px; padding: 0 14px; border-radius: 17px; font-size: 14px; font-weight: 600; background: var(--subtle); }
.chip.on { background: var(--inverted); color: var(--on-inverted); }

/* ---------- sheets ---------- */
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%; max-height: 94dvh; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--fg); box-shadow: 0 -10px 40px rgb(0 0 0 / .2); overflow: hidden; display: none; flex-direction: column; }
dialog.sheet[open] { display: flex; animation: sheetUp .38s cubic-bezier(.32,.72,0,1); }
dialog.sheet.closing { animation: sheetDown .24s ease-in forwards; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .4); animation: fade .25s; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.grab-area { flex: none; height: 26px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--gutter-r) calc(20px + env(safe-area-inset-bottom, 0px)) var(--gutter-l); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font: 400 24px/1.2 var(--font-display); }
.sheet-head .btn { color: var(--fg); margin-right: -12px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input { min-height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; background: var(--subtle); font-weight: 500; font-size: 16px; min-width: 0; }
.hint { font-size: 13px; color: var(--muted); }
.share-preview { background: var(--subtle); border-radius: 16px; padding: 14px; display: grid; place-items: center; }
.share-preview img { display: block; max-width: 100%; max-height: 46dvh; width: auto; height: auto; border-radius: 10px; box-shadow: 0 10px 28px -8px rgb(0 0 0 / .35); }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.swatches { display: flex; gap: 12px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; background: var(--sw); border: 1px solid var(--border-strong); transition: box-shadow .15s; }
.swatches button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--fg); }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 50px; height: 30px; border-radius: 15px; background: var(--emphasis); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .22s cubic-bezier(.32,.72,0,1); }
.switch input:checked + i { background: var(--fg); }
/* Two people by default; "We're partners" brings back hearts and the romantic wording. */
body:not([data-partners]) .if-partners, body[data-partners] .if-pair { display: none; }
body[data-empty] #dPeople { display: none; }
.partners .switch { width: 100%; justify-content: space-between; }
.partners small { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.heart-pin svg.x circle, .heart-ic svg.x circle { fill: var(--a); opacity: 0.9; }
.heart-pin svg.x circle + circle, .heart-ic svg.x circle + circle { fill: var(--b); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--surface); }
.switch input:focus-visible + i { outline: 2px solid var(--fg); outline-offset: 2px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-total) + 16px); transform: translateX(-50%); z-index: 3000; background: var(--inverted); color: var(--on-inverted); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); animation: toast .25s cubic-bezier(.32,.72,0,1); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
.overlay { position: fixed; inset: 12px; border-radius: 20px; background: color-mix(in srgb, var(--surface) 85%, transparent); border: 2px dashed var(--fg); display: grid; place-items: center; z-index: 4000; font: 400 24px var(--font-display); pointer-events: none; }

/* ---------- map details ---------- */
.leaflet-container { font-family: var(--font-body); background: var(--bg); }
body[data-map="muted"] .leaflet-tile-pane { filter: var(--tile-filter); }
/* Map style picker */
.map-style { position: relative; }
.ms-btn { width: 36px; height: 36px; display: grid; place-items: center; background: var(--surface); color: var(--fg); border-radius: 12px; box-shadow: var(--shadow); }
.ms-btn svg { width: 18px; height: 18px; }
.ms-menu { position: absolute; top: 0; left: 44px; width: 172px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.ms-menu button { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; font-size: 14px; font-weight: 500; text-align: left; color: var(--fg); }
.ms-menu button:hover { background: var(--subtle); }
.ms-menu button[aria-checked="true"] { background: var(--emphasis); font-weight: 600; }
.ms-sw { width: 34px; height: 34px; flex: none; border-radius: 8px; background-size: cover; background-position: center; border: 1px solid var(--border); }
.ms-muted { filter: var(--tile-filter); }
/* On phones the picker sits beside the Together/You/Friend switcher: same height, clear of the notch. */
.leaflet-top { top: env(safe-area-inset-top, 0px); }
@media (max-width: 899px) { .ms-btn { width: 40px; height: 40px; } .ms-menu { left: 48px; } }
.leaflet-bar { border: 0 !important; border-radius: 12px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--fg) !important; border-color: var(--border) !important; width: 36px !important; height: 36px !important; line-height: 36px !important; }
.leaflet-tooltip, .leaflet-popup-content-wrapper { background: var(--surface); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-tooltip { padding: 6px 10px; font-size: 13px; }
.leaflet-tooltip b { font-weight: 600; }
.leaflet-control-attribution { background: transparent !important; color: var(--faint) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--faint) !important; }

.leaflet-div-icon { background: none; border: 0; }
.heart-pin { width: 30px; height: 30px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--fg); display: grid; place-items: center; box-shadow: var(--shadow); position: relative; }
.heart-pin svg { width: 15px; height: 15px; fill: var(--heart); }
.heart-pin.sel { width: 40px; height: 40px; background: var(--inverted); border-color: var(--inverted); }
.heart-pin.sel svg { width: 19px; height: 19px; }
.heart-pin.sel::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--heart); animation: pulse 1.8s cubic-bezier(.22,1,.36,1) infinite; }
@keyframes pulse { from { transform: scale(.7); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.dhead, .rail, .dslot { display: none; }
#storyMain, #sharedSec, #sinceSec, #itSec, #modesSec, #placesSec { display: flex; flex-direction: column; gap: 16px; }
#meetGroup { margin-top: 12px; }
.ccard.person-card { grid-template-columns: 1fr; gap: 8px; }
.ccard.person-card .actions { justify-content: space-between; margin: 0 -6px -6px; }
.leaflet-bottom.leaflet-right { top: auto; bottom: calc(var(--car-h, 96px) + 20px); }
.cell.sel { background: var(--emphasis); }
.settings-fields { display: flex; flex-direction: column; gap: 14px; }

/* ---------- desktop: side column + map + floating panel (earlier layout) ---------- */
@media (min-width: 900px) {
  :root { --tab-total: 0px; --gutter-l: 24px; --gutter-r: 24px; }
  body { font-size: 14px; }
  .app { right: auto; width: 380px; border-right: 1px solid var(--border); background: var(--surface); pointer-events: auto; display: flex; flex-direction: column; }
  .dhead { display: flex; flex-direction: column; gap: 16px; padding: 22px 24px 8px; flex: none; }
  .logo { display: flex; align-items: center; gap: 8px; font: 400 19px/1 var(--font-display); letter-spacing: 0.01em; }
  .logo svg { width: 26px; height: 26px; }
  .dhead .seg button { min-height: 32px; font-size: 13px; }
  .screens { position: relative; inset: auto; flex: 1; min-height: 0; }
  .screen { background: var(--surface); }
  .tabbar, .bar, #scr-story .large-title, .couple-chip, #meetGroup, #crossTitle, #scr-people, #scr-map, .map-top, .carousel, #personMap2, #openShareTop { display: none !important; }
  body[data-dview="couple"] #scr-story { display: flex; }
  body:not([data-dview="couple"]) #scr-story { display: none; }
  #scr-person { transform: none; box-shadow: none; display: none; transition: none; position: relative; inset: auto; flex: 1; min-height: 0; }
  body[data-dview="A"] #scr-person, body[data-dview="B"] #scr-person { display: flex; }
  body[data-dview="A"] .screens, body[data-dview="B"] .screens { display: none; }
  .scroll { padding: 12px 24px 28px; gap: 14px; }
  .dslot { display: flex; flex-direction: column; gap: 10px; }
  #dSettings { margin-top: 10px; padding-top: 18px; border-top: 1px solid var(--border); }

  /* compact people cards at the top of the side column */
  .person { padding: 12px 14px; gap: 8px; border-radius: 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .person-head { gap: 10px; min-width: 0; }
  .scroll { overflow-x: hidden; }
  .avatar { width: 32px; height: 32px; font-size: 15px; }
  .pname { font-size: 17px; padding: 2px 0; }
  .pstatus { grid-column: 1 / -1; font-size: 12.5px; order: 3; }
  .person-actions { display: flex; }
  .person-actions .btn { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
  .person-actions [id^="view"] { display: none; }

  .group-title { margin: 14px 2px -4px; font-size: 12px; }
  .hero { padding: 8px 0 4px; border-top: 1px solid var(--border); padding-top: 20px; margin-top: 4px; }
  .big { font-size: 84px; }
  .hero-line { font-size: 21px; margin-top: 10px; max-width: none; }
  .hero-sub { font-size: 13.5px; margin-top: 8px; }
  .btn.lg { min-height: 42px; font-size: 14px; border-radius: 10px; }
  .closest { padding: 14px 16px; border-radius: 14px; }
  .closest b { font-size: 24px; }
  .badges { gap: 8px; }
  .badge { padding: 10px 12px; gap: 6px; border-radius: 12px; }
  .badge .ic { width: 28px; height: 28px; border-radius: 8px; }
  .badge .ic svg.i { width: 15px; height: 15px; }
  .badge b { font-size: 12.5px; }
  .badge span { font-size: 11.5px; }
  .group { border-radius: 12px; }
  .group.pad { padding: 12px 14px; }
  .field input { min-height: 38px; font-size: 14px; border-radius: 9px; }
  .seg button { min-height: 30px; font-size: 13px; }

  /* person view: calendar in the side column */
  #scr-person .large-title { font-size: 26px; }
  .day { font-size: 13.5px; border-radius: 8px; }
  .chip { min-height: 28px; font-size: 13px; padding: 0 11px; }

  /* map + floating panel */
  #mapPane, body[data-tab="map"] #mapPane { left: 380px; bottom: 0; visibility: visible; z-index: 1; }
  .rail { display: flex; position: absolute; top: 16px; right: 16px; bottom: 16px; width: 340px; z-index: 600; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
  body[data-dview="couple"] #railPerson, body:not([data-dview="couple"]) #railCouple { display: none; }
  .rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 14px; border-bottom: 1px solid var(--border); flex: none; }
  .rail-head h2 { font: 400 19px/1.2 var(--font-display); }
  .rail-head p { margin-top: 2px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
  .rail-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
  .rail-body > * { flex-shrink: 0; }
  .rail .cell { min-height: 56px; padding: 9px 12px; gap: 12px; }
  .rail .tile { width: 42px; }
  .rail .tile b { font-size: 17px; }
  .rail .cell-main b { font-size: 13.5px; }
  .rail .cell-main span { font-size: 12px; }
  .rail .cell-ic { width: 30px; height: 30px; border-radius: 8px; }
  .rail .group-title { margin: 10px 2px -6px; }
  .rail-body #sharedSec, .rail-body #sinceSec, .rail-body #itSec, .rail-body #modesSec, .rail-body #placesSec { gap: 14px; }
  .rail .stat b { font-size: 22px; }

  dialog.sheet { inset: 0; margin: auto; width: min(460px, calc(100vw - 48px)); height: fit-content; max-height: calc(100dvh - 48px); border-radius: 20px; }
  dialog.sheet[open] { animation: pop .22s cubic-bezier(.32,.72,0,1); }
  dialog.sheet.closing { animation: fadeOut .15s forwards; }
  .grab-area { display: none; }
  .sheet-body { padding-top: 18px; }
  .toast { left: 190px; bottom: 20px; }
  .leaflet-bottom.leaflet-right { bottom: 0; }
  .leaflet-top.leaflet-left { top: 4px; }
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes fadeOut { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.cell-empty { padding: 16px; color: var(--muted); font-size: 14px; }
.scroll > *, .sheet-body > * { flex-shrink: 0; }
