:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #fbfaf8; --sunken: #efede9;
  --ink: #1b1d22; --ink-2: #3d414a; --muted: #6f737c; --faint: #9a9da4;
  --line: #e7e4de; --line-2: #d9d5cd;
  --accent: #9b1b3f; --accent-ink: #ffffff; --accent-soft: #f7e6eb; --accent-2: #7d1532;
  --teal: #0f6e66; --teal-soft: #e1f2ef;
  --indigo: #3b3f9e; --indigo-soft: #e8e9f8;
  --amber: #8a5a00; --amber-soft: #fcefd2;
  --green: #1e6b31; --green-soft: #dcf1e0;
  --red: #b42318; --red-soft: #fde8e6;
  --tierA: #9b1b3f; --tierB: #c2410c; --tierC: #6b7280;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, .06);
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 20px rgba(20, 20, 30, .06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 30, .16);
  --r: 14px; --r-sm: 10px; --r-xs: 7px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215; --surface: #1a1b1f; --surface-2: #1f2025; --sunken: #15161a;
    --ink: #eceae6; --ink-2: #cfccc6; --muted: #9a9790; --faint: #6e6c67;
    --line: #2a2b30; --line-2: #34363c;
    --accent: #e0577d; --accent-ink: #1a0a10; --accent-soft: #3a1a24; --accent-2: #f07a9b;
    --teal: #5cc7bb; --teal-soft: #15302d; --indigo: #a3a7f5; --indigo-soft: #23254a;
    --amber: #f0bf5c; --amber-soft: #352a12; --green: #7fd492; --green-soft: #17301d;
    --red: #ff8a80; --red-soft: #3a1c1a;
    --tierA: #e0577d; --tierB: #f0915c; --tierC: #9aa0aa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
button, a, label, input, select, textarea { touch-action: manipulation; }
body.sheet-open, body.modal-open, body.drawer-open { overflow: hidden; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line);
  background: var(--surface-2); display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; text-decoration: none;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: var(--sunken); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); padding: 8px 11px; }
.nav a.active svg { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding: 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; padding: 16px 32px 12px; padding-top: calc(16px + var(--safe-t));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.content { padding: 8px 32px 64px; max-width: 1180px; width: 100%; }

/* ---------- ask bar ---------- */
.ask {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); max-width: 860px;
  transition: border-color .15s, box-shadow .15s;
}
.ask:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow); }
.ask .spark { color: var(--accent); }
.ask input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 9px 4px; }
.ask input::placeholder { color: var(--faint); }
.mic {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent);
  transition: transform .1s, background .15s; position: relative;
}
.mic:active { transform: scale(.95); }
.mic svg { width: 20px; height: 20px; }
.mic.listening { background: var(--red); }
.mic.listening::after {
  content: ""; position: absolute; inset: -5px; border-radius: 16px; border: 2px solid var(--red); opacity: .6; animation: pulse 1.2s infinite;
}
@keyframes pulse { 0% { transform: scale(.92); opacity: .7 } 100% { transform: scale(1.15); opacity: 0 } }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.ask-hints { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; max-width: 860px; }
.hint {
  font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  white-space: nowrap;
}
.hint:hover { border-color: var(--line-2); background: var(--surface-2); }

/* ---------- result panel ---------- */
.result {
  max-width: 860px; margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: drop .18s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px) } to { opacity: 1; transform: none } }
