/* ==========================================================================
   FamFind — keep your circle close. Refined 2026-07-16.
   Deep navy night sky, one warm teal accent, soft glass panels. Friendly,
   premium, trustworthy — a family product, not a command console.
   ========================================================================== */
:root {
  --bg:        #090F1D;
  --bg-2:      #0F182C;
  --panel:     #131E36;
  --panel-2:   #1A2845;
  --line:      #22345A;
  --line-soft: rgba(148, 178, 215, 0.10);
  --text:      #EAF0FA;
  --muted:     #8FA1BF;
  --dim:       #5D6F8D;
  --accent:    #2DD4BF;
  --accent-dk: #14B8A6;
  --accent-ink:#A9F0E5;
  --danger:    #F0556B;
  --warn:      #F5B14C;
  --good:      #46D39A;
  --radius:    14px;
  --shadow:    0 14px 40px rgba(0, 0, 0, 0.4);
  --mono:      ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans:      "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
::selection { background: rgba(45, 212, 191, 0.3); }
* { scrollbar-width: thin; scrollbar-color: #2a3b5e transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #263759; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible { outline: none; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0;
  border-radius: 11px; padding: 10px 16px; color: var(--text);
  background: var(--panel-2); transition: transform .06s ease, background .15s ease, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, #3BE3CD, var(--accent-dk)); color: #04251F;
  box-shadow: 0 10px 24px -10px rgba(45, 212, 191, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, #3BE3CD, var(--accent-dk)); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--panel-2); border-color: #2e4370; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sos {
  background: linear-gradient(135deg, #FF6B81, #E23D54); color: #fff; font-weight: 800; letter-spacing: .8px;
  box-shadow: 0 10px 26px -10px rgba(240, 85, 107, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: sos-breathe 2.4s ease-in-out infinite;
}
@keyframes sos-breathe {
  0%, 100% { box-shadow: 0 10px 26px -10px rgba(240, 85, 107, 0.65), 0 0 0 0 rgba(240, 85, 107, 0.35); }
  50% { box-shadow: 0 10px 26px -10px rgba(240, 85, 107, 0.65), 0 0 0 7px rgba(240, 85, 107, 0); }
}
@media (prefers-reduced-motion: reduce) { .btn-sos { animation: none; } }
.btn-sos:hover { filter: brightness(1.08); }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  width: 40px; height: 40px; border-radius: 11px; font-size: 18px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--panel-2); border-color: #2e4370; }

/* ── Brand ───────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.brand-mark { color: var(--accent); font-size: 30px; line-height: 1; display: inline-flex; filter: drop-shadow(0 4px 14px rgba(45, 212, 191, 0.45)); }
.brand-mark svg { width: 34px; height: 34px; }
.brand-mark.sm { font-size: 22px; }
.brand-mark.sm svg { width: 24px; height: 24px; }
.brand-name { font-size: 27px; font-weight: 700; letter-spacing: .3px; }
.brand-name b { color: var(--accent); font-weight: 800; }
.brand-tag { text-align: center; color: var(--muted); margin: 6px 0 22px; }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth-screen {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px;
  background:
    radial-gradient(1000px 560px at 80% -12%, rgba(45, 212, 191, 0.16), transparent 60%),
    radial-gradient(760px 520px at -10% 112%, rgba(45, 212, 191, 0.09), transparent 55%),
    radial-gradient(2px 2px at 18% 28%, rgba(234, 240, 250, 0.35) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 72% 16%, rgba(234, 240, 250, 0.28) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 38% 64%, rgba(234, 240, 250, 0.2) 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 52%, rgba(234, 240, 250, 0.24) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 8% 82%, rgba(234, 240, 250, 0.22) 50%, transparent 51%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 384px;
  background: linear-gradient(180deg, #16223D, var(--panel));
  border: 1px solid var(--line); border-top: 2px solid rgba(45, 212, 191, 0.55);
  border-radius: 16px;
  padding: 32px 28px 26px; box-shadow: var(--shadow), 0 0 0 1px rgba(45, 212, 191, 0.04);
}
.tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 12px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  transition: background .15s, color .15s;
}
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  font: inherit; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: #0C1425; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15); }
.auth-form input::placeholder { color: var(--dim); }
.form-hint { color: var(--muted); font-size: 13px; text-align: center; margin: 2px 0 0; }
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; text-align: center; }
.auth-foot { color: var(--dim); font-size: 12px; letter-spacing: .04em; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(9, 15, 29, 0.9); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  gap: 12px; z-index: 600;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.circle-select {
  font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; cursor: pointer; max-width: 46vw;
  transition: border-color .15s;
}
.circle-select:hover, .circle-select:focus { border-color: var(--accent); outline: none; }
.trial-badge {
  font-size: 12px; font-weight: 700; color: var(--warn);
  border: 1px solid rgba(245, 177, 76, 0.5); background: rgba(245, 177, 76, 0.1);
  padding: 4px 10px; border-radius: 20px; white-space: nowrap;
}

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 322px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-nav { display: flex; gap: 6px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); }
.side-tab {
  flex: 1; padding: 11px 8px; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 600; border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0; transition: color .15s, background .15s;
}
.side-tab:hover { color: var(--text); background: rgba(45, 212, 191, 0.05); }
.side-tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); background: rgba(45, 212, 191, 0.07); }
.pane { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; }
.pane-hint { color: var(--muted); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ── Member list ─────────────────────────────────────────────────────────── */
.member-list, .place-list, .activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.member {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  background: linear-gradient(180deg, #101A31, var(--bg-2));
  border: 1px solid var(--line); border-radius: 13px; cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.member:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 10px 24px -14px rgba(45, 212, 191, 0.4); }
.member.is-me { border-left: 3px solid var(--accent); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; color: #04251F; font-size: 15px;
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px rgba(45, 212, 191, 0.35);
}
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.member-body { flex: 1; min-width: 0; }
.member-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.member-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batt { font-variant-numeric: tabular-nums; }
.batt.low { color: var(--danger); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.live { background: var(--good); box-shadow: 0 0 9px var(--good); }
.dot.stale { background: var(--dim); }
.member-actions { display: flex; gap: 4px; flex: none; }
.member-actions button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 14px; line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}
.member-actions button:hover { background: var(--panel-2); color: var(--text); }
.member-actions button.del:hover { color: var(--danger); border-color: var(--danger); }
.role-pill { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--accent-ink); background: rgba(45, 212, 191, 0.1); border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 20px; padding: 1px 7px; margin-left: 4px; }
.cred-box { font-family: var(--mono); background: #0C1425; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; margin: 8px 0; font-size: 13px; word-break: break-all; }
.cred-box b { color: var(--accent); }

/* ── Activity / audit log ──────────────────────────────────────────────────── */
.audit-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.audit-row { padding: 9px 2px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.audit-row:last-child { border-bottom: 0; }
.audit-when { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Places ──────────────────────────────────────────────────────────────── */
.place {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  background: linear-gradient(180deg, #101A31, var(--bg-2));
  border: 1px solid var(--line); border-radius: 13px;
  transition: border-color .15s;
}
.place:hover { border-color: #2e4370; }
.place-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; font-size: 16px; }
.place-body { flex: 1; }
.place-name { font-weight: 600; }
.place-sub { color: var(--muted); font-size: 12px; }
.place .del { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; }
.place .del:hover { color: var(--danger); }
.place .edit { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.place .edit:hover { color: var(--accent); }

/* ── Zones: type picker (add-zone modal) + danger styling ─────────────────── */
.zone-type { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 2px; }
.zt-opt { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 11px; cursor: pointer; font-size: 14px; transition: border-color .15s, background .15s; }
.zt-opt input { accent-color: var(--accent); }
.zt-opt:has(input:checked) { border-color: var(--accent); background: rgba(45, 212, 191, 0.10); }
.zt-danger:has(input:checked) { border-color: #ef4444; background: rgba(239, 68, 68, 0.12); }
#az-radius { width: 100%; accent-color: var(--accent); }
.place-danger { border-color: rgba(239, 68, 68, 0.5); }
.place-danger .place-ico { background: rgba(239, 68, 68, 0.16); }
.zone-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: #ff7b7b; border: 1px solid rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.1); border-radius: 20px; padding: 1px 7px; margin-left: 4px; }
.zone-here { font-size: 10.5px; font-weight: 600; color: var(--accent-ink); background: rgba(45, 212, 191, 0.13);
  border-radius: 20px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.zone-here.danger { color: #ff8f8f; background: rgba(239, 68, 68, 0.16); }

/* iPhone background-location notice (foreground-only sharing) */
.ios-notice { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 560px; z-index: 900; display: flex; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.4; color: var(--text); }
.ios-notice b { color: var(--accent); }
.ios-notice button { flex: none; background: linear-gradient(135deg, #3BE3CD, var(--accent-dk)); color: #04251F; border: 0;
  border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; }

/* ── Activity feed ───────────────────────────────────────────────────────── */
.activity { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.activity .when { color: var(--muted); font-size: 12px; }
.activity .ic { font-size: 16px; }

/* ── Map ─────────────────────────────────────────────────────────────────── */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #dfe6ee; }
.leaflet-container { background: #dfe6ee !important; font-family: var(--sans); }
.map-marker {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--bg);
  display: grid; place-items: center; font-weight: 700; color: #04251F; font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.map-marker.me { box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5); }

.history-bar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 18px;
  background: rgba(19, 30, 54, 0.96); border: 1px solid var(--line); border-radius: 13px;
  backdrop-filter: blur(8px);
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; z-index: 500;
  box-shadow: var(--shadow); width: min(560px, 92%);
}
.history-bar input[type=range] { flex: 1; accent-color: var(--accent); }
#history-label { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Toast / SOS banner ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 2000; font-weight: 600;
}
.sos-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: linear-gradient(90deg, #E23D54, var(--danger)); color: #fff;
  padding: 14px 18px; text-align: center; font-weight: 700; z-index: 2200; cursor: pointer;
  box-shadow: 0 6px 26px rgba(240, 85, 107, 0.55);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(3, 7, 15, 0.75); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 1500; padding: 20px;
}
.modal {
  width: 100%; max-width: 424px;
  background: linear-gradient(180deg, #16223D, var(--panel));
  border: 1px solid var(--line); border-top: 2px solid rgba(45, 212, 191, 0.5);
  border-radius: 16px; padding: 24px; position: relative; box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; background: transparent; border: 0;
  color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; border-radius: 8px; padding: 0 6px;
}
.modal-close:hover { color: var(--text); background: var(--panel-2); }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal p.sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 13px 0 6px; }
.modal input, .modal select {
  width: 100%; font: inherit; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--line); background: #0C1425; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15); }
.invite-code {
  font-family: var(--mono); font-size: 27px; font-weight: 700; letter-spacing: 4px;
  color: var(--accent); text-align: center; background: #0C1425;
  border: 1px dashed rgba(45, 212, 191, 0.6); border-radius: 13px; padding: 16px; margin: 8px 0 4px;
  text-shadow: 0 0 22px rgba(45, 212, 191, 0.4);
}
.coords { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: .5px; margin: 4px 0; }
.detail-h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 18px 0 6px; font-weight: 700; }
.ice-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.ice-row > span { color: var(--muted); min-width: 128px; flex: none; }
.plan-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.plan-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: #0C1425; border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s;
}
.plan-row .price { font-weight: 800; color: var(--accent); }
.plan-row.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ── Responsive (phones / iOS PWA) ───────────────────────────────────────── */
@media (max-width: 820px) {
  .layout { flex-direction: column-reverse; }
  .sidebar { width: 100%; height: 42vh; border-right: 0; border-top: 1px solid var(--line); }
  .map-wrap { height: 58vh; flex: none; }

  /* Top bar must never overflow: the left (circle picker) shrinks; the action
     buttons on the right stay pinned + fully tappable. */
  .topbar { padding: 8px 10px; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar-left { flex: 1 1 auto; min-width: 0; }
  .topbar-right { flex: 0 0 auto; gap: 6px; }
  .brand-mark.sm { display: none; }
  .circle-select { max-width: none; min-width: 0; flex: 1 1 auto; }
  #trial-badge { display: none; }        /* freed for SOS + menu; still in the ≡ menu */
  #btn-checkin { padding: 9px 11px; white-space: nowrap; }
  .btn-sos { padding: 9px 13px; }
}
