:root {
  --bg: #0a0a0a;
  --bg-raise: #161616;
  --pill: #222222;
  --pill-active: #2e2e2e;
  --lav: #ffffff;
  --lav-dim: #6e6e6e;
  --text: #f3f3f3;
  --muted: #8a8a8a;
  --line: #2a2a2a;
  --danger: #e57373;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* stop iOS Safari from auto-inflating text in wide blocks (e.g. the update
   banner rendered with a huge font on some iPhones) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  overflow: hidden;
}
#app { display: flex; height: 100vh; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 300px; min-width: 300px;
  padding: 28px 22px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
#sidebar h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
#sidebar .sub { color: var(--muted); font-size: 13px; margin: 8px 0 18px; }

.searchbox { position: relative; }
#search {
  width: 100%; padding: 10px 12px; padding-right: 44px;
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 14px; line-height: 1.4; outline: none;
  /* grows with dictated text (auto-sized in JS), scrolls past a cap */
  display: block; resize: none; overflow-y: auto; max-height: 40vh;
}
#search:focus { border-color: var(--lav-dim); }
/* mic / clear both anchor to the bottom-right so they stay put as the
   textarea grows; only one is shown at a time */
#mic, #clear {
  position: absolute; right: 4px; bottom: 4px;
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: 50%;
  color: #ffffff; cursor: pointer;
}
#clear { color: var(--muted); }
#clear:hover { color: var(--text); }
#search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  margin-right: -6px;
  cursor: pointer;
  background-color: #ffffff;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6L18 18M18 6L6 18' stroke='black' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6L18 18M18 6L6 18' stroke='black' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}
#mic:hover { background: var(--pill); }
#mic.rec { background: var(--danger); animation: mic-pulse 1.1s ease-in-out infinite; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 80, 80, .45); }
  50% { box-shadow: 0 0 0 8px rgba(255, 80, 80, 0); }
}
.update {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: #ffffff; color: #111111; font-weight: 600; font-size: 14px;
  border: none; border-radius: 0 0 14px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  animation: update-in .35s cubic-bezier(.32, .72, .33, 1);
}
@keyframes update-in {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* error/info toast — replaces alert(), which is a silent no-op in an iOS
   home-screen PWA (no browser chrome to host the native dialog) */
.toast {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  font-weight: 600; font-size: 14px; text-align: center;
  border: none; border-radius: 0 0 14px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  animation: update-in .35s cubic-bezier(.32, .72, .33, 1);
  cursor: pointer;
}
.toast.error { background: var(--danger); color: #2a0a0a; }
.toast.info { background: #ffffff; color: #111111; }

/* saving state: pulse the button so a slow request never looks like nothing
   is happening */
@keyframes btn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
button.saving { animation: btn-pulse .9s ease-in-out infinite; pointer-events: none; }

.ai-summary {
  padding: 8px 8px 10px; font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.results .r-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.results .r-body .r-name { flex: none; font-size: 16.8px; }
.results .r-reason {
  font-size: 13.8px; color: var(--muted);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* round icon buttons in the bottom-left row */
#add-btn, #names-btn {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--bg-raise); color: var(--text); border: 1px solid var(--line);
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  transition: transform .15s;
}
#add-btn { left: 68px; }
#names-btn { left: 184px; }
/* hide the hide-surnames (eye) button — functionality kept, button hidden */
#names-btn { display: none; }
#add-btn:active, #names-btn:active { transform: scale(0.94); }
/* logout: small bare icon in the top-right corner (no background/rounding) */
#logout-btn {
  position: fixed; top: calc(13px + env(safe-area-inset-top)); right: 14px; z-index: 15;
  width: auto; height: auto; padding: 6px; border: none; border-radius: 0;
  background: none; box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
}
#logout-btn:active { transform: scale(0.9); }
/* admin: round style, only visible for the super-admin */
#admin-btn {
  position: fixed; left: 126px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--bg-raise); color: var(--lav); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  transition: transform .15s;
}
#admin-btn:active { transform: scale(0.94); }
/* admin user list */
.adm-list { display: flex; flex-direction: column; margin-top: 6px; }
.adm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.adm-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.adm-email { font-size: 14px; color: var(--text); word-break: break-all; }
.adm-tag {
  font-size: 10px; font-weight: 700; color: var(--lav);
  border: 1px solid var(--lav-dim); border-radius: 6px; padding: 0 4px; margin-left: 4px;
}
.adm-meta { font-size: 12px; color: var(--muted); }
.adm-plan { display: flex; gap: 0; flex: none; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.adm-plan button {
  background: none; border: none; border-radius: 0; padding: 7px 12px;
  color: var(--muted); font-size: 13px;
}
.adm-plan button.on { background: var(--lav); color: #14121c; font-weight: 700; }
.adm-plan button:disabled { opacity: .5; }
/* the icon itself signals the state: open eye = surnames shown, closed = hidden */
#names-btn .eye-closed, #names-btn.on .eye-open { display: none; }
#names-btn.on .eye-closed { display: block; }
button {
  font: inherit; cursor: pointer;
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px;
}
button:hover { border-color: var(--lav-dim); }
button.primary { background: #ffffff; border-color: #ffffff; color: #111111; font-weight: 600; }
button.primary:hover { filter: brightness(0.88); }
button.danger { color: var(--danger); }
button.linklike { background: none; border: none; padding: 0; color: var(--lav-dim); font-size: 12px; }
button.linklike:hover { color: var(--lav); }

.results { margin-top: 14px; }
.results .r-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.results .r-item:hover { background: var(--bg-raise); }
.results .r-ava {
  width: 31px; height: 31px; border-radius: 50%;
  background: var(--pill) center/cover;
  flex: none;
}
.results .r-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-score { color: var(--lav-dim); font-size: 11px; }

/* ---------- stage ---------- */
#stage { flex: 1; position: relative; }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* floating add button (mobile) */
#fab {
  display: none;
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 48px; height: 48px; border-radius: 50%;
  align-items: center; justify-content: center; padding: 0;
  /* light (off-white) button with a black plus */
  background: #e9e9ea; color: #111111; border: none;
  font-size: 26px; line-height: 1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
#fab:active { transform: scale(0.94); }
/* ---------- avatar cropper ---------- */
#crop-stage {
  position: relative; width: 100%; max-width: 320px; aspect-ratio: 1;
  margin: 4px auto 14px; border-radius: 12px; overflow: hidden;
  background: #000; touch-action: none;
}
#crop-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#crop-frame {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5);
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85);
}
#crop-zoom { width: 100%; max-width: 320px; display: block; margin: 0 auto 6px; }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--muted); text-align: center; pointer-events: none;
}
.empty .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--lav); opacity: .7; }

