:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4efe7;
  --ink: #1f2a2e;
  --muted: #5d6b6f;
  --line: #e6dfd3;
  --brand: #0f766e;
  --brand-ink: #0b5a54;
  --brand-soft: #e5f2ef;
  --gold: #a95c0b;
  --gold-soft: #fbf0df;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #18794a;
  --ok-soft: #e6f4ec;
  --shadow: 0 1px 2px rgba(31, 42, 46, 0.05), 0 4px 16px rgba(31, 42, 46, 0.05);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--brand-ink); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.h3 { font-size: 1.2rem; }
.h4 { font-size: 1.02rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small, small { font-size: 0.875rem; }
.fine { font-size: 0.82rem; color: var(--muted); margin-top: 0.75rem; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

/* Shell */
.test-strip { background: var(--gold-soft); color: var(--gold); text-align: center; font-size: 0.8rem; padding: 0.35rem 1rem; border-bottom: 1px solid #f0dcbd; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(250, 247, 242, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0.7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; fill: var(--brand); }
.who { display: flex; align-items: center; gap: 0.6rem; }
.who-name { font-weight: 500; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; font-size: 0.85rem; flex: none; }
.avatar.gold { background: var(--gold-soft); color: var(--gold); }

.tabs { max-width: 1100px; margin: 0 auto; padding: 0 0.5rem; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; display: flex; align-items: center; gap: 0.45rem; padding: 0.7rem 0.85rem; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); position: absolute; top: 0.6rem; left: 1.9rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.view { animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-title { font-size: 1.85rem; margin-bottom: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .page-title { margin: 0; }
.foot { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 6rem; color: var(--muted); font-size: 0.82rem; }

/* Layout */
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-row.end { justify-content: flex-end; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.card-head h2 { margin: 0; }
.card.demo { border-style: dashed; background: transparent; box-shadow: none; }
.soft-box { background: var(--surface-2); border-radius: 10px; padding: 0.85rem 1rem; margin-top: 1rem; }

/* Buttons */
.btn { appearance: none; border: 1px solid transparent; border-radius: 10px; padding: 0.6rem 1.05rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 44px; transition: background 0.15s, border-color 0.15s, transform 0.05s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: #cfc5b5; background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #f3c7c1; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.link { background: none; color: var(--brand-ink); padding-left: 0.25rem; padding-right: 0.25rem; }
.btn.large { padding: 0.85rem 1.4rem; font-size: 1.05rem; }
.btn.small { min-height: 34px; padding: 0.35rem 0.75rem; font-size: 0.875rem; border-radius: 8px; }
:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.35); outline-offset: 2px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 500; }
.field small { color: var(--muted); font-weight: 400; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #d9d1c3; border-radius: 10px; padding: 0.6rem 0.75rem; min-height: 44px; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem; margin-top: 1rem; align-items: end; }
.inline-form { display: flex; gap: 0.5rem; }
.inline-form input { flex: 1; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }

fieldset.choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45rem; }
fieldset.choice legend { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.4rem; padding: 0; }
.choice-card { display: flex; align-items: center; gap: 0.7rem; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; cursor: pointer; background: var(--surface); }
.choice-card:hover { border-color: #cfc5b5; }
.choice-card input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); flex: none; }
.choice-card span { display: flex; flex-direction: column; }
.choice-card small { color: var(--muted); }
.choice-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 1rem; gap: 2px; }
.seg-btn { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 0.45rem 1rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; }
.seg-btn.active, .seg-btn:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.25rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; cursor: pointer; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); }
.switch { appearance: none; width: 48px; height: 28px; min-height: 0; padding: 0; border-radius: 99px; background: #d4ccbf; border: 0; position: relative; cursor: pointer; flex: none; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

/* Pills and chips */
.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--sans); font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.unlock { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.chip { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.chip.on { border-color: transparent; background: var(--gold-soft); color: var(--gold); }
.chip.on.full { background: var(--danger-soft); color: var(--danger); }

/* Welcome */
.hero { padding: 2rem 0 2.25rem; max-width: 680px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 0.75rem; }
.lead { font-size: 1.12rem; color: var(--muted); }
.eyebrow { color: var(--gold); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.02em; margin-bottom: 0.75rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
.steps { padding-left: 1.2rem; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.bullets { padding-left: 1.1rem; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }

/* Home */
.stat { display: flex; flex-direction: column; gap: 0.15rem; text-decoration: none; color: var(--ink); transition: border-color 0.15s, transform 0.15s; }
.stat:hover { border-color: #cfc5b5; transform: translateY(-1px); }
.stat-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.stat-sub { font-size: 0.85rem; color: var(--muted); }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; background: var(--danger-soft); border: 1px solid #f3c7c1; }
.alert p { margin: 0; }
.alert.gold { background: var(--gold-soft); border-color: #f0dcbd; }
.guide summary, details.info summary { cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; list-style: none; display: flex; align-items: center; gap: 0.6rem; }
.guide summary::-webkit-details-marker, details.info summary::-webkit-details-marker { display: none; }
.guide summary::after, details.info summary::after { content: "+"; margin-left: auto; color: var(--muted); font-family: var(--sans); }
.guide[open] summary::after, details.info[open] summary::after { content: "\2212"; }
.guide[open] summary, details.info[open] summary { margin-bottom: 0.75rem; }
.checklist { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.6rem; }
.expect { display: block; color: var(--brand-ink); font-size: 0.88rem; }

/* People */
.people-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.reports, .contacts, .mini-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.65rem; }
.empty { color: var(--muted); font-size: 0.92rem; padding: 1rem; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

.report { border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; border-left: 4px solid var(--line); }
.report.open { border-left-color: var(--gold); background: #fffdf9; }
.report-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.report-title { font-weight: 600; }
.report-meta { font-size: 0.85rem; color: var(--muted); }
.report .pills { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.report details { margin-top: 0.5rem; font-size: 0.85rem; }
.report summary { cursor: pointer; color: var(--muted); }
.timeline { list-style: none; margin: 0.5rem 0 0; padding: 0 0 0 0.9rem; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 0.4rem; }
.timeline time { color: var(--muted); display: block; font-size: 0.78rem; }

.contact { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; }
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.contact-sub { font-size: 0.85rem; color: var(--muted); }
.contact .btn-row { margin-top: 0.5rem; }

.phone { position: sticky; top: 8.5rem; background: #18282b; border-radius: 28px; padding: 0.6rem; box-shadow: 0 10px 30px rgba(24, 40, 43, 0.25); }
.phone-head { color: #e7efee; padding: 0.9rem 1rem 0.8rem; text-align: center; }
.phone-head h2 { color: #fff; margin: 0.4rem 0 0.15rem; }
.phone-head p { margin: 0; color: #a9bcbc; }
.phone-notch { display: block; width: 70px; height: 5px; border-radius: 99px; background: #3a4d50; margin: 0 auto; }
.phone-body { background: var(--bg); border-radius: 22px; padding: 1rem; display: flex; flex-direction: column; gap: 0.85rem; }
.identity { border-radius: 10px; padding: 0.7rem 0.85rem; font-size: 0.9rem; }
.identity.ok { background: var(--ok-soft); color: #0f5132; }
.identity.bad { background: var(--danger-soft); color: var(--danger); }
.identity strong { display: block; }
.mini-list li { border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem; background: var(--surface); font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.45rem; }

/* Check-ins */
.status-card { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-text { flex: 1; min-width: 220px; }
.status-text p { margin: 0; }
.status-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--ok-soft); flex: none; position: relative; }
.status-icon::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 24px; border: solid var(--ok); border-width: 0 4px 4px 0; transform: translate(0, -3px) rotate(45deg); }
.status-card.warn { border-color: #f3c7c1; background: #fffafa; }
.status-card.warn .status-icon { background: var(--danger-soft); }
.status-card.warn .status-icon::after { width: 4px; height: 22px; border: 0; background: var(--danger); transform: translateY(-4px); box-shadow: 0 16px 0 var(--danger); height: 18px; }
.status-card.off .status-icon { background: var(--surface-2); }
.status-card.off .status-icon::after { width: 22px; height: 4px; border: 0; background: var(--muted); transform: none; }

/* Vault */
.vault-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.slot { display: flex; flex-direction: column; gap: 0.5rem; }
.slot h3 { margin: 0; }
.slot-note { font-size: 0.85rem; color: var(--muted); margin: 0; }
.slot ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.slot li { font-size: 0.88rem; background: var(--surface-2); border-radius: 8px; padding: 0.4rem 0.6rem; overflow-wrap: anywhere; }
.slot form { display: flex; gap: 0.4rem; margin-top: auto; padding-top: 0.5rem; }
.slot form input { flex: 1; min-height: 38px; padding: 0.4rem 0.6rem; font-size: 0.9rem; }

/* Planning */
.path-card { text-align: left; font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 0.3rem; }
.path-card:hover { border-color: #cfc5b5; }
.path-card.active { border-color: var(--brand); background: var(--brand-soft); }
.path-card small { color: var(--muted); }
details.info p { color: var(--muted); }

/* Account */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; margin: 0; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.counter { display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 0 1rem; flex-wrap: wrap; }
progress { flex: 1; min-width: 160px; height: 10px; appearance: none; border: 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--gold); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 99px; }
.plan { display: flex; flex-direction: column; gap: 0.4rem; }
.price { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; margin: 0 0 0.5rem; }
.price small { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); font-weight: 400; }

/* Dialogs and toasts */
dialog { border: 0; border-radius: 18px; padding: 1.4rem; width: min(460px, calc(100vw - 2rem)); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(24, 40, 43, 0.45); }
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.5rem; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: #18282b; color: #fff; border-radius: 12px; padding: 0.8rem 1rem; font-size: 0.92rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); animation: toast-in 0.2s ease-out; border-left: 4px solid var(--brand); pointer-events: auto; }
.toast.error { border-left-color: #f97066; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Mobile */
@media (max-width: 860px) {
  .people-layout { grid-template-columns: 1fr; }
  .phone { position: static; }
}
@media (max-width: 640px) {
  .wrap { padding-top: 1rem; }
  .page-title { font-size: 1.5rem; }
  .who-name { display: none; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; max-width: none; background: var(--surface); border-top: 1px solid var(--line); padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; z-index: 30; }
  .tabs a { flex-direction: column; gap: 0.1rem; padding: 0.4rem 0.3rem; font-size: 0.7rem; border-bottom: 0; flex: 1; }
  .tabs a.active { background: var(--brand-soft); border-radius: 10px; }
  .badge-dot { top: 0.35rem; left: calc(50% + 6px); }
  .phone { top: auto; }
  .hero { padding-top: 1rem; }
  .toasts { bottom: 5.5rem; }
}

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

/* Sign-in, app lock and two-step verification (milestone 2) */
.form-error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 0; }
.lock-card { max-width: 26rem; margin: 3rem auto; }
#mfa-qr { background: #fff; border-radius: 8px; padding: 6px; display: block; }
#mfa-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; letter-spacing: 0.04em; user-select: all; }
#reauth-dialog { max-width: 26rem; width: calc(100% - 2rem); }

/* Passkeys */
.passkey-list { list-style: none; padding: 0; margin: 0.75rem 0; display: grid; gap: 0.5rem; }
.passkey-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; background: var(--surface-2); border-radius: 10px; padding: 0.6rem 0.85rem; }
.passkey-list small { display: block; color: var(--muted); }
