:root {
  --bg: #15171c; --panel: #1e2128; --panel2: #272b34; --line: #2f343e;
  --text: #f1f2f4; --muted: #9aa1ad; --accent: #ff6a1a; --accent-ink: #1a0d04;
  --ok: #3ccf91; --bad: #ff5468; --me: #3a2417; --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f2ee; --panel: #ffffff; --panel2: #ece9e3; --line: #ddd8cf; --text: #1b1c1f; --muted: #6b6f78; --accent-ink: #fff; --me: #ffe3d2; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { display: flex; justify-content: center; }
#app { width: 100%; max-width: 480px; height: 100dvh; position: relative; overflow: hidden; background: var(--bg); }
@media (min-width: 600px) { #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; }

.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hdr { padding: calc(14px + var(--safe-t)) 18px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); min-height: 60px; }
.hdr h1 { margin: 0; font-size: 20px; flex: 1; }
.hdr .sub { font-size: 12px; color: var(--muted); }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.iconbtn:active { background: var(--panel2); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px; }

nav.tabs { display: flex; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: var(--safe-b); }
nav.tabs button { flex: 1; padding: 10px 0 8px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
nav.tabs button.on { color: var(--accent); }
nav.tabs svg { width: 24px; height: 24px; }
.dot { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 700; color: var(--accent); flex: none; }
.btn { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 11px 18px; border-radius: 14px; }
.btn.ghost { background: var(--panel2); color: var(--text); }
.btn.sm { padding: 7px 12px; border-radius: 10px; font-size: 14px; }
.btn.bad { background: var(--bad); color: #fff; }
.btn[disabled] { opacity: .5; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; margin: 18px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

.login { padding: 0 24px; justify-content: center; gap: 14px; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; }
.login h1 { margin: 8px 0 0; font-size: 34px; letter-spacing: -.02em; }
.login p { margin: 0; color: var(--muted); }
.testmode { font-size: 12px; background: var(--panel2); border: 1px dashed var(--accent); color: var(--accent); border-radius: 10px; padding: 8px 10px; }

/* chat */
#msgs { display: flex; flex-direction: column; gap: 6px; }
.bub { max-width: 80%; padding: 9px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); word-wrap: break-word; overflow-wrap: anywhere; }
.bub.me { align-self: flex-end; background: var(--me); border-color: transparent; border-bottom-right-radius: 5px; }
.bub.them { align-self: flex-start; border-bottom-left-radius: 5px; }
.bub .t { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bub.gone { color: var(--muted); font-style: italic; }
.voice { display: flex; align-items: center; gap: 10px; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.voice .play[disabled] { background: var(--panel2); color: var(--muted); }
.voice .info { font-size: 14px; }
.voice .info small { display: block; color: var(--muted); font-size: 12px; }
.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 14px calc(12px + var(--safe-b)); }
.textrow { display: flex; gap: 8px; margin-bottom: 12px; }
.textrow input { border-radius: 22px; }
.send { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
#ptt { width: 100%; height: 76px; border-radius: 38px; background: var(--panel2); border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 700; font-size: 17px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; transition: background .12s, border-color .12s; }
#ptt svg { width: 28px; height: 28px; }
#ptt.requesting { border-color: var(--accent); color: var(--accent); }
#ptt.talking { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255,106,26,.22); } }
.listen { position: absolute; left: 12px; right: 12px; top: calc(66px + var(--safe-t)); z-index: 5; background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; display: none; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.listen.on { display: flex; }
.bars { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; }
.bars i { width: 3px; background: currentColor; border-radius: 2px; animation: bar .8s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: .15s; } .bars i:nth-child(3) { animation-delay: .3s; }
@keyframes bar { 0%, 100% { height: 4px; } 50% { height: 16px; } }

.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--panel); border-radius: 22px 22px 0 0; padding: 14px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.sheet .btn { width: 100%; text-align: center; }

#toast { position: fixed; left: 50%; bottom: calc(170px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #000d; color: #fff; padding: 10px 16px; border-radius: 22px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
.dot[hidden] { display: none; }

/* around (map) */
.scroll.flush { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.chips { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; flex: none; border-bottom: 1px solid var(--line); }
.chip { flex: none; padding: 6px 12px; border-radius: 16px; background: var(--panel2); font-size: 13px; color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
#mapwrap { position: relative; flex: 0 0 48%; min-height: 220px; }
#map { position: absolute; inset: 0; background: var(--panel2); z-index: 0; }
#list { flex: 1; overflow-y: auto; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; }
.fab { position: absolute; right: 12px; bottom: 12px; z-index: 500; display: flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 11px 16px; border-radius: 24px; box-shadow: 0 4px 14px #0006; }
.locate { position: absolute; left: 12px; bottom: 44px; z-index: 500; width: 44px; height: 44px; border-radius: 50%; background: var(--panel); color: var(--text); display: grid; place-items: center; box-shadow: 0 2px 10px #0005; }
.sharepill { position: absolute; left: 12px; top: 10px; z-index: 500; background: var(--panel); border: 1px solid var(--ok); color: var(--text); font-size: 12px; border-radius: 14px; padding: 5px 6px 5px 10px; display: flex; align-items: center; gap: 6px; }
.sharepill[hidden] { display: none; }
.sharepill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
.sharepill button { background: var(--panel2); border-radius: 10px; padding: 2px 8px; font-size: 12px; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px #0007; background: var(--accent); }
.pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 13px; }
.pin.verified, .pin-s.verified { background: var(--ok); } .pin.disputed, .pin-s.disputed { background: var(--bad); }
.pin-s { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.person { width: 30px; height: 30px; border-radius: 50%; background: #3b82f6; color: #fff; display: grid; place-items: center; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 6px #0007; }
.person.fuzzy { opacity: .75; border-style: dashed; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 6px #2563eb33; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--panel2); color: var(--muted); vertical-align: middle; }
.badge.verified { background: var(--ok); color: #04210f; } .badge.disputed { background: var(--bad); color: #fff; }
.sheet.scrolly { max-height: 86%; overflow-y: auto; }
.rphoto { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; background: var(--panel2); }
select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; margin-top: 4px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.switch input { width: 24px; height: 24px; accent-color: var(--accent); }
.filebtn { cursor: pointer; text-align: center; }
.pinwrap { width: 30px; height: 40px; padding-top: 4px; cursor: pointer; }
.person, .me-dot { cursor: default; }

/* groups, rooms, gifts */
.bub .who { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.giftgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gift { background: var(--panel2); border: 2px solid transparent; border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; }
.gift span { font-size: 28px; } .gift small { color: var(--muted); }
.gift.on { border-color: var(--accent); }
.sub { font-size: 12px; color: var(--muted); }

.bell { position: relative; font-size: 22px; padding: 4px 8px; }
.bell .dot { position: absolute; top: -2px; right: 0; left: auto; }
.bar { height: 8px; border-radius: 4px; background: var(--panel2); margin: 8px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.camp { cursor: pointer; }
.sheet textarea, .sheet input[type=date], .sheet input[type=time], .sheet input[type=number] { width: 100%; }
.sheet .btn.sm { width: auto; flex: none; } .sheet .row { padding: 8px 0; } .sheet input[type=time] { flex: 1; }