.result-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.result-head .q { font-size: 13px; color: var(--muted); }
.result-head .t { font-weight: 650; font-size: 16px; letter-spacing: -.005em; }
.result-body { max-height: min(56vh, 520px); overflow: auto; }
.result-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; align-items: center; }
.bignum { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.change-list { list-style: none; margin: 0; padding: 12px 16px; display: grid; gap: 8px; }
.change-list li { display: flex; gap: 10px; align-items: flex-start; }
.change-list li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }
.change-list li.head::before { display: none; }
.change-list li.head { font-weight: 650; }
.warn { margin: 0 16px 12px; padding: 9px 12px; border-radius: var(--r-xs); background: var(--amber-soft); color: var(--amber); font-size: 13px; }
.answer { padding: 14px 16px; font-size: 15.5px; }
.answer mark { background: var(--amber-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.ai-answer { margin: 12px 16px 4px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--ink); font-size: 15.5px; display: flex; gap: 10px; }
.ai-answer svg { color: var(--accent); margin-top: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 10px;
  font-weight: 600; font-size: 14px; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
a.btn { text-decoration: none; }
.btn.danger.grow, .btn.danger { color: var(--red); }
.sheet-foot .btn.danger.grow { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  background: var(--teal-soft); color: var(--teal); white-space: nowrap;
}
.chip.ev { background: var(--indigo-soft); color: var(--indigo); }
.chip.ev.att { background: var(--green-soft); color: var(--green); }
.chip.ev.inv { background: var(--amber-soft); color: var(--amber); }
.chip.plain { background: var(--sunken); color: var(--ink-2); }
.toggle-chip {
  height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 550; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; transition: all .12s;
}
.toggle-chip:hover { border-color: var(--faint); }
.toggle-chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.toggle-chip.off-x { background: var(--red-soft); border-color: transparent; color: var(--red); text-decoration: line-through; }
@media (prefers-color-scheme: dark) { .toggle-chip.on { color: #0d1f1d; } }
.tier {
  width: 24px; height: 24px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 750; flex: none;
  color: #fff; background: var(--tierC);
}
.tier.A { background: var(--tierA); } .tier.B { background: var(--tierB); } .tier.C { background: var(--tierC); }
.tier.none { background: transparent; border: 1.5px dashed var(--line-2); color: var(--faint); }
@media (prefers-color-scheme: dark) { .tier.A, .tier.B, .tier.C { color: #16171a; } }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
  background: var(--sunken); color: var(--ink-2); letter-spacing: .02em;
}
.avatar.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 21px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.section-title { font-family: var(--font-display); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
h1.page { font-family: var(--font-display); font-size: 28px; letter-spacing: -.02em; margin: 18px 0 4px; font-weight: 700; }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- home ---------- */
.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .n { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--sunken) 0); }
.ring > div { width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 750; font-size: 18px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.field-bars { display: grid; gap: 10px; margin-top: 14px; }
.field-bars .row { font-size: 13px; }
.field-bars .bar { flex: 1; }

/* prompt cards */
.prompt { padding: 18px 20px; border-top: 1px solid var(--line); }
.prompt:first-of-type { border-top: 0; }
.prompt .kind { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.prompt .qtext { font-size: 16.5px; font-weight: 550; margin-bottom: 12px; letter-spacing: -.005em; }
.prompt .qtext b { font-weight: 750; }
.prompt .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.tier-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tier-pick button {
  padding: 12px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); text-align: left; transition: all .12s;
}
.tier-pick button:hover { border-color: var(--faint); }
.tier-pick button .tier { margin-bottom: 6px; }
.tier-pick button .d { font-size: 12.5px; color: var(--muted); }
.tier-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.inline-input { display: flex; gap: 8px; }
.input, .inline-input input, textarea.input, select.input {
  flex: 1; min-width: 0; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 12px; outline: 0; font-size: 15px;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus, .inline-input input:focus { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.done-state { padding: 26px 20px; text-align: center; color: var(--muted); }
.done-state svg { width: 30px; height: 30px; color: var(--green); margin-bottom: 6px; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; display: flex; gap: 10px; }
.activity li:first-child { border-top: 0; }
.activity time { color: var(--faint); font-size: 12px; white-space: nowrap; margin-left: auto; padding-left: 8px; }

/* ---------- contacts ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); min-width: 240px; flex: 1; max-width: 380px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 15px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-label { font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin: 4px 6px 0 0; align-self: center; }
.seg { display: inline-flex; background: var(--sunken); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 30px; padding: 0 11px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list-head { display: grid; grid-template-columns: 1fr 1.4fr 140px 110px; gap: 14px; padding: 10px 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.crow {
  display: grid; grid-template-columns: 1fr 1.4fr 140px 110px; gap: 14px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line);
  cursor: pointer; transition: background .1s; width: 100%; text-align: left;
}
.crow:first-of-type { border-top: 0; }
.crow:hover { background: var(--surface-2); }
.crow.sel { background: var(--accent-soft); }
.crow .nm { font-weight: 600; }
.crow .sub { font-size: 12.5px; color: var(--muted); }
.crow .chips { display: flex; gap: 5px; flex-wrap: wrap; overflow: hidden; max-height: 26px; }
.dots { display: flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sunken); border: 1px solid var(--line-2); }
.dot.I { background: var(--amber); border-color: var(--amber); }
.dot.A { background: var(--green); border-color: var(--green); }
.comp { display: flex; gap: 3px; }
.comp i { width: 14px; height: 5px; border-radius: 3px; background: var(--sunken); }
.comp i.on { background: var(--teal); }
.list-foot { padding: 10px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- drawer (contact detail) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 15, 20, .32); z-index: 60; animation: fade .15s; }
@keyframes fade { from { opacity: 0 } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg); z-index: 61; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide .2s ease-out; border-left: 1px solid var(--line);
}
@keyframes slide { from { transform: translateX(30px); opacity: .4 } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; padding-top: calc(12px + var(--safe-t)); border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-body { grid-template-columns: minmax(0, 1fr); flex: 1; overflow-x: hidden; overflow-y: auto; padding: 18px 20px calc(40px + var(--safe-b)); display: grid; gap: 16px; align-content: start; }
.hero { display: flex; gap: 14px; align-items: center; }
.hero .name-input { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -.015em; border: 0; background: transparent; outline: 0; width: 100%; padding: 2px 0; border-bottom: 1.5px solid transparent; }
.hero .name-input:focus { border-bottom-color: var(--accent); }
.kv { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px 10px; align-items: center; }
.kv label { font-size: 13px; color: var(--muted); }
.kv input { height: 38px; border: 1px solid transparent; border-radius: 9px; padding: 0 10px; background: var(--surface-2); outline: 0; width: 100%; font-size: 15px; }
.kv input:hover { border-color: var(--line); }
.kv input:focus { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); background: var(--surface); }
.kv a.icon-btn { width: 34px; height: 34px; }
.ev-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.ev-row:first-child { border-top: 0; }
.ev-row .seg button { padding: 0 10px; }
.ev-row .seg button.on.I { color: var(--amber); }
.ev-row .seg button.on.A { color: var(--green); }
.hc { width: 54px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); text-align: center; outline: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.timeline li:first-child { border-top: 0; }
.tl-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); }
.tl-ic svg { width: 15px; height: 15px; }
.tl-ic.met { background: var(--accent-soft); color: var(--accent); }
.tl-ic.call { background: var(--teal-soft); color: var(--teal); }
.tl-ic.text, .tl-ic.email { background: var(--indigo-soft); color: var(--indigo); }
.tl-date { font-size: 12.5px; color: var(--muted); }
.composer { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
details.legacy summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.legacy-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; margin-top: 8px; color: var(--ink-2); }

/* ---------- circles page ---------- */
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.meta-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.meta-row:first-of-type { border-top: 0; }
.meta-row .nm { font-weight: 600; cursor: pointer; }
.meta-row .nm:hover { color: var(--accent); }
.meta-row .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 64px; text-align: right; }
.meta-row .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--teal); flex: none; }
.meta-row .sw.ev { background: var(--indigo); }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .18s ease-out; border: 1px solid var(--line); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px) } }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 18px; letter-spacing: -.01em; }
.modal-body { padding: 4px 0 0; overflow: auto; }
.steps { display: flex; gap: 5px; }
.steps i { width: 20px; height: 4px; border-radius: 4px; background: var(--sunken); }
.steps i.on { background: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 100; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; animation: drop .2s;
  max-width: calc(100vw - 32px);
}
.toast button { color: #f6a9bf; font-weight: 700; }
@media (prefers-color-scheme: dark) { .toast button { color: var(--accent); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 32px 28px; text-align: center; }
.login-card .brand-mark { width: 56px; height: 56px; border-radius: 17px; margin: 0 auto 16px; }
.login-card .brand-mark svg { width: 34px; height: 34px; }
.login-card h2 { margin: 0 0 4px; font-family: var(--font-display); letter-spacing: -.015em; }

/* ---------- tabbar (mobile) ---------- */
.tabbar { display: none; }


/* =================== components (v2) =================== */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 4px; }
.page-head .btn { margin-bottom: 22px; }
.toolbar .search { flex: 1; max-width: none; }
select.sort-sel { width: 180px; flex: none; height: 40px; }
.filter-btn { height: 40px; position: relative; }
.filter-btn.has { border-color: var(--indigo); color: var(--indigo); }
.badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--indigo); color: #fff; font-size: 11px; font-weight: 750; }
.seg-full { display: flex; width: 100%; }
.seg-full button { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-seg { max-width: 460px; margin-bottom: 12px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.af-chip { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px 0 12px; border-radius: 99px; background: var(--indigo-soft); color: var(--indigo); font-size: 13px; font-weight: 600; max-width: 100%; }
.af-chip svg { width: 14px; height: 14px; }
.af-clear { font-size: 13px; color: var(--muted); font-weight: 600; padding: 0 6px; height: 30px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.count-pill { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--sunken); color: var(--muted); font-size: 11px; letter-spacing: 0; vertical-align: 1px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head .section-title { margin: 0; flex: 1; }
.grabber { display: none; width: 38px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 0 auto; }
.result-scrim { display: none; }
.skip-group { display: inline-flex; gap: 2px; margin-left: auto; }
.prompt .acts { justify-content: flex-start; }

/* sheets (filters, log, menus) */
.sheet-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; padding: 16px 16px 8px 20px; }
.sheet-head .grabber { grid-column: 1 / -1; margin-bottom: 6px; }
.sheet-head h3 { margin: 0; font-family: var(--font-display); font-size: 18px; letter-spacing: -.01em; min-width: 0; }
.sheet-body { padding: 6px 20px 18px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px; padding-bottom: calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface-2); }
.sheet-foot .btn { height: 46px; }
.fs { margin-bottom: 22px; }
.fs:last-child { margin-bottom: 4px; }
.fs-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.fs-h > span:first-child { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.action-list { display: grid; padding: 4px 0 calc(8px + var(--safe-b)); }
.action-list button { display: flex; align-items: center; gap: 14px; height: 54px; padding: 0 22px; border-top: 1px solid var(--line); font-size: 16px; font-weight: 550; text-align: left; }
.action-list button:hover { background: var(--surface-2); }
.action-list .danger { color: var(--red); }

/* forms */
.fields { display: grid; gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  display: block; width: 100%; min-width: 0; height: 44px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface-2);
  padding: 0 12px; outline: 0; font-size: 16px; -webkit-appearance: none; appearance: none;
}
.field input:focus, .field textarea:focus { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.ta-mic { position: relative; }
.ta-mic textarea { width: 100%; min-height: 110px; padding-right: 54px; font-size: 16px; }
.ta-mic .mic { position: absolute; right: 8px; bottom: 10px; }
.mic-sm { width: 36px; height: 36px; border-radius: 11px; }
.mic-sm svg { width: 17px; height: 17px; }
#dNotes { width: 100%; min-height: 120px; font-size: 16px; }

/* contact drawer */
.drawer-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; }
.drawer-head .icon-btn { justify-self: end; }
.nav-back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; font-size: 15px; height: 38px; padding-right: 8px; justify-self: start; }
.nav-back svg { width: 22px; height: 22px; }
.dh-title { font-weight: 650; font-size: 15px; max-width: 52vw; text-align: center; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.qa { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 64px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--accent); font-size: 12.5px; font-weight: 650; text-decoration: none; }
.qa svg { width: 21px; height: 21px; }
.qa:hover { background: var(--surface-2); }
.qa.off { color: var(--faint); opacity: .55; }
.tier3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tier3 button { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); text-align: left; min-width: 0; transition: border-color .12s, box-shadow .12s; }
.tier3 button:hover { border-color: var(--faint); }
.tier3 button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.t3-l { display: flex; flex-direction: column; min-width: 0; }
.t3-l b { font-size: 14px; font-weight: 700; }
.t3-l small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-row { display: block; padding: 12px 0; border-top: 1px solid var(--line); }
.ev-row:first-of-type { border-top: 0; padding-top: 2px; }
.ev-name { font-weight: 600; margin-bottom: 8px; }
.ev-ctrl { display: flex; gap: 8px; align-items: center; }
.ev-ctrl .seg { flex: 1; min-width: 0; }
.ev-ctrl .seg button.on.I { color: var(--amber); }
.ev-ctrl .seg button.on.A { color: var(--green); }
.hc-wrap { display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 4px 0 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-weight: 650; flex: none; }
.hc-wrap.dim { opacity: .45; }
.hc-wrap .hc { width: 36px; height: 30px; border: 0; background: transparent; text-align: center; font-size: 16px; outline: 0; -moz-appearance: textfield; }
.hc::-webkit-outer-spin-button, .hc::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
details.legacy summary { list-style: none; display: flex; align-items: center; gap: 6px; }
details.legacy summary::-webkit-details-marker { display: none; }
.timeline li > div:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }

