/* Nearby Now. Layout: one-column phone app shell. The palette follows the time of day (set by period.js). */
:root {
  color-scheme: dark;
  --bg: #120f22; --surface: #1c1833; --surface-2: #262044; --line: #352d5a;
  --fg: #f1ecff; --muted: #a49cc4;
  --accent: #ff9a4d; --accent-ink: #2a1300; --rose: #ff5f8f; --ok: #57d9a3; --bad: #ff6b6b;
  --glow1: rgba(255,154,77,.16); --glow2: rgba(255,95,143,.10);
  --nav: rgba(18,15,34,.92); --scrim: rgba(5,3,14,.6);
  --c-woman: #ff5f8f; --c-man: #4da3ff; --c-couple: #b57bff; --c-nb: #3fd0a6;
  --map-bg: #171330;
  --display: "Syne", "Trebuchet MS", sans-serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
:root[data-period="morning"] {
  --bg: #1a1630; --surface: #251f3d; --surface-2: #30284f; --line: #40366a;
  --accent: #ffb46b; --glow1: rgba(255,180,110,.32); --glow2: rgba(255,130,170,.20); --nav: rgba(26,22,48,.92); --map-bg: #211b3a;
}
:root[data-period="day"] {
  color-scheme: light;
  --bg: #f4f2fb; --surface: #ffffff; --surface-2: #ece8f7; --line: #d9d2ee;
  --fg: #1d1733; --muted: #6a6288; --accent: #e0611f; --accent-ink: #ffffff; --rose: #e0336b; --ok: #12935f; --bad: #c62828;
  --glow1: rgba(255,170,60,.22); --glow2: rgba(80,170,255,.16); --nav: rgba(244,242,251,.92); --scrim: rgba(20,15,40,.4);
  --c-woman: #e0336b; --c-man: #2f7fe0; --c-couple: #8a4fe0; --c-nb: #14a37a; --map-bg: #e9e6f3;
}
:root[data-period="evening"] {
  --bg: #170f25; --surface: #22183a; --surface-2: #2e2149; --line: #3f2f62;
  --accent: #ff8a5c; --glow1: rgba(255,110,90,.26); --glow2: rgba(170,90,255,.20); --nav: rgba(23,15,37,.92); --map-bg: #1d1430;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.45;
  background-image: radial-gradient(60% 40% at 80% -5%, var(--glow1), transparent 70%),
                    radial-gradient(50% 35% at 0% 100%, var(--glow2), transparent 70%);
  background-attachment: fixed;
  padding-top: env(safe-area-inset-top, 0px);
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.brand { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: .95; }
.brand em { font-style: normal; color: var(--accent); }
.brand.big { font-size: clamp(48px, 12vw, 84px); }
.lede { font-size: 17px; color: var(--muted); max-width: 44ch; margin: 0; }

.btn { border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 700; background: var(--surface-2); text-decoration: none; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); }
.btn.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 4px; }

.field { display: grid; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=date], .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
}
.field textarea { resize: vertical; min-height: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip-in { position: relative; }
.chip-in input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-in span { display: inline-block; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 500; }
.chip-in input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip-in input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: 0 0 18px; }
.notice-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); border: 1px solid var(--ok); border-radius: 12px; padding: 10px 14px; }
.live.pending { border-color: var(--accent); }
.error { background: color-mix(in srgb, var(--bad) 16%, transparent); border: 1px solid var(--bad); border-radius: 12px; padding: 10px 14px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.v { color: var(--ok); }
.t-woman { --tc: var(--c-woman); } .t-man { --tc: var(--c-man); } .t-couple { --tc: var(--c-couple); } .t-nb { --tc: var(--c-nb); }
.tdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tc, var(--muted)); margin-right: 6px; vertical-align: 1px; }

