/* Peloton — OLED-dark UI (visual language per mockup.html) */
:root {
  --bg: #0b0e13;
  --bg2: #12161f;
  --card: #171c27;
  --card2: #1d2331;
  --line: #262d3d;
  --ink: #eef2f9;
  --muted: #7d8590;
  --muted2: #59616e;
  --accent: #6d8dff;
  --accent2: #8b6dff;
  --ok: #34d27b;
  --warn: #ffb020;
  --bad: #ff5d6c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  overscroll-behavior: none; user-select: none;
  -webkit-user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; overflow-y: auto;
  padding: calc(14px + var(--safe-top)) 18px calc(18px + var(--safe-bot)); background: var(--bg); }
.screen.on { display: flex; }
.screen.center { justify-content: center; align-items: center; text-align: center; }

/* ---------- welcome ---------- */
.logo { width: 88px; height: 88px; border-radius: 24px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 40px rgba(109, 141, 255, .35); }
.logo svg { width: 46px; height: 46px; }
h1.appname { font-size: 34px; letter-spacing: -.5px; }
.tagline { color: var(--muted); margin: 6px 0 34px; font-size: 16px; }
.btn { display: block; width: 100%; max-width: 380px; margin: 0 auto 12px; padding: 15px 18px;
  border-radius: 15px; font-size: 16.5px; font-weight: 650; text-align: center; transition: transform .06s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  box-shadow: 0 6px 26px rgba(109, 141, 255, .3); }