/* contacts list (desktop default) */
.crow { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 110px 90px; }
.list-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 110px 90px; }
.c-main { min-width: 0; }
.c-chev { display: none; }
.tab-mic { display: none; }

/* circles & events pages */
.meta-tabs { max-width: 420px; margin-bottom: 14px; }
.meta-list .crow, .meta-crow { grid-template-columns: auto minmax(0, 1fr) auto !important; align-items: center; gap: 12px; }
.meta-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); flex: none; }
.meta-ic.events { background: var(--indigo-soft); color: var(--indigo); }
.meta-ic svg { width: 18px; height: 18px; }
.meta-add { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-top: 1px solid var(--line); color: var(--accent); font-weight: 650; }
.meta-add:hover { background: var(--surface-2); }
.crumb { margin-top: 14px; text-decoration: none; }
.stats-3 { grid-template-columns: repeat(3, 1fr) !important; }
.detail-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.detail-tools .seg-full { max-width: 460px; }
.detail-tools .search { flex: 1; max-width: none; }
.drow { display: flex !important; align-items: center; gap: 10px; cursor: default; padding: 10px 14px !important; }
.drow-name { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; text-align: left; padding: 4px 0; }
.drow-name .nm { max-width: 100%; }
.drow-name:hover .nm { color: var(--accent); }
.seg-mini { flex: none; }
.seg-mini button { height: 30px; padding: 0 9px; font-size: 12.5px; }
.seg-mini button.on.I { color: var(--amber); }
.seg-mini button.on.A { color: var(--green); }
.drow .toggle-chip { flex: none; height: 32px; }
.add-chip { border-style: dashed; color: var(--accent); }
.add-chip svg { width: 15px; height: 15px; }