/* ----- landing ----- */
.land {
  max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; align-items: start;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 48px 32px;
}
@media (max-width: 820px) { .land { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-block: 32px; } }
.hero { display: grid; gap: 22px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.steps li::marker { font-family: var(--mono); color: var(--accent); }
.rules { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; color: var(--muted); }
.rules li { display: flex; gap: 10px; }
.rules li::before { content: ""; flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--accent); }
.upnow-auth { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 22px; display: grid; gap: 16px; max-width: 520px; }
.upnow-auth h2 { font-size: 24px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.tabs a { text-align: center; padding: 9px; border-radius: 999px; font-weight: 700; text-decoration: none; color: var(--muted); }
.tabs a[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.form { display: grid; gap: 16px; }

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px;
  max-width: 1040px; margin: 0 auto; padding-block: 24px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.foot nav { display: flex; gap: 16px; }
.foot a { color: var(--muted); }

/* ----- documents ----- */
.docpage {
  max-width: 720px; margin: 0 auto; display: grid; gap: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 32px;
}
.docpage h1 { font-size: 36px; }
.docpage h2 { font-size: 20px; margin-top: 14px; }
.docpage p, .docpage li { max-width: 68ch; }
.docpage ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.back { text-decoration: none; font-weight: 700; }
.draft { background: color-mix(in srgb, var(--accent) 14%, transparent); border: 1px dashed var(--accent); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.sos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.sos div { background: var(--surface); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; }
.sos b { font-size: 22px; }

/* ----- app shell ----- */
.app {
  max-width: 560px; margin: 0 auto; display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 calc(96px + env(safe-area-inset-bottom, 0px));
}
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 500; background: var(--bg); padding-block: 14px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body.in-app::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 501; background: var(--bg); }
.clock { font-family: var(--mono); color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.clock i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.live { border-radius: 22px; padding: 18px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); transition: background .3s, border-color .3s; }
.live.on { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, var(--surface)), color-mix(in srgb, var(--rose) 14%, var(--surface))); border-color: var(--accent); }
.live-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.live h2 { font-size: 21px; }
.switch { position: relative; flex: 0 0 64px; height: 36px; border-radius: 999px; border: 0; background: var(--surface-2); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(28px); background: var(--accent-ink); }
.switch[aria-busy="true"] { opacity: .6; }
.dur { display: flex; gap: 6px; flex-wrap: wrap; }
.dur .chip { padding: 6px 12px; font-size: 13px; }
.pulse { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 12px transparent; } }