/* ---------- detail panel ---------- */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px;
  background: var(--bg-raise); border-left: 1px solid var(--line);
  padding: 56px 24px 28px; overflow-y: auto; z-index: 20;
  transform: translateX(105%);
  transition: transform .32s cubic-bezier(.32, .72, .33, 1);
  touch-action: pan-y; /* allow vertical scroll, block pinch-zoom of the card */
}
.detail.open { transform: translate(0, 0); }
.detail .close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--muted); font-size: 22px; padding: 4px 8px;
}
.d-photo {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--pill) center/cover;
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--lav); font-size: 34px; font-weight: 600;
  border: none; padding: 0; cursor: pointer; font-family: inherit;
  transition: filter .15s;
}
.d-photo:hover { filter: brightness(1.15); }
.d-photo:active { filter: brightness(0.9); }
.detail h2 { font-size: 19px; margin-bottom: 14px; }
.d-block { margin-bottom: 16px; }
.d-block h3 {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: 5px;
}
.d-block p { white-space: pre-wrap; }
#d-reach a {
  display: block; color: var(--lav); text-decoration: none; margin-bottom: 4px;
  font-size: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#d-reach a:hover { text-decoration: underline; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.d-tag {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--pill); color: var(--text); font-size: 13px;
}
.d-tag.empty { background: none; color: var(--lav-dim); padding-left: 0; font-style: italic; }
#d-gentag { display: inline-block; }
.d-actions { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(5, 4, 8, .7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  position: relative;
  width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px;
}
.modal-card .close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--muted); font-size: 24px; padding: 4px 10px;
}

/* wizard steps: one field at a time */
#steps .step { display: none; }
#steps .step.active { display: block; }
.dots { display: flex; gap: 7px; justify-content: center; margin: 6px 0 16px; }
.dots .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pill-active); }
.dots .dot.on { background: var(--lav); }
input.invalid, textarea.invalid { border-color: var(--danger) !important; }

/* summary step */
.sum-hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.sum-row {
  display: flex; gap: 12px; align-items: baseline;
  padding: 13px 10px; cursor: pointer;
  border-bottom: 1px solid var(--line); border-radius: 8px;
}
.sum-row:hover { background: var(--bg); }
.sum-label { color: var(--muted); font-size: 13px; width: 80px; flex: none; }
.sum-val { flex: 1; white-space: pre-wrap; word-break: break-word; }
.sum-val.empty { color: var(--lav-dim); font-style: italic; }
.modal-card.narrow { width: 320px; }
.modal-card h2 { font-size: 17px; margin-bottom: 16px; }
/* the add/edit contact title, 1.5x larger */
#m-title { font-size: 25px; }
.modal-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.modal-card .hint { font-size: 11px; color: var(--lav-dim); }
.modal-card input, .modal-card textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; outline: none; resize: vertical;
}
.modal-card input:focus, .modal-card textarea:focus { border-color: var(--lav-dim); }
/* Autofill must never flash the native white/blue fill: the browser paints it
   over `background`, so we paint back with a huge inset shadow instead. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  border-color: var(--line);
  transition: background-color 9999999s ease-out; /* stalls the fill animation */
}
/* the person's name is the headline field: ~20% larger and centered */
.modal-card input[name="name"] { font-size: 17px; text-align: center; caret-color: transparent; }
.modal-card input[type=file] { border: none; padding-left: 0; background: none; }
.row2 { display: flex; gap: 10px; }
.row2 label { flex: 1; }
.m-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.err { color: var(--danger); font-size: 13px; margin-bottom: 8px; }