.btn.ghost { background: var(--card); border: 1px solid var(--line); }
.btn.danger { background: none; border: 1px solid rgba(255, 93, 108, .5); color: var(--bad); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.foot { color: var(--muted2); font-size: 13px; margin-top: 20px; max-width: 300px; }

/* ---------- join / create ---------- */
.topnav { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex: none; }
.backbtn { width: 38px; height: 38px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.topnav h2 { font-size: 19px; }
.lbl { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 9px; }
.codegrid { display: flex; gap: 7px; }
.codegrid input, .codegrid .cell { flex: 1; min-width: 0; height: 54px; border-radius: 12px; background: var(--card);
  border: 1.5px solid var(--line); text-align: center; font-size: 23px; font-weight: 700; text-transform: uppercase; }
.codegrid input:focus { outline: none; border-color: var(--accent); }
.codegrid.pin input, .codegrid.pin .cell { max-width: 62px; }
.bigcode { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.bigcode .cell { display: flex; align-items: center; justify-content: center; background: var(--card2); }
.note { display: flex; gap: 10px; align-items: flex-start; background: rgba(255, 176, 32, .08);
  border: 1px solid rgba(255, 176, 32, .35); border-radius: 13px; padding: 12px 14px;
  font-size: 13.5px; color: #e8c98a; margin-top: 14px; }
.note.blue { background: rgba(109, 141, 255, .08); border-color: rgba(109, 141, 255, .35); color: #a9bdf5; }
.note.red { background: rgba(255, 93, 108, .1); border-color: rgba(255, 93, 108, .4); color: #f5a9b0; }
input.txt { width: 100%; height: 52px; border-radius: 13px; background: var(--card);
  border: 1.5px solid var(--line); padding: 0 16px; font-size: 16px; }
input.txt:focus { outline: none; border-color: var(--accent); }
.swatches { display: flex; gap: 11px; margin-top: 12px; flex-wrap: wrap; }
.sw { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; position: relative; }
.sw.sel { border-color: #fff; }
.modes { display: flex; gap: 8px; margin-top: 4px; }
.mode { flex: 1; padding: 11px 6px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line);
  text-align: center; font-size: 14px; font-weight: 600; }
.mode.sel { border-color: var(--accent); background: rgba(109, 141, 255, .12); }
.spacer { flex: 1; min-height: 18px; }
.err { color: var(--bad); font-size: 14px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ---------- map screen ---------- */
#scr-map { padding: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: #0d1017; }
.maptop { position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(10px + var(--safe-top)) 14px 26px;
  background: linear-gradient(180deg, rgba(11, 14, 19, .92), rgba(11, 14, 19, 0));
  display: flex; align-items: center; gap: 10px; pointer-events: none; }
.maptop > * { pointer-events: auto; }
.roomname { font-size: 17px; font-weight: 700; }
.bigcode .cell { user-select: text; -webkit-user-select: text; }
.roomcount { font-size: 12px; font-weight: 700; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 8px; color: var(--muted); }
.mapbtns { margin-left: auto; display: flex; gap: 8px; }
.mapbtn { width: 40px; height: 40px; border-radius: 50%; background: rgba(23, 28, 39, .92);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.mapbtn.active { border-color: var(--accent); color: var(--accent); }
.wakepill { position: absolute; right: 12px; z-index: 20; font-size: 12px; font-weight: 650;
  background: rgba(23, 28, 39, .92); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px;
  color: var(--ok); transition: bottom .25s; }
.wakepill.off { color: var(--warn); }
.conn { position: absolute; left: 50%; transform: translateX(-50%); top: calc(54px + var(--safe-top)); z-index: 30;
  font-size: 12.5px; font-weight: 650; background: rgba(255, 176, 32, .15); border: 1px solid rgba(255, 176, 32, .5);
  color: var(--warn); border-radius: 99px; padding: 6px 14px; display: none; }
.conn.show { display: block; }

/* member map markers */
.mk { position: relative; width: 0; height: 0; }
.mk .dot { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c, #999); border: 3px solid #0b0e13; box-shadow: 0 0 14px var(--c, #999); }
.mk.me .dot { background: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, .8); }
.mk .hdg { position: absolute; left: -5px; top: -24px; width: 0; height: 0; transform-origin: 5px 24px;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid #fff; }
.mk .tag { position: absolute; left: 50%; top: 13px; transform: translateX(-50%); white-space: nowrap;
  font-size: 11px; font-weight: 700; background: rgba(11, 14, 19, .85); border-radius: 6px; padding: 2px 7px; }
.mk.stale .dot { opacity: .45; box-shadow: none; border-style: dashed; }
.mk.stale .tag { opacity: .55; }
.mk-meet { font-size: 26px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); transform: translateY(-13px); }

/* bottom sheet */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 25;
  background: rgba(18, 22, 31, .97); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 10px 14px calc(12px + var(--safe-bot)); max-height: 46%; display: flex; flex-direction: column;
  transition: max-height .25s; }
.sheet.mini { max-height: 92px; overflow: hidden; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 8px; flex: none; }
.sheethead { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; flex: none; }
.sheethead .t { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; color: var(--muted); }
.sheethead .n { margin-left: auto; font-size: 12px; color: var(--muted2); }
.mlist { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.mrow { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 13px; background: var(--card); }
.mrow:active { background: var(--card2); }
.mrow .cdot { width: 13px; height: 13px; border-radius: 50%; background: var(--c, #999);
  box-shadow: 0 0 8px var(--c, #999); flex: none; }
.mrow .info { flex: 1; min-width: 0; }
.mrow .nm { font-size: 15px; font-weight: 650; }
.mrow .sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow .dist { font-size: 19px; font-weight: 750; letter-spacing: -.3px; white-space: nowrap; }
.mrow .arr { width: 20px; height: 20px; flex: none; color: var(--muted); transition: transform .4s; }
.mrow.warned .sub, .mrow.warned .dist { color: var(--warn); }
.mrow.stale { opacity: .55; }
.mrow.stale .dist { color: var(--muted); font-size: 16px; }
.mrow.hl { outline: 1.5px solid var(--ok); }

/* ---------- detail / radar ---------- */
.dhead { text-align: center; margin: 6px 0 4px; }
.dhead .cdot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-right: 7px; }
.dhead .nm { font-size: 18px; font-weight: 700; }
.bigdist { text-align: center; font-size: 62px; font-weight: 800; letter-spacing: -2px; margin-top: 8px; }
.bigsub { text-align: center; color: var(--muted); font-size: 15px; margin-top: 2px; min-height: 20px; }
.trend { text-align: center; font-size: 14px; margin-top: 6px; min-height: 20px; }
.trend .up { color: var(--ok); } .trend .down { color: var(--warn); }
.compass { width: 230px; height: 230px; border-radius: 50%; margin: 22px auto 8px; position: relative;
  background: radial-gradient(circle at 50% 40%, #1a2030, #10141d 70%); border: 1px solid var(--line); }
.compass .lab { position: absolute; font-size: 12px; font-weight: 700; color: var(--muted2); }
.compass .lab.n { top: 9px; left: 50%; transform: translateX(-50%); color: #8ba4d6; }
.compass .lab.s { bottom: 9px; left: 50%; transform: translateX(-50%); }
.compass .lab.e { right: 11px; top: 50%; transform: translateY(-50%); }
.compass .lab.w { left: 11px; top: 50%; transform: translateY(-50%); }
.needle { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: transform .35s; }
.needle::before { content: ''; position: absolute; left: -7px; top: -86px;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 15px solid var(--c, #fff); filter: drop-shadow(0 0 7px var(--c, #fff)); }
.needle::after { content: ''; position: absolute; left: -2.5px; top: -74px; width: 5px; height: 62px;
  border-radius: 3px; background: linear-gradient(180deg, var(--c, #fff), transparent); }
.statrow { display: flex; gap: 9px; margin-top: 18px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 10px 8px; text-align: center; }
.stat .v { font-size: 16px; font-weight: 700; }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dbtns { display: flex; gap: 10px; margin-top: 18px; }
.dbtns .btn { margin: 0; flex: 1; }
.updline { text-align: center; color: var(--muted2); font-size: 12.5px; margin-top: 14px; }
.spark { width: 100%; height: 74px; margin-top: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; padding: 8px; }

/* ---------- settings / diag ---------- */
.sect { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 8px; }
.tgl { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 7px; }
.tgl .tx { flex: 1; }
.tgl .tt { font-size: 15px; font-weight: 600; }
.tgl .ts { font-size: 12px; color: var(--muted); margin-top: 2px; }
.knob { width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative;
  transition: background .2s; flex: none; }
.knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: left .2s; }
.tgl.on .knob { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.tgl.on .knob::after { left: 23px; }
.kv { display: flex; justify-content: space-between; padding: 9px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.ver { text-align: center; color: var(--muted2); font-size: 12px; margin-top: 24px; }

/* ---------- toast / install ---------- */
.modal { position: fixed; inset: 0; z-index: 120; background: rgba(5, 7, 10, .75); display: none;
  align-items: center; justify-content: center; padding: 20px; }
.modal.show { display: flex; }
.modalbox { width: 100%; max-width: 420px; background: var(--card2); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; }
.modalbox h3 { font-size: 18px; margin-bottom: 6px; }
.modalsub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.txtarea { width: 100%; min-height: 120px; border-radius: 13px; background: var(--card);
  border: 1.5px solid var(--line); padding: 12px 14px; font: inherit; color: var(--ink); resize: vertical; }
.txtarea:focus { outline: none; border-color: var(--accent); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-bot));
  z-index: 100; background: var(--card2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 18px; font-size: 14.5px; box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 88vw; text-align: center; }
.toast.show { opacity: 1; }
.iosinstall { position: fixed; left: 12px; right: 12px; bottom: calc(14px + var(--safe-bot)); z-index: 90;
  background: var(--card2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  font-size: 13.5px; color: var(--muted); display: none; }
.iosinstall.show { display: block; }
.iosinstall b { color: var(--ink); }
.iosinstall .x { position: absolute; right: 10px; top: 8px; color: var(--muted2); font-size: 17px; padding: 4px; }
@media (min-width: 700px) {
  .screen { max-width: 460px; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  #scr-map { max-width: none; left: 0; transform: none; border: 0; }
}