@media (max-width: 900px) {
  .home-grid, .meta-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* =================== phone =================== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  input, select, textarea, .input, .ask input, .search input { font-size: 16px !important; }
  .hide-sm { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 8px 16px 8px; padding-top: calc(8px + var(--safe-t)); background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .content { padding: 4px 16px calc(110px + var(--safe-b)); }
  h1.page { font-size: 28px; margin: 12px 0 2px; }
  .page-sub { margin-bottom: 16px; font-size: 14px; }
  .page-head .btn { margin-bottom: 16px; width: 44px; height: 44px; padding: 0; border-radius: 13px; }
  .page-head .btn svg { width: 22px; height: 22px; }

  /* ask bar */
  .ask { border-radius: 14px; padding: 5px 5px 5px 12px; box-shadow: var(--shadow-sm); max-width: none; }
  .ask .icon-btn { width: 34px; height: 34px; }
  .mic { width: 40px; height: 40px; border-radius: 11px; }
  .ask-hints { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 8px -16px 0; padding: 0 16px 2px; max-width: none; }
  .ask-hints::-webkit-scrollbar { display: none; }
  .hint { font-size: 13px; padding: 7px 12px; }

  /* results as a bottom sheet */
  .result-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 15, 20, .38); z-index: 70; animation: fade .15s; }
  .result {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-width: none; z-index: 71; border-radius: 22px 22px 0 0; border: 0;
    max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column; animation: up .22s ease-out; padding-top: 8px;
  }
  @keyframes up { from { transform: translateY(40px); opacity: .5 } }
  .result .grabber { display: block; margin-bottom: 2px; }
  .result-head { padding: 10px 16px 12px; }
  .result-body { max-height: none; flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
  .result-foot { padding: 12px 16px; padding-bottom: calc(12px + var(--safe-b)); }
  .result-foot > .spacer, .result-foot > span.tiny:empty { display: none; }
  .result-foot .btn { flex: 1 1 140px; height: 44px; }
  .bignum { font-size: 30px; }

  /* sheets */
  .modal-wrap { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; border: 0; max-height: 92vh; max-height: 92dvh; animation: up .22s ease-out; }
  .modal .grabber { display: block; }
  .modal:not(.is-sheet) { padding-bottom: var(--safe-b); }
  .modal:not(.is-sheet) .result-foot { padding-bottom: 12px; }
  .modal .result-foot .btn { height: 44px; }

  /* home */
  .stats { gap: 10px; margin-bottom: 14px; }
  .stat { padding: 12px 14px; }
  .stat .n { font-size: 22px; }
  .home-grid, .home-grid > div { gap: 14px !important; }
  .card-pad { padding: 16px; }
  .prompt { padding: 16px; }
  .prompt .qtext { font-size: 16.5px; }
  .prompt .acts { gap: 6px; }
  .inline-input input { height: 44px; }
  .inline-input .btn { height: 44px; }
  .chip-grid .toggle-chip { height: 36px; }
  .tier3 { gap: 6px; }
  .tier3 button { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }
  .t3-l small { font-size: 11.5px; }
  .activity time { font-size: 11.5px; }

  /* contacts */
  .toolbar { gap: 8px; flex-wrap: nowrap; margin-bottom: 10px; }
  .toolbar .search { min-width: 0; height: 44px; border-radius: 12px; }
  .filter-btn { height: 44px; padding: 0 12px; border-radius: 12px; }
  .filter-btn > span { display: none; }
  select.sort-sel { display: none; }
  .tier-seg { max-width: none; }
  .tier-seg button { height: 34px; }
  .active-filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .active-filters::-webkit-scrollbar { display: none; }
  .af-chip, .af-clear { flex: none; }
  .list { border-radius: 16px; }
  .list-head { display: none; }
  .crow { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 12px 14px; }
  .c-chev { display: block; }
  .c-groups { padding-left: 34px; flex-wrap: nowrap !important; overflow: hidden; max-height: none !important; }
  .c-groups:empty { display: none; }
  .crow .c-ev, .crow .c-comp { display: none; }
  .chip { height: 24px; font-size: 12px; padding: 0 9px; }
  .list-foot .btn { flex: 1 1 auto; }

  /* drawer = full screen page */
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head { padding: 8px 10px; padding-top: calc(8px + var(--safe-t)); }
  .drawer-body { padding: 16px 16px calc(40px + var(--safe-b)); gap: 14px; }
  .hero .name-input { font-size: 22px; }
  .avatar.lg { width: 56px; height: 56px; font-size: 19px; border-radius: 17px; }
  .ev-ctrl .seg button { padding: 0 6px; font-size: 13px; }

  /* circles & settings */
  .meta-row { padding: 12px 14px; }
  .meta-row .num { min-width: 0; }
  .meta-row .icon-btn[data-act="meta-move"] { display: none; }
  .meta-row .input { height: 44px; }
  .meta-tabs { max-width: none; }
  .crumb { margin-top: 6px; }
  .stats-3 .stat .n { font-size: 20px; }
  .detail-tools .btn { height: 44px; width: 48px; padding: 0; border-radius: 12px; flex: none; }
  .detail-tools .search { height: 44px; border-radius: 12px; }
  .drow { padding: 10px 12px !important; gap: 8px; }
  .seg-mini button { padding: 0 7px; font-size: 12px; }

  /* tab bar with centre mic */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--faint); text-decoration: none; padding: 4px 0; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg.i { width: 24px; height: 24px; }
  .tab-mic {
    display: grid; place-items: center; justify-self: center; width: 56px; height: 56px; border-radius: 50%; margin-top: -22px; position: relative;
    background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 0 5px var(--bg);
  }
  .tab-mic svg { width: 24px; height: 24px; }
  .tab-mic.listening { background: var(--red); }
  .tab-mic.listening::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--red); animation: pulse 1.2s infinite; }
  body.drawer-open .tabbar, body.sheet-open .tabbar { display: none; }

  .toast { bottom: calc(92px + var(--safe-b)); }
  body.drawer-open .toast { bottom: calc(24px + var(--safe-b)); }
}
@media (max-width: 360px) {
  .t3-l small { display: none; }
  .quick-actions { gap: 6px; }
}
.meta-grid > *, .home-grid > *, .stats > * { min-width: 0; }
.meta-row .input { min-width: 0; }

.ai-badge { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 650; }
.ai-badge svg { width: 13px; height: 13px; }
.field select { background-image: none; }
@media (max-width: 760px) { .result-foot .ai-badge { flex: none; } }
@media (max-width: 760px) {
  .drow { align-items: center; }
  .drow-name .nm { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
}