.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-head h3 { font-size: 18px; }
.viewtoggle { display: inline-grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.viewtoggle button { border: 0; background: none; padding: 6px 16px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted); }
.viewtoggle button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filters .chip { white-space: nowrap; font-size: 13px; padding: 6px 12px; }
/* ----- map ----- */
.mapwrap { position: relative; }
.map { height: min(62vh, 580px); min-height: 360px; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: var(--map-bg); z-index: 1; }
.map-tag { position: absolute; z-index: 450; font-size: 11px; font-weight: 700; background: var(--surface); color: var(--muted); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.map-msg { position: absolute; z-index: 450; inset: auto 14px 14px; text-align: center; background: var(--surface); padding: 12px 14px; border-radius: 14px; color: var(--muted); font-size: 13px; display: grid; gap: 10px; justify-items: center; }
.leaflet-container { background: var(--map-bg); font-family: var(--body); }
.map.darken .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.78) contrast(.92) saturate(.55); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--fg) !important; border-color: var(--line) !important; }
.pin-icon, .you-icon { background: none; border: 0; }
.pin { display: grid; justify-items: center; gap: 3px; cursor: pointer; animation: drift var(--dur, 7s) ease-in-out infinite; animation-delay: var(--dl, 0s); }
.pin .face { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 800; font-size: 15px; border: 3px solid var(--tc); box-shadow: 0 4px 14px rgba(0,0,0,.35); background-size: cover; background-position: center; transition: transform .15s; }
.pin .pname { font-size: 11px; font-weight: 700; background: var(--surface); color: var(--fg); padding: 1px 7px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.pin:hover .face { transform: scale(1.12); }
.pin .face { position: relative; }
.pin .face.no-photo { font-size: 24px; }
.pin-emo { position: absolute; right: -9px; bottom: -7px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; line-height: 1; background: var(--surface); border: 2px solid var(--tc); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pin.knocked .face { outline: 2px dashed var(--tc); outline-offset: 3px; }
.pin.knocked-me .pname { background: var(--rose); color: #fff; }
.pin.matched .pname { background: var(--ok); color: #fff; }
@keyframes drift { 50% { transform: translate(var(--dx, 3px), var(--dy, -3px)); } }
.you-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--muted); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.you-dot.on { background: var(--accent); animation: pulse 1.8s infinite; }

/* ----- lists ----- */
.list { display: grid; gap: 10px; }
.card { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; background: var(--surface); border: 1px solid transparent; border-radius: 18px; padding: 12px; width: 100%; }
button.card:hover { border-color: var(--line); }
.card .name { font-weight: 700; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { text-align: right; display: grid; gap: 4px; justify-items: end; }
.av { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 20px; color: #fff; position: relative; background-size: cover; background-position: center; flex: 0 0 auto; }
.av.lg { width: 96px; height: 96px; border-radius: 26px; font-size: 32px; }
.av.sm { width: 36px; height: 36px; border-radius: 11px; font-size: 14px; }
.left { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 18px; }

/* ----- bottom nav ----- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; background: var(--nav); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nav button { background: none; border: 0; padding: 10px 4px; border-radius: 12px; font-weight: 700; font-size: 13px; color: var(--muted); position: relative; }
.nav button[aria-current="page"] { color: var(--fg); background: var(--surface); }
.badge { position: absolute; top: 4px; margin-left: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--rose); color: #fff; font-size: 11px; display: inline-grid; place-items: center; }

/* ----- sheet ----- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 700; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 22px max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: grid; gap: 16px; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
.sheet-head { display: flex; gap: 16px; align-items: center; }
.sheet-head h2 { font-size: 26px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kv div { background: var(--surface-2); border-radius: 14px; padding: 10px; display: grid; gap: 2px; min-width: 0; }
.kv b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1 1 140px; }
.small-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.big-photo { width: 100%; aspect-ratio: 4 / 5; max-height: 52vh; object-fit: cover; border-radius: 20px; background: var(--surface-2); }

/* ----- chat ----- */
.thread { display: grid; gap: 8px; padding-block: 8px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 18px; background: var(--surface-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me { justify-self: end; background: var(--accent); color: var(--accent-ink); }
.msg.sys { justify-self: center; background: none; color: var(--muted); font-size: 12px; text-align: center; max-width: 90%; }
.safety { background: var(--surface); border-radius: 16px; padding: 12px 14px; font-size: 13px; color: var(--muted); display: grid; gap: 8px; }
.safety strong { color: var(--fg); }
.composer { display: flex; gap: 8px; position: sticky; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); padding-block: 8px; background: var(--bg); }
.composer input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 12px 16px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 800; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

/* ----- phones ----- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overflow-x: clip; }
/* 16px text in fields stops iPhones zooming in when a field is tapped */
.field input, .field select, .field textarea, .composer input { font-size: 16px; }
.btn { min-height: 48px; }
.btn.sm { min-height: 36px; }
.form .btn.primary { width: 100%; }
#join { scroll-margin-top: 84px; }
.map { height: min(62dvh, 580px); }
.sheet { max-height: 92dvh; overscroll-behavior: contain; }
@media (pointer: coarse) {
  .chip, .chip-in span { min-height: 44px; display: inline-flex; align-items: center; padding-inline: 16px; }
  .dur .chip, .filters .chip { min-height: 40px; }
  .viewtoggle button { min-height: 38px; }
  .tabs a { padding: 12px; }
  .nav button { min-height: 52px; font-size: 14px; }
  .link { padding: 10px; }
  .check { font-size: 15px; }
  .check input { width: 22px; height: 22px; flex-basis: 22px; margin-top: 1px; }
  .pin:hover .face { transform: none; }
}
@media (max-width: 600px) {
  body { background-attachment: scroll; }
  .upnow-auth { padding: 18px; border-radius: 20px; max-width: none; }
  .map { min-height: 320px; border-radius: 18px; }
  .sheet-head h2 { font-size: 22px; }
  .kv { gap: 6px; }
  .kv div { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