/* ---------- login screen: solid black, edge to edge ---------- */
#login {
  background: #000000;
  backdrop-filter: none;
  inset: 0; top: 0; left: 0; right: 0; bottom: 0; height: auto;
  align-items: center; justify-content: center;
}
#login .modal-card {
  width: 100%; max-width: 340px; height: auto; max-height: none;
  background: transparent; border: none; border-radius: 0; box-shadow: none;
  padding: 24px; display: block;
}
/* brand title: silver gradient over a classic serif, with a slow sheen
   sweeping across the letters (metallic, not flat white) */
#login .brand, #pwa-tutorial .brand {
  font-family: ui-serif, "New York", Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: 500;
  letter-spacing: -1px;
  text-align: center;
  margin-bottom: 16px;
  background: linear-gradient(
    105deg,
    #eceef2 0%, #9a9aa3 30%, #ffffff 48%, #8f8f98 66%, #e8e9ee 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-sheen 5.5s ease-in-out infinite;
}
/* tagline under the brand: quiet, small, centered */
#login .brand-sub {
  max-width: 300px;
  margin: 0 auto 28px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
@keyframes brand-sheen {
  0%, 100% { background-position: 100% 0; }
  50% { background-position: 0% 0; }
}

/* soft halo behind the inputs — the login screen is solid black, so the
   fields "float" in a faint lavender-white glow */
#login .modal-card input {
  box-shadow:
    0 0 18px rgba(203, 190, 255, .10),
    0 0 70px 6px rgba(203, 190, 255, .13);
  transition: box-shadow .35s ease, border-color .35s ease;
}
#login .modal-card input:focus {
  box-shadow:
    0 0 22px rgba(203, 190, 255, .18),
    0 0 90px 10px rgba(203, 190, 255, .22);
}
/* autofilled login fields keep the dark fill AND the outer glow */
#login .modal-card input:-webkit-autofill,
#login .modal-card input:-webkit-autofill:hover,
#login .modal-card input:-webkit-autofill:focus {
  -webkit-box-shadow:
    0 0 0 1000px var(--bg) inset,
    0 0 22px rgba(203, 190, 255, .18),
    0 0 90px 10px rgba(203, 190, 255, .22);
}
/* one-time code entry: big, centered, spaced like the email it came from */
#login .code-input {
  font-size: 22px; text-align: center; letter-spacing: 8px;
  caret-color: transparent; /* the dots are the affordance, a blinking caret just adds noise */
}
#login .resend { display: block; margin: 14px auto 0; font-size: 13px; }
#login .resend:disabled { color: var(--muted); cursor: default; }
/* "получить код": a compact rounded white button, centered (not full-width) */
#login .send-row { text-align: center; margin-top: 20px; }
#login .send-code {
  display: inline-block;
  background: #ffffff; color: #111111; border: none; border-radius: 12px;
  padding: 11px 30px; font-size: 15px; font-weight: 600;
}
#login .send-code:hover { filter: brightness(0.9); }
#login .send-code:disabled { opacity: .55; cursor: default; }

/* small serif wordmark in the top-left once inside the app (same look as the
   login title, but static) */
.brand-mini {
  font-family: ui-serif, "New York", Georgia, "Times New Roman", serif;
  font-size: 32px; letter-spacing: -.6px; line-height: 1;
  margin: 0 0 14px; text-align: center;
  background: linear-gradient(105deg, #eceef2, #9a9aa3 42%, #ffffff 56%, #b6b6bf);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- add-to-home-screen tutorial ---------- */
#pwa-tutorial {
  background: #000000; backdrop-filter: none;
  align-items: center; justify-content: center;
}
#pwa-tutorial .brand { font-size: 32px; margin-bottom: 6px; }
.pwa-card {
  width: 100%; max-width: 380px;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center; overflow-y: auto; max-height: 100%;
}
/* keep the heading to a single line */
.pwa-title { font-size: 16px; margin: 6px 0 10px; color: var(--text); white-space: nowrap; }
.pwa-lead { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin-bottom: 26px; }
.pwa-steps { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.pwa-step { display: flex; align-items: center; gap: 12px; }
.pwa-num {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--lav); color: #14121c; font-size: 12px; font-weight: 700;
}
.pwa-ico {
  flex: none; width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raise); border: 1px solid var(--line); color: var(--text);
}
.pwa-txt { font-size: 14px; line-height: 1.4; color: var(--text); }
.pwa-word { color: var(--lav); font-weight: 600; }
.pwa-done { width: 100%; padding: 13px; }

