/* iamurph v3 — design tokens + delight-first dark UI. */
:root {
  --bg: #0b0b10;
  --bg-2: #12121a;
  --card: #171724;
  --card-2: #1e1e2e;
  --text: #f2f2f7;
  --muted: #9a9aad;
  --accent: #7c5cff;
  --accent-2: #4fd1c5;
  --danger: #ff5c5c;
  --line: rgba(255, 255, 255, 0.07);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --topbar-h: 54px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --chrome-top: calc(var(--topbar-h) + var(--safe-top));
  --chrome-bottom: calc(var(--nav-h) + var(--safe-bottom));
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--chrome-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) calc(18px + var(--safe-right)) 0 calc(18px + var(--safe-left));
  background: rgba(11, 11, 16, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-mark { font-size: 19px; }
.page-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); }

/* ---- Layout ---- */
main { padding-bottom: calc(var(--chrome-bottom) + 18px); }
.tab { display: none; min-height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom)); }
.tab.active { display: flex; flex-direction: column; }
.tab-body { padding: 20px calc(20px + var(--safe-right)) 20px calc(20px + var(--safe-left)); display: flex; flex-direction: column; gap: 16px; max-width: 680px; width: 100%; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card p { margin: 0 0 10px; }
.card-danger { border-color: rgba(255, 92, 92, 0.35); }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #262640; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #8d70ff; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 92, 92, 0.12); }
.btn-small { min-height: 44px; padding: 9px 14px; font-size: 14px; }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type="text"], textarea {
  width: 100%;
  min-height: 48px;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.pin-input { max-width: 120px; text-align: center; font-size: 20px; letter-spacing: 0.35em; }

/* ---- Text helpers ---- */
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- Bottom nav ---- */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--chrome-bottom);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: flex;
  background: rgba(11, 11, 16, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  flex: 1;
  min-width: 44px;
  min-height: 44px;
  appearance: none;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s ease, transform 0.12s ease;
}
.nav-btn:active { transform: scale(0.96); }
.nav-btn.active { color: #fff; }
.nav-icon { line-height: 0; }
.nav-icon svg { width: 24px; height: 24px; display: block; }
.nav-label { font-size: 11px; font-weight: 600; }

/* ---- AI tab ---- */
.ai-head { display: flex; align-items: center; gap: 8px; padding: 16px calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left)); max-width: 680px; width: 100%; margin: 0 auto; }
.ai-head-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.ai-badge {
  font-size: 12px; font-weight: 600; line-height: 1.2; color: var(--muted);
  background: transparent; border: 1px solid var(--line);
  padding: 4px 8px; border-radius: 999px;
}
.ai-msgs { flex: 1; overflow-y: auto; padding: 16px calc(20px + var(--safe-right)) 18px calc(20px + var(--safe-left)); display: flex; flex-direction: column; gap: 12px; max-width: 680px; width: 100%; margin: 0 auto; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 20px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 2px 12px rgba(124, 92, 255, 0.35); }
.msg-ai { align-self: flex-start; background: var(--card-2); border: 1px solid rgba(255, 255, 255, 0.12); border-bottom-left-radius: 6px; }
.ai-composer {
  position: sticky;
  bottom: var(--chrome-bottom);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left));
  background: var(--bg);
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}
.ai-composer input { flex: 1; min-height: 48px; border-radius: 999px; padding: 12px 18px; background: var(--card-2); border-color: rgba(255, 255, 255, 0.12); }
.ai-composer input::placeholder { color: var(--muted); opacity: 1; }
.ai-composer input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.ai-send { flex: none; width: 48px; height: 48px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 12px rgba(124, 92, 255, 0.4); }
.ai-send svg { width: 20px; height: 20px; display: block; margin-left: -2px; }
.ai-send:hover { background: #8d70ff; }

/* ---- Me tab ---- */
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.me-avatar-img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--card-2); flex: none; }
.me-avatar-fallback { display: flex; align-items: center; justify-content: center; font-size: 34px; }
.me-name { font-size: 20px; font-weight: 700; }
.me-handle { color: var(--muted); font-size: 14px; }
.pager-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.pager-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.pager-id { font-size: 18px; font-weight: 700; letter-spacing: 0.12em; }
.link-flow { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---- Welcome overlay ---- */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.welcome.show { display: flex; }
.welcome-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.welcome-mark { font-size: 44px; }
.welcome-card h2 { margin: 8px 0; font-size: 22px; }
.welcome-card p { color: var(--muted); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  /* Clears the AI-tab composer (which occupies the band from the nav bar
     up ~64px): the old bottom sat inside that band, so the toast pill
     covered the "Ask Murph…" field for its whole 2.8s life. */
  bottom: calc(var(--chrome-bottom) + 84px);
  transform: translateX(-50%) translateY(8px);
  z-index: 60;
  background: #262640;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px - var(--safe-left) - var(--safe-right));
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

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

/* ---- v3 module classes (Tracks C/D) ---- */
.v3-btn, .v3-qbtns button {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; min-height: 44px; padding: 10px 16px; border-radius: 999px;
  cursor: pointer; transition: transform 0.12s ease, background 0.15s ease;
}
.v3-btn:hover, .v3-qbtns button:hover { background: #262640; }
.v3-btn:active, .v3-qbtns button:active { transform: scale(0.97); }
.v3-btn-small { min-height: 44px; padding: 9px 14px; font-size: 14px; }
.v3-input {
  width: 100%; min-height: 48px; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; outline: none;
}
.v3-input:focus { border-color: var(--accent); }
.v3-form { display: flex; flex-direction: column; gap: 10px; }
.v3-note { color: var(--muted); font-size: 13px; }
.v3-empty { color: var(--muted); text-align: center; padding: 24px 0; }
.v3-msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; background: var(--card); border: 1px solid var(--line); }
.v3-p { margin: 0 0 10px; }
.v3-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.v3-tab-active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.v3-coms, .v3-mail, .v3-phone, .v3-walkie, .v3-pager, .v3-games, .v3-cal, .v3-reminders,
.v3-weather, .v3-briefing, .v3-biz, .v3-apps-hub, .v3-accounts, .v3-c, .v3-vedge, .v3-hedge,
.v3-mail-body, .v3-coms-body, .v3-weather-body, .v3-miniapp-body, .v3-threads, .v3-mail-list,
.v3-event-list, .v3-rem-list, .v3-game-list, .v3-weather-list, .v3-nearby-list, .v3-walkie-log, .v3-qlog {
  display: flex; flex-direction: column; gap: 12px;
}
.v3-app-card, .v3-game-card, .v3-mail-item, .v3-event, .v3-rem, .v3-thread, .v3-wk-entry, .v3-tile,
.v3-boxcell {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.v3-apps-grid, .v3-game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 12px; }
.v3-app-icon, .v3-game-icon { font-size: 28px; }
.v3-app-name, .v3-game-name { font-weight: 700; font-size: 15px; }
.v3-game-desc { color: var(--muted); font-size: 13px; }
.v3-game-score, .v3-score, .v3-tally { font-weight: 700; }
.v3-miniapp-overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column; overflow-y: auto;
}
.v3-miniapp-host { flex: 1; display: flex; flex-direction: column; }
.v3-miniapp-header {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  min-height: calc(54px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: rgba(11, 11, 16, 0.94); border-bottom: 1px solid var(--line);
}
.v3-miniapp-title { font-weight: 700; font-size: 17px; flex: 1; }
.v3-c4-grid, .v3-bs-grid, .v3-dots-grid, .v3-word-board {
  display: grid; gap: 6px; justify-content: center; margin: 12px 0;
}
.v3-c4-grid { grid-template-columns: repeat(7, 40px); }
.v3-bs-grid, .v3-bs-board { grid-template-columns: repeat(6, 40px); }
.v3-dots-grid { grid-template-columns: repeat(4, 44px); }
.v3-c4-cell, .v3-bs-cell, .v3-dot, .v3-boxcell {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; font-weight: 700; cursor: pointer;
}
.v3-dot { width: 44px; height: 44px; border-radius: 50%; }
.v3-bs-hit { background: #ff5c5c !important; color: #fff; }
.v3-bs-miss { background: #2a2a3a !important; color: var(--muted); }
.v3-bs-ship { background: #2f6fed; }
.v3-box-you { border-color: var(--accent-2); }
.v3-box-cpu { border-color: var(--accent); }
.v3-word-row { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.v3-word-row span {
  width: 40px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; font-weight: 700; font-size: 20px; text-transform: uppercase;
}
.v3-q { font-weight: 700; font-size: 17px; }
.v3-qbtns { display: flex; flex-direction: column; gap: 8px; }
.v3-taken { color: var(--muted); }
.v3-p1 { color: var(--accent-2); font-weight: 700; }
.v3-p2 { color: var(--accent); font-weight: 700; }
.v3-mail-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.v3-mail-subj { font-weight: 700; }
.v3-mail-preview { color: var(--muted); font-size: 13px; }
.v3-thread-peer { font-weight: 700; }
.v3-unread {
  display: inline-block; min-width: 20px; text-align: center; font-size: 11px; font-weight: 700;
  color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 6px;
}
.v3-due { color: #ffb020; font-weight: 700; font-size: 13px; }
.v3-ev-date, .v3-ev-title { font-weight: 600; }
.v3-rem-text { flex: 1; }
.v3-call-videos { display: flex; gap: 10px; flex-wrap: wrap; }
.v3-local-vid, .v3-remote-vid {
  width: 100%; max-width: 320px; aspect-ratio: 4 / 3; background: #000;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.v3-incoming-call {
  position: fixed; left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right)); bottom: calc(var(--chrome-bottom) + 16px); z-index: 55;
  background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.v3-call-note { color: var(--muted); font-size: 13px; }
.v3-ptt {
  width: 96px; height: 96px; border-radius: 50%; margin: 12px auto; font-size: 15px; font-weight: 700;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
}
.v3-ptt:active { transform: scale(0.95); }
/* ---- Map: fullscreen between the app bars ---- */
main:has(#tab-map.active) {
  height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom));
  padding-bottom: 0;
}
#tab-map.active { height: 100%; min-height: 0; overflow: hidden; }
#tab-map .map-root {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
}
.v3-map {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: var(--bg-2);
}
.v3-leaflet-map, .v3-map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg-2);
}
.v3-map-top {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: calc(12px + var(--safe-left));
  right: calc(76px + var(--safe-right));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.v3-map-status {
  max-width: min(520px, 100%);
  margin: 0;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(11, 11, 16, 0.9);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  pointer-events: auto;
}
.v3-map-status .v3-map-privacy { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.v3-map-locate { pointer-events: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); }
.v3-map-locate[disabled] { opacity: 0.65; cursor: default; }
.v3-map-sheet {
  position: absolute;
  z-index: 1000;
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  bottom: 44px;
  max-width: 460px;
  max-height: min(44dvh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(11, 11, 16, 0.94);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}
.v3-map-sheet summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.v3-map-sheet summary::-webkit-details-marker { display: none; }
.v3-map-sheet summary::after { content: "＋"; color: var(--muted); font-size: 20px; line-height: 1; }
.v3-map-sheet[open] summary::after { content: "−"; }
.v3-map-sheet-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.v3-map-sheet h3 { margin: 0 0 8px; font-size: 15px; }
.v3-nearby-people, .v3-nearby-places { background: transparent; border: 0; border-radius: 0; padding: 0; }
.v3-nearby-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.v3-nearby-list li {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.045);
  border-radius: 12px;
}
.v3-nearby-person {
  width: 100%;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.v3-map .leaflet-top.leaflet-right { top: 12px; right: calc(12px + var(--safe-right)); }
.v3-map .leaflet-control-zoom { margin: 0; }
.v3-map .leaflet-control-attribution { margin-right: calc(4px + var(--safe-right)); }
.v3-weather-now { font-size: 20px; font-weight: 700; }
.v3-mlt-prompt { font-size: 18px; font-weight: 700; text-align: center; padding: 16px 0; }
.v3-trivia { display: flex; flex-direction: column; gap: 12px; }
.v3-game { display: flex; flex-direction: column; gap: 12px; }

/* ---- People (Track C) ---- */
.people-title { margin: 0; font-size: 20px; }
.people-sub { color: var(--muted); font-size: 14px; margin: 0; }
.people-list { display: flex; flex-direction: column; gap: 10px; }
.people-card {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.people-card:hover { border-color: var(--accent); }
.people-card:active { transform: scale(0.98); }
.people-card-ai { border-color: rgba(124, 92, 255, 0.45); }
.people-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--card-2); flex: none; }
.people-avatar-emoji { display: flex; align-items: center; justify-content: center; font-size: 24px; }
.people-avatar-lg { width: 72px; height: 72px; font-size: 34px; }
.people-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.people-name-row { display: flex; align-items: center; gap: 8px; }
.people-name { font-weight: 700; font-size: 16px; }
.people-ai-badge {
  font-size: 11px; font-weight: 700; line-height: 1; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 3px 6px; border-radius: 999px;
}
.people-handle { color: var(--muted); font-size: 13px; }
.people-role { color: var(--muted); font-size: 13px; }
.people-bio { font-size: 14px; margin: 6px 0 0; }
.people-owner { font-size: 13px; color: var(--muted); }
.people-disclosure { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.people-add-form { display: flex; flex-direction: column; gap: 8px; }
.people-add-input {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
}
.people-add-input:focus { border-color: var(--accent); }
.people-add-btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; min-height: 44px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
}
.people-toast {
  position: fixed; left: 50%; bottom: calc(var(--chrome-bottom) + 18px);
  transform: translateX(-50%); z-index: 60; background: #262640; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px - var(--safe-left) - var(--safe-right)); text-align: center;
}
.people-sheet-backdrop, .share-sheet-backdrop {
  position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.55);
}
.people-sheet, .share-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 24px 24px 0 0; padding: 20px calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  max-width: 560px; margin: 0 auto; max-height: 85dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.people-sheet-head { display: flex; align-items: center; gap: 14px; }
.people-sheet-names { display: flex; flex-direction: column; gap: 2px; }
.people-sheet-name-row { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.people-actions { display: flex; flex-direction: column; gap: 8px; }
.people-action-btn, .people-close-btn, .share-close-btn, .share-recipient-btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; min-height: 48px; padding: 12px 16px; border-radius: 12px;
  cursor: pointer; text-align: left; width: 100%;
}
.people-action-btn:hover, .share-recipient-btn:hover { background: #262640; }
.people-close-btn, .share-close-btn { text-align: center; background: transparent; }
.people-shared { display: flex; flex-direction: column; gap: 8px; }

/* ---- Share (Track C) ---- */
.share-sheet-title { margin: 0; font-size: 18px; }
.share-sheet-preview {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; color: var(--muted); white-space: pre-wrap; word-break: break-word;
}
.share-sheet-note { color: var(--muted); font-size: 13px; margin: 0; }
.share-recipients { display: flex; flex-direction: column; gap: 8px; }
.share-empty { color: var(--muted); text-align: center; padding: 16px 0; }
.share-toast {
  position: fixed; left: 50%; bottom: calc(var(--chrome-bottom) + 18px);
  transform: translateX(-50%); z-index: 60; background: #262640; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px - var(--safe-left) - var(--safe-right)); text-align: center;
}
.shared-title { margin: 0; font-size: 17px; }
.shared-sub { color: var(--muted); font-size: 13px; margin: 0; }
.shared-list { display: flex; flex-direction: column; gap: 10px; }
.shared-row, .shared-row-pending {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.shared-row-pending { border-color: rgba(255, 176, 32, 0.45); }
.shared-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.shared-meta { color: var(--muted); font-size: 12px; }
.shared-note { color: var(--muted); font-size: 13px; margin: 0; }
.shared-empty { color: var(--muted); text-align: center; padding: 16px 0; }
.shared-pending { display: flex; flex-direction: column; gap: 8px; }
.shared-pending-title { font-weight: 700; font-size: 15px; }
.shared-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.shared-approve-btn, .shared-cancel-btn, .shared-retry-btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; min-height: 44px; padding: 10px 14px; border-radius: 999px; cursor: pointer;
}
.shared-approve-btn { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- HomeView (v3.2): 1088x1088 square touch display + short viewports ----
 * Layout / legibility / touch only. No behavior, copy, or color changes.
 * Everything below overrides earlier rules (same specificity, later wins). */

/* 1. Never a horizontal scrollbar; never double-tap zoom on a control.
 * overflow-x: clip (not hidden) so sticky topbar/composer keep working. */
html, body { overflow-x: clip; }
button, a, input, textarea, select { touch-action: manipulation; }
/* No stray text selection from tapping chrome/cards (inputs keep selecting). */
button, .nav-btn, .people-card, .v3-app-card {
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}

/* 2. Glanceable type floor: nothing below 12px (was 11px on badges/labels). */
.ai-badge, .people-ai-badge, .nav-label { font-size: 12px; }
.v3-unread { font-size: 12px; min-width: 22px; padding: 3px 7px; }

/* 3. Touch targets: every interactive control at least 44px on its short side. */
.btn, .v3-btn, .people-add-btn, .people-card, .v3-app-card, .v3-game-card { min-height: 44px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-small, .v3-btn-small, .shared-approve-btn, .shared-cancel-btn, .shared-retry-btn {
  min-height: 44px; padding-top: 10px; padding-bottom: 10px;
}
input[type="text"], textarea, .v3-input, .people-add-input { min-height: 48px; }
/* Text links used as controls (e.g. the HomeView-calling link in Coms/Phone). */
a.v3-note { display: inline-block; padding: 12px 4px; min-height: 44px; }

/* Game boards: 40px cells -> 44px. Connect 4 (7x44+6x6=344) and
 * Battleship (6x44+5x6=294) still fit the 448px test width. */
.v3-c4-grid { grid-template-columns: repeat(7, 44px); }
.v3-bs-grid, .v3-bs-board { grid-template-columns: repeat(6, 44px); }
.v3-c4-cell, .v3-bs-cell, .v3-dot, .v3-boxcell { width: 44px; height: 44px; }
.v3-word-row span { width: 44px; height: 44px; }
/* Dots & Boxes: the board is 9 items per row (5 dots + 4 edges), so the
 * grid needs 9 columns — the old 4-column template scrambled the board
 * into a 4-wide strip (found by the HomeView audit; no spec ever opened
 * this game). Columns shrink below 44px only on viewports too narrow to
 * fit 9x44, so the board never overflows. */
.v3-dots-grid {
  grid-template-columns: repeat(9, minmax(0, 44px));
  width: min(100%, 444px);
  margin: 12px auto;
}
/* Edge buttons had no styling at all (default light button face on dark
 * UI, and they were swept into a flex-column display rule). Give them the
 * same dark cell look; a claimed edge reads as claimed. */
.v3-vedge, .v3-hedge {
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer;
}
.v3-vedge.v3-taken, .v3-hedge.v3-taken { background: var(--card-2); border-color: rgba(255, 255, 255, 0.22); }

/* Leaflet (Map tab): zoom buttons were 30px; attribution was 11px. */
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
  width: 44px !important; height: 44px !important; line-height: 44px !important;
}
.leaflet-control-attribution { font-size: 12px; padding: 4px 8px; }
/* Attribution link: 44px hit area without growing the visible credit bar
 * (padding grows the tap target, negative margins keep the layout box). */
.leaflet-control-attribution a { display: inline-block; padding: 14px 2px; margin: -14px 0; }
/* Map pins open a popup, so they are interactive — but they are 25x41px.
 * Transparent padding grows the tap target to 45x45 without stretching
 * the pin image; the pin tip lands ~10px right / 2px down from the true
 * point, negligible on a rough-area (~2km circle) map. (Selector must
 * beat Leaflet's own `.leaflet-container .leaflet-marker-pane img`
 * padding:0 rule.) */
.leaflet-container .leaflet-marker-pane img.leaflet-marker-icon { box-sizing: content-box; padding: 2px 10px; }

/* 4. Mini-app overlay: pad + constrain like tab-body (content was flush
 * to the viewport edges at 1088px). Incoming-call sheet stays dismissible. */
.v3-miniapp-body { padding: 20px calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left)); max-width: 680px; width: 100%; margin: 0 auto; }
.v3-incoming-call { max-height: 90dvh; overflow-y: auto; }

/* 5. Modals/sheets always dismissible.
 * Welcome: a 382px card in a 364px viewport clipped its top (flex-end
 * with no scroll). Column flex + margin-top:auto keeps it bottom-anchored
 * when it fits and scrollable when it doesn't; the card itself scrolls
 * internally past 90dvh. */
.welcome { overflow-y: auto; flex-direction: column; align-items: center; }
.welcome-card { margin-top: auto; max-height: 90dvh; overflow-y: auto; }
/* People/share sheets: Close sits at the end of the content, so at short
 * heights it was below the fold. Sticky-bottom keeps it on screen while
 * the sheet scrolls under it. */
.people-close-btn, .share-close-btn {
  position: sticky; bottom: 0; z-index: 2; background: var(--card);
}

/* 6. Short viewports (<600px tall): compact the chrome so content keeps
 * room. Topbar 56->48, nav 64->56, tighter composer/padding, shorter map.
 * (1088x1088 HomeView keeps the roomy chrome; this is for the short
 * test viewport and any split/small-height Safari window.) */
@media (max-height: 600px) {
  :root { --topbar-h: 48px; --nav-h: 56px; }
  .brand { font-size: 16px; }
  .page-title { font-size: 14px; }
  .tab-body { padding: 12px calc(12px + var(--safe-right)) 12px calc(12px + var(--safe-left)); gap: 10px; }
  .ai-composer { padding: 8px calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left)); }
  .ai-head { padding-top: 10px; }
  .v3-miniapp-body { padding: 12px calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left)); }
  .nav-icon svg { width: 22px; height: 22px; }
}

/* 7. App chrome must sit above Leaflet. Leaflet panes/controls run at
 * z-index 200-1000 while the topbar/bottomnav were 20, so wherever the
 * map overlaps them the map paints on top: at 448x364 the map covers
 * the bottom nav, the nav buttons are invisible AND unclickable (the
 * audit's tab clicks after Map silently failed), and the same would
 * swallow a toast or incoming-call banner shown over the Map tab.
 * +1000 on every app layer, preserving their relative order. */
.topbar, .bottomnav { z-index: 1001; }
.v3-miniapp-overlay { z-index: 1040; }
.people-sheet-backdrop, .share-sheet-backdrop { z-index: 1045; }
.people-sheet, .share-sheet { z-index: 1046; }
.welcome { z-index: 1050; }
.v3-incoming-call { z-index: 1055; }
.toast, .people-toast, .share-toast { z-index: 1060; }

