/* Contacts — full dark theme. Background is always dark. */
:root{
  --bg:#0a0d13; --card:#131926; --card2:#182032;
  --ink:#eef1f6; --muted:#8b94a7;
  --line:#232c3f; --accent:#f0b429; --accent-ink:#1a1405;
  --chip:#182032; --chip-active:#f0b429; --chip-active-ink:#1a1405;
  --radius:16px; --shadow:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);
  --sheet-shadow:0 -12px 48px rgba(0,0,0,.6);
  --danger:#ff7a7a;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased; padding-bottom:48px;
}

/* ---------- gate ---------- */
.gate{min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:24px}
.gate[hidden]{display:none!important}
.gate-card{width:100%; max-width:360px; text-align:center; background:var(--card);
  border:1px solid var(--line); border-radius:20px; padding:36px 28px; box-shadow:var(--shadow)}
.gate-mark{color:var(--accent); font-size:34px; margin-bottom:6px}
.gate-title{font-size:26px; margin:0 0 6px; letter-spacing:-.02em}
.gate-hint{color:var(--muted); font-size:14px; margin:0 0 18px}
.gate-input{
  width:100%; border:1px solid var(--line); border-radius:12px; padding:13px 16px;
  font-size:17px; background:var(--bg); color:var(--ink); margin-bottom:12px; outline:none;
}
.gate-input:focus{border-color:var(--accent)}
.gate-btn{width:100%; padding:13px; font-size:16px}
.gate-err{color:var(--danger); font-size:14px; min-height:20px; margin:10px 0 0}
.gate-note{color:var(--muted); font-size:14px; line-height:1.6; margin:14px 0 0}
.gate-note a{color:var(--accent)}

/* ---------- app chrome ---------- */
.topbar{
  position:sticky; top:0; z-index:20; background:rgba(10,13,19,.92);
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px; border-bottom:1px solid var(--line);
}
.brand{display:flex; align-items:baseline; gap:8px}
.brand-mark{color:var(--accent); font-size:20px}
.brand-name{font-size:22px; font-weight:700; letter-spacing:-.02em}
.brand-sub{color:var(--muted); font-size:13px}
.top-actions{display:flex; gap:8px}
.btn{
  border:1px solid var(--line); background:var(--card2); color:var(--ink);
  border-radius:999px; padding:9px 16px; font-size:14px; font-weight:600; cursor:pointer;
}
.btn.primary{background:var(--accent); border-color:var(--accent); color:var(--accent-ink)}
.btn.ghost{background:transparent}
.btn:active{transform:scale(.97)}
.btn.danger{color:var(--danger); border-color:#5a2b2b}
.linklike{background:none;border:none;color:var(--accent);font:inherit;font-weight:600;cursor:pointer;padding:0}

.searchwrap{
  position:sticky; top:61px; z-index:15; margin:0; padding:12px 18px 6px;
  background:linear-gradient(var(--bg) 78%, transparent);
  display:flex; align-items:center;
}
.search-icon{position:absolute; left:34px; color:var(--muted); font-size:18px; pointer-events:none}
#search{
  width:100%; border:1px solid var(--line); background:var(--card);
  border-radius:999px; padding:13px 44px 13px 46px; font-size:16px; color:var(--ink);
  outline:none; box-shadow:var(--shadow);
}
#search::placeholder{color:var(--muted)}
#search:focus{border-color:var(--accent)}
.search-clear{
  position:absolute; right:30px; border:none; background:var(--chip);
  width:26px; height:26px; border-radius:50%; color:var(--muted);
  font-size:13px; cursor:pointer;
}