/* ---------- upgrade-to-Pro dialog ---------- */
.up-card { text-align: center; }
.up-badge {
  display: inline-block; margin-bottom: 12px;
  padding: 3px 12px; border-radius: 999px;
  background: linear-gradient(105deg, #cbb8ff, #8f7bff);
  color: #14121c; font-size: 12px; font-weight: 800; letter-spacing: 1px;
}
.up-title { font-size: 18px; margin-bottom: 10px; }
.up-lead { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin-bottom: 16px; }
.up-perks {
  list-style: none; text-align: left; display: flex; flex-direction: column; gap: 8px;
  margin: 0 auto 20px; max-width: 240px;
}
.up-perks li { position: relative; padding-left: 24px; font-size: 14px; color: var(--text); }
.up-perks li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--lav); font-weight: 700;
}
.up-go { width: 100%; padding: 13px; margin-bottom: 8px; }
.up-later { display: block; margin: 0 auto; }

.hidden { display: none !important; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  #app { flex-direction: column; }

  /* sidebar becomes a frosted-glass top bar floating over the graph, so
     avatars passing beneath it faintly show through (iOS-style liquid glass) */
  #sidebar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 10;
    width: 100%; min-width: 0;
    /* top inset keeps the search below the iPhone status bar / notch in standalone PWA mode */
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-right: none; border-bottom: 1px solid rgba(255, 255, 255, .07);
    overflow: visible;
    background: rgba(10, 10, 10, .5);
    -webkit-backdrop-filter: blur(24px) saturate(1.7);
    backdrop-filter: blur(24px) saturate(1.7);
  }
  #sidebar h1, #sidebar .sub, #add-btn { display: none; }
  /* mobile has no side column — keep the row in the bottom-left corner */
  #admin-btn { left: 18px; }
  /* translucent so the frosted bar (and the graph behind it) shows through */
  #search {
    padding: 12px 14px; font-size: 16px;
    background: rgba(24, 24, 24, .55); border-color: rgba(255, 255, 255, .09);
  }
  .results { max-height: 40vh; overflow-y: auto; }

  #fab { display: flex; }

  /* detail panel drops down from the top like a popup */
  .detail {
    bottom: auto; left: 0; width: 100%; max-height: 90vh;
    border-left: none; border-bottom: 1px solid var(--line);
    border-radius: 0 0 18px 18px;
    padding: calc(36px + env(safe-area-inset-top)) 18px 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    transform: translateY(-105%);
  }
  .detail .close { top: calc(14px + env(safe-area-inset-top)); }
  .d-photo { width: 76px; height: 76px; font-size: 28px; }
  .d-actions button { flex: 1; padding: 13px 14px; }

  /* add / edit form drops down from the top like the detail popup */
  .modal { align-items: flex-start; justify-content: center; }
  .modal-card {
    width: 100%; max-width: 100%; height: auto; max-height: 88vh;
    border: none; border-radius: 0 0 18px 18px;
    padding: calc(18px + env(safe-area-inset-top)) 18px 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    transform: translateY(-105%);
    transition: transform .32s cubic-bezier(.32, .72, .33, 1);
    display: flex; flex-direction: column; overflow-y: auto;
  }
  .modal.open .modal-card { transform: translateY(0); }
  .modal-card .close { top: calc(10px + env(safe-area-inset-top)); }
  .modal-card form { display: flex; flex-direction: column; }
  /* 16px inputs stop iOS from auto-zooming on focus */
  .modal-card input, .modal-card textarea { font-size: 16px; padding: 12px; }
  .modal-card label { font-size: 14px; margin-bottom: 14px; }
  /* the person's name is the headline field: bigger and centered */
  .modal-card input[name="name"] { font-size: 19px; text-align: center; }
  .m-actions { gap: 12px; margin-top: 10px; }
  .m-actions button { flex: 1; padding: 13px 14px; }

  /* the login overlay is a centered full-screen sheet, NOT a slide-down
     top-sheet like #modal — cancel the transform so its card stays centered
     (otherwise the Sonar title is pushed off the top of the screen) */
  #login .modal-card {
    transform: none; max-height: 100%;
    padding: 24px; border-radius: 0;
  }
  /* mini wordmark sits just under the status bar on mobile */
  .brand-mini { font-size: 28px; margin-bottom: 12px; }
}