.chips{
  display:flex; gap:8px; overflow-x:auto; padding:10px 18px 4px;
  scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
.chips::-webkit-scrollbar{display:none}
.chip{
  flex:0 0 auto; border:1px solid var(--line); background:var(--chip);
  border-radius:999px; padding:8px 15px; font-size:14px; font-weight:600;
  color:var(--ink); cursor:pointer; white-space:nowrap;
}
.chip .n{color:var(--muted); font-weight:400; margin-left:5px; font-size:12px}
.chip.active{background:var(--chip-active); color:var(--chip-active-ink); border-color:var(--chip-active)}
.chip.active .n{color:inherit; opacity:.7}
.tags-row{padding-top:2px}
.tagchip{font-size:12.5px; padding:6px 12px}
.tagchip.active{background:#e8ecf4; border-color:#e8ecf4; color:#101623}

.grid{
  display:grid; gap:12px; padding:14px 18px;
  grid-template-columns:repeat(auto-fill,minmax(300px,1fr));
  max-width:1100px; margin:0 auto;
}
.card{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; display:flex; gap:13px; align-items:center; cursor:pointer;
  box-shadow:var(--shadow); text-align:left; width:100%; font:inherit; color:inherit;
}
.card:active{transform:scale(.985)}
.avatar{
  width:56px; height:56px; border-radius:50%; flex:0 0 auto; object-fit:cover;
  background:linear-gradient(135deg,#2a3348,#171e2d); display:block;
}
.avatar-fallback{
  width:56px; height:56px; border-radius:50%; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:20px; color:#0a0d13;
  background:linear-gradient(135deg,var(--accent),#b57e14);
}
.card-main{min-width:0; flex:1}
.card-name{font-weight:700; font-size:17px; letter-spacing:-.01em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.card-sub{color:var(--muted); font-size:13.5px; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.card-tags{display:flex; gap:6px; margin-top:7px; flex-wrap:wrap; align-items:center}
.badge{
  font-size:11.5px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
  padding:3px 9px; border-radius:999px; background:var(--chip); color:var(--muted);
}
.badge.family{background:rgba(125,227,141,.14); color:#7de38d}
.badge.friends{background:rgba(178,132,255,.14); color:#b284ff}
.badge.tesla{background:rgba(255,122,122,.14); color:#ff7a7a}
.badge.business{background:rgba(90,162,255,.14); color:#5aa2ff}
.badge.personal{background:rgba(240,180,41,.14); color:#f0b429}
.badge.imported{background:rgba(139,148,167,.16); color:#9aa3b5}
.badge.uncategorized{background:transparent; border:1px dashed var(--line); color:var(--muted)}
.star{color:var(--accent); font-size:14px}
.tag{font-size:12px; color:var(--muted); background:var(--bg); border:1px solid var(--line); padding:2px 8px; border-radius:999px; cursor:pointer}
.tag.active{background:var(--accent); border-color:var(--accent); color:var(--accent-ink)}
.card-chev{color:var(--muted); font-size:20px; flex:0 0 auto}

.empty{text-align:center; color:var(--muted); padding:60px 20px; font-size:16px}

/* bottom sheet */
.sheet-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:40;
  opacity:0; transition:opacity .22s ease;
}
.sheet-backdrop.show{opacity:1}
.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:41; background:var(--card);
  border-radius:22px 22px 0 0; box-shadow:var(--sheet-shadow);
  max-height:92dvh; overflow-y:auto; -webkit-overflow-scrolling:touch;
  transform:translateY(102%); transition:transform .28s cubic-bezier(.32,.72,.28,1);
  padding:10px 22px calc(28px + env(safe-area-inset-bottom));
  border-top:1px solid var(--line);
}
.sheet.show{transform:translateY(0)}
.sheet-grab{width:44px; height:5px; border-radius:99px; background:var(--line); margin:6px auto 14px}
.sheet-head{display:flex; gap:16px; align-items:center; margin-bottom:6px}
.sheet-head .avatar,.sheet-head .avatar-fallback{width:76px; height:76px; font-size:28px}
.sheet-name{font-size:24px; font-weight:700; letter-spacing:-.02em}
.sheet-sub{color:var(--muted); margin-top:3px; font-size:14.5px}
.sheet-actions{display:flex; gap:10px; margin:16px 0 4px}
.sheet-actions .btn{flex:1; padding:12px}
.kv{border-top:1px solid var(--line); margin-top:14px}
.kv-row{display:flex; gap:12px; padding:12px 2px; border-bottom:1px solid var(--line); align-items:baseline}
.kv-label{flex:0 0 108px; color:var(--muted); font-size:13px; font-weight:600; text-transform:uppercase; letter-spacing:.05em}
.kv-val{flex:1; font-size:16px; min-width:0; overflow-wrap:anywhere}
.kv-val a{color:var(--accent); text-decoration:none}
.kv-multi{display:flex; flex-direction:column; gap:6px}
.kv-multi .lbl{font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.05em}
.sheet-close{position:absolute; top:14px; right:18px; border:none; background:var(--chip); width:34px; height:34px; border-radius:50%; font-size:16px; color:var(--muted); cursor:pointer}

/* forms */
.form-grid{display:flex; flex-direction:column; gap:14px; margin-top:8px}
.f-row label{display:block; font-size:12.5px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; margin-bottom:6px}
.f-row input,.f-row textarea,.f-row select{
  width:100%; border:1px solid var(--line); border-radius:12px; padding:12px 14px;
  font-size:16px; font-family:inherit; background:var(--bg); color:var(--ink);
}
.f-row textarea{min-height:76px; resize:vertical}
.f-list-item{display:flex; gap:8px; margin-bottom:8px}
.f-list-item select{flex:0 0 108px}
.f-add{margin-top:2px}
.photo-row{display:flex; gap:14px; align-items:center}
.photo-preview{width:76px; height:76px; border-radius:50%; object-fit:cover; background:linear-gradient(135deg,#2a3348,#171e2d)}
.photo-btns{display:flex; flex-direction:column; gap:8px}
.toggle-list{display:flex; flex-direction:column}
.toggle-row{
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 2px; border-bottom:1px solid var(--line); font-size:16px; font-weight:600;
}
.toggle-row small{display:block; font-weight:400; color:var(--muted); font-size:13px}
.switch{position:relative; width:52px; height:31px; flex:0 0 auto}
.switch input{opacity:0; width:100%; height:100%; position:absolute; margin:0; cursor:pointer}
.knob{
  position:absolute; inset:0; background:#2a3348; border-radius:99px; transition:.2s; pointer-events:none;
}
.knob::after{
  content:""; position:absolute; width:25px; height:25px; border-radius:50%;
  background:#eef1f6; top:3px; left:3px; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.5);
}
.switch input:checked + .knob{background:var(--accent)}
.switch input:checked + .knob::after{transform:translateX(21px); background:#1a1405}
.sheet-title{font-size:20px; font-weight:700; margin:8px 0 4px; letter-spacing:-.01em}
.sheet-note{color:var(--muted); font-size:14px; margin:0 0 6px; line-height:1.5}
.hl{background:rgba(240,180,41,.35); border-radius:3px; padding:0 1px}
@media (min-width:720px){
  .sheet{left:50%; right:auto; width:520px; transform:translate(-50%,102%); border-radius:22px; bottom:5dvh; max-height:86dvh}
  .sheet.show{transform:translate(-50%,0)}
}

.gate-sub2{display:block;margin-top:8px;font-size:.78rem;color:var(--dim);line-height:1.45}

/* ---------- base nav package (matches lathom.com home) ---------- */
header.home-chrome{position:sticky;top:0;z-index:60;background:rgba(10,14,20,.96);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.home-chrome-inner{max-width:760px;margin:0 auto;padding:4px 12px 3px;display:flex;align-items:flex-start;gap:.4rem}
.home-chrome .nav-group{display:flex;gap:.45rem;align-items:flex-start}
a.nav-pill-icon{flex:0 0 52px;width:52px;display:flex;flex-direction:column;align-items:center;text-decoration:none;padding:0;margin:0;background:transparent;border:0}
.nav-ico{display:block;width:52px;height:52px;overflow:hidden;border-radius:12px;border:1px solid #9aa6b8;background:#0a1018;line-height:0}
.nav-ico img{width:52px;height:52px;display:block;object-fit:cover}
.nav-ico svg{width:52px;height:52px;stroke:#5ee7ff;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
a.nav-pill-icon.on .nav-ico{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.nav-word{display:block;width:52px;margin:2px 0 0;font-size:11px;font-weight:600;color:var(--ink);line-height:1.15;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav-spacer{flex:1 1 auto;align-self:stretch}
.chrome-marks{flex:0 0 auto;display:flex;align-items:flex-start}

/* no-name toggle in the title bar */
.noname-toggle{display:inline-flex;align-items:center;gap:.35rem;font-size:.78rem;font-weight:600;
  color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:.42rem .7rem;cursor:pointer;white-space:nowrap}
.noname-toggle input{accent-color:var(--accent);width:15px;height:15px;margin:0;cursor:pointer}
.noname-toggle:has(input:checked){color:var(--ink);border-color:var(--accent)}

/* contacts nav: action buttons match the link pills; search lives in a toggle drawer */
button.nav-pill-icon{flex:0 0 52px;width:52px;display:flex;flex-direction:column;align-items:center;background:transparent;border:0;padding:0;margin:0;cursor:pointer;font:inherit;color:inherit}
.search-drawer{max-width:760px;margin:0 auto;padding:8px 12px 10px;border-top:1px solid var(--line)}
.search-drawer[hidden]{display:none}
.drawer-tools{display:flex;align-items:center;gap:.6rem;margin-top:8px}
.drawer-tools .noname-toggle{font-size:12px;color:var(--ink-dim)}
