/* Life dashboard — one design language for both domains. No framework. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1d23;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #2563eb;
  --good: #16a34a;
  --danger: #dc2626;
--warn: #d97706;
  --radius: 12px;
  /* spacing scale — 4px grid (Polaris-like) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  /* elevation + motion (Material/Polaris-inspired) */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 2px 8px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.10), 0 24px 64px rgba(16, 24, 40, 0.12);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 180ms;
  --dur-slow: 340ms;
  --accent-soft: #eef4ff;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over component display rules (.tabs, .split, etc.). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: var(--space-3) var(--space-6); background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1100;
}
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.logo { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tabs button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: #f0f2f5; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.focus-toggle {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.focus-toggle:hover { background: #f0f2f5; }
.focus-toggle.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.domain { max-width: 1200px; margin: 0 auto; padding: var(--space-4) var(--space-6) var(--space-7); }

.panel {
background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4);
}
.panel h2 { margin: 0 0 var(--space-3); font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.notes-panel { margin: var(--space-4) 0; padding: 0; overflow: hidden; }
.notes-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  width: 100%; padding: var(--space-3) var(--space-4); background: transparent; border: 0;
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left;
}
.notes-toggle:hover { background: #f8f9fb; }
.notes-caret { transition: transform .15s ease; color: var(--muted); }
.notes-toggle.expanded .notes-caret { transform: rotate(90deg); }
.notes-body { padding: 0 var(--space-4) var(--space-3); font-size: 14px; line-height: 1.55; }
.notes-body.collapsed {
  max-height: 5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}
.notes-body h3 { margin: var(--space-3) 0 var(--space-1); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notes-body p { margin: var(--space-2) 0; }
.notes-body ul { margin: var(--space-1) 0 var(--space-2); padding-left: 20px; }
.notes-body li { margin: 2px 0; }
.notes-body strong { color: var(--ink); }
.notes-body em { color: var(--muted); font-style: normal; }
.notes-table { width: 100%; border-collapse: collapse; margin: var(--space-2) 0 var(--space-3); font-size: 13px; }
.notes-table th, .notes-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.notes-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
.notes-table tr:last-child td { border-bottom: 0; }
.notes-table td:first-child { font-weight: 600; white-space: nowrap; }

/* ---------- Finance ---------- */
.finance-head { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; width: 32px; height: 32px; font-size: 18px; line-height: 1; cursor: pointer;
}
.nav-btn:hover { background: #f0f2f5; }
.nav-btn.today { width: auto; padding: 0 12px; font-size: 13px; }
.month-label { font-weight: 600; min-width: 110px; text-align: center; }

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3); margin-bottom: var(--space-4);
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

.budget-bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-row .spent-val { color: var(--muted); }
.bar-track { height: 8px; border-radius: 999px; background: #eceef1; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.3s ease; }
.bar-fill.over { background: var(--danger); }
.bar-fill.warn { background: var(--warn); }

.debts { display: flex; flex-direction: column; gap: 14px; }
.debt-item { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.debt-item:last-child { border-bottom: 0; padding-bottom: 0; }
.debt-name { font-weight: 600; font-size: 14px; }
.debt-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.debt-balance { font-size: 18px; font-weight: 700; margin-top: 4px; }
.util-track { height: 6px; border-radius: 999px; background: #eceef1; margin-top: 6px; overflow: hidden; }
.util-fill { height: 100%; background: var(--warn); }

.tx-panel { padding-bottom: 12px; }
.tx-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tx-head h2 { margin: 0; }
.tx-head input { border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 14px; min-width: 220px; }
.tx-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tx-table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tx-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tx-table tr:last-child td { border-bottom: 0; }
.tx-table .num, .tx-table th.num { text-align: right; }
.tx-date { color: var(--muted); white-space: nowrap; }
.tx-desc { font-weight: 500; }
.tx-cat { font-size: 12px; color: var(--muted); }
.amt-out { color: var(--danger); font-variant-numeric: tabular-nums; }
.amt-in { color: var(--good); font-variant-numeric: tabular-nums; }
.tx-excluded { opacity: 0.45; }
.tx-empty { color: var(--muted); padding: 18px; text-align: center; }

.badge {
  display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: #eef2ff; color: #4338ca; font-weight: 600; margin-left: 8px; vertical-align: 2px;
}
.badge.active { background: #dcfce7; color: #166534; }
.badge.idea { background: #fef3c7; color: #92400e; }

/* ---------- Travel ---------- */
.trip-tabs { flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
/* hide the header picker's scrollbar until you hover (mobile just swipes) */
.trip-tabs::-webkit-scrollbar { height: 0; }
.trip-tabs:hover { scrollbar-width: thin; }
.trip-tabs:hover::-webkit-scrollbar { height: 6px; }
.trip-tabs:hover::-webkit-scrollbar-track { background: transparent; }
.trip-tabs:hover::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.trip-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; flex-wrap: wrap; }
.trip-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.stats { display: flex; gap: 18px; }
.stat { text-align: center; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.filter { display: flex; gap: 6px; }
.filter button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 5px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.filter button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.open-count { color: var(--muted); font-size: 13px; }

.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.map { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); background: #e9ecef; z-index: 1; }
.stops { height: 520px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 8px; }
.stop { padding: 11px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; cursor: pointer; border-radius: 8px; }
.stop:last-child { border-bottom: 0; }
.stop:hover { background: #f0f2f5; }
.stop .rail { width: 4px; border-radius: 999px; background: var(--line); flex-shrink: 0; }
.stop.booked .rail { background: var(--good); }
.stop.planned .rail { background: var(--warn); }
.stop-body { flex: 1; min-width: 0; }
.stop-top { display: flex; justify-content: space-between; gap: 8px; }
.stop-place { font-weight: 600; }
.stop-nights { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stop-date { color: var(--muted); font-size: 12px; }
.stop-camp { font-size: 13px; margin-top: 2px; }
.stop-note { font-size: 12px; color: var(--muted); margin-top: 3px; }

.open-panel { margin-top: 14px; }
.open-panel ul { list-style: none; margin: 0; padding: 0; }
.open-panel li { padding: 6px 0; font-size: 14px; }
.open-panel li.done { color: var(--muted); text-decoration: line-through; }

.analysis-panel { margin-top: 14px; }
.analysis-body { font-size: 14px; line-height: 1.55; }
.analysis-body h1 { font-size: 20px; margin: 0 0 10px; }
.analysis-body h2 { font-size: 17px; margin: 0 0 8px; }
.analysis-body h3 { font-size: 15px; margin: 0 0 6px; }
.analysis-body ul { margin: 6px 0; padding-left: 20px; }
.analysis-body li { margin-bottom: 4px; }
.analysis-body br { content: ''; display: block; margin: 6px 0; }
.analysis-body strong { color: var(--ink); }

.leaflet-popup-content { font-family: inherit; }
.leaflet-popup-content strong { display: block; margin-bottom: 2px; }
.leaflet-popup-content .pmeta { color: var(--muted); font-size: 12px; }

/* ---------- Share view (no chrome) ---------- */
.share-active .topbar { display: none; }
.share-active .domain { max-width: none; padding: 0; }
.share-active .trip-head { padding: var(--space-4) var(--space-4) 0; }
.share-active .toolbar { display: none; }
.share-active .split { height: calc(100vh - 120px); }
.share-active .map { height: 100%; }

/* ---------- Goals ---------- */
.goals-intro { margin-bottom: 18px; }
.goals-north { margin: 0; font-size: 15px; color: var(--muted); max-width: 720px; }
.goals-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.goal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 8px;
}
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.goal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.goal-horizon { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.goal-why { font-size: 13px; color: var(--muted); }
.goal-metrics { display: flex; flex-wrap: wrap; gap: 6px; }
.goal-metric { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: #eef2ff; color: #4338ca; }
.goal-progress { margin-top: 4px; }
.goal-count { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge.planned { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.shelved { background: #e5e7eb; color: #4b5563; }

/* ---------- Memory ---------- */
.mem-toolbar { margin-bottom: 14px; }
.mem-search {
  width: 100%; max-width: 560px; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; font-size: 14px;
}
.mem-list { display: flex; flex-direction: column; gap: 10px; }
.mem-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.mem-head { display: flex; align-items: center; gap: 10px; }
.mem-title { font-weight: 600; font-size: 15px; }
.mem-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.mem-snippet { color: var(--muted); font-size: 13px; margin-top: 4px; font-style: italic; }
.mem-path { color: var(--muted); font-size: 11px; margin-top: 6px; font-family: ui-monospace, monospace; }
.badge.decision { background: #fef3c7; color: #92400e; }
.badge.context { background: #e0f2fe; color: #075985; }
.badge.preference { background: #fae8ff; color: #86198f; }

/* ---------- Combo picker (share/combo) ---------- */
.combo-picker { margin-bottom: var(--space-4); }
.combo-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); flex-wrap: wrap; }
.combo-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; min-width: 110px; }
.combo-tabs { flex-wrap: wrap; overflow: visible; }
.combo-summary { margin-top: var(--space-2); font-size: 14px; }
.combo-summary strong { font-size: 16px; }
.combo-summary .muted { color: var(--muted); font-size: 13px; }

/* ---------- Share button + modal ---------- */
.trip-head-right { display: flex; align-items: center; gap: var(--space-4); }
.share-btn { border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.share-btn:hover { opacity: 0.9; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,24,0.45); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: var(--space-4); }
.modal { background: var(--panel); border-radius: var(--radius); padding: var(--space-5); width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal h3 { margin: 0 0 var(--space-1); font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 var(--space-3); }
.modal-field { margin: var(--space-3) 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.modal-field.checkbox { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-field input[type=text], .modal-field select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--space-4); }
.btn, .btn-ghost { border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.share-result { margin-top: var(--space-3); font-size: 13px; }
.share-link { display: flex; gap: 8px; }
.share-link input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 0; }
.share-existing { margin-top: var(--space-3); }
.share-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.share-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }

/* ---------- Budget ---------- */
.budget-grid-2col { grid-template-columns: 1fr 1fr; }
.budget-recurring { display: flex; flex-direction: column; gap: 4px; }
.rec-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.rec-row:last-child { border-bottom: 0; }
.rec-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-total { font-weight: 600; color: var(--muted); font-size: 13px; padding-top: 6px; border-top: 2px solid var(--line); }
.rec-grand { font-weight: 700; padding-top: 6px; border-top: 2px solid var(--ink); }
.rec-income { color: var(--good); }
.rec-interest { color: var(--danger); }
.debt-interest { font-size: 12px; color: var(--danger); margin-top: 2px; }

.insight-box { margin-top: var(--space-4); background: var(--panel); border: 2px solid var(--ink); }
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); text-align: center; }
.insight-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); display: block; }
.insight-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; display: block; }

/* ---------- Services ---------- */
.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.svc-card { padding: var(--space-4); }
.svc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: var(--space-2); }
.svc-name { font-size: 16px; font-weight: 700; }
.svc-row { font-size: 13px; margin-top: 6px; display: flex; gap: 8px; }
.svc-label { color: var(--muted); min-width: 70px; flex-shrink: 0; }
.svc-notes { color: var(--muted); font-style: italic; }

/* ---------- Agent (family assistant) ---------- */
.agent-domain { max-width: none; padding: 0; }

.agent-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 46px);
  background: var(--bg);
}
@media (max-width: 860px) {
  .agent-shell { grid-template-columns: 1fr; }
  .agent-sidebar { display: none; }
}

/* Sidebar — the "brain's" context panel */
.agent-sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
}
.agent-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-5); }
.agent-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.agent-brand .name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.agent-brand .role { font-size: 12px; color: var(--muted); }
.agent-live {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--good);
  background: #ecfdf5; border: 1px solid #bbf7d0; padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.agent-live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.side-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: var(--space-5) 0 var(--space-3); font-weight: 600; }
.side-deadline { padding: 10px 0; border-bottom: 1px solid var(--line); }
.side-deadline:last-child { border-bottom: 0; }
.side-dl-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-dl-item { font-size: 13px; font-weight: 600; margin-top: 2px; line-height: 1.4; }
.side-dl-stat { font-size: 12px; margin-top: 2px; }
.side-dl-stat.done { color: var(--good); }
.side-dl-stat.warn { color: var(--warn); }
.side-fact { font-size: 13px; line-height: 1.5; color: var(--muted); }

/* Chat thread */
.agent-main { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.agent-thread { flex: 1 1 auto; overflow-y: auto; padding: var(--space-6) var(--space-6) var(--space-4); }
.agent-thread::-webkit-scrollbar { width: 8px; }
.agent-thread::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.msg { display: flex; gap: 10px; margin-bottom: 18px; animation: msg-in var(--dur-slow) var(--ease); }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; }
.msg.user .msg-avatar { background: var(--ink); color: #fff; }
.msg-body { max-width: 68%; }
.msg-bubble {
  padding: 12px 16px; border-radius: 18px; font-size: 14px; line-height: 1.55; white-space: pre-wrap;
  animation: msg-in var(--dur-slow) var(--ease);
}
.msg.assistant .msg-bubble { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm); border-top-left-radius: 6px; }
.msg.user .msg-bubble { background: var(--accent); color: #fff; border-top-right-radius: 6px; }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.user .msg-time { text-align: right; }

/* Inline card inside an assistant message */
.msg-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 4px; }
.msg-card .card-head { padding: 10px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.msg-card .card-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.msg-card .card-row:last-child { border-bottom: 0; }
.msg-card .cr-label { color: var(--muted); }
.msg-card .cr-val { font-weight: 600; text-align: right; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

/* Composer */
.agent-composer { border-top: 1px solid var(--line); background: var(--panel); padding: var(--space-3) var(--space-5) var(--space-4); }
.agent-chips { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: var(--space-3); }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; transition: all var(--dur) var(--ease); white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.agent-input { display: flex; align-items: flex-end; gap: 10px; }
.agent-input textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; font: inherit;
  font-size: 14px; resize: none; min-height: 46px; max-height: 140px; line-height: 1.4; background: var(--bg);
}
.agent-input textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.send-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.send-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.send-btn:active { transform: translateY(0); }
.send-btn:disabled { opacity: .5; cursor: default; }

@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Family (shared wife-safe view) ---------- */
.family-domain { max-width: none; padding: 0; min-height: 100vh; background: var(--bg); }

.family-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: var(--space-3) var(--space-6); background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1100;
}
.logout-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; text-decoration: none; cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

.family-body {
  max-width: 960px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-8);
  display: flex; flex-direction: column; gap: var(--space-5);
}
.family-section-title {
  margin: 0 0 var(--space-3); font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); font-weight: 600;
}

.family-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }
.fam-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--space-4); }
.fam-card-head { font-size: 13px; font-weight: 700; margin-bottom: var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.fam-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; }
.fam-row span { color: var(--muted); }
.fam-row strong { text-align: right; font-weight: 600; }

.fam-add { display: flex; flex-direction: column; gap: var(--space-2); }
.fam-add input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; }
.fam-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fam-add-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fam-add-msg { font-size: 12px; color: var(--good); }

.family-chatbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column;
}
.family-chatbox .agent-thread { height: 420px; padding: var(--space-4); }
.family-chatbox .agent-composer { border-top: 1px solid var(--line); }

/* ---------- Login ---------- */
.login-body {
  margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #eef4ff 0%, var(--bg) 55%);
  padding: var(--space-4);
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: var(--space-7); width: min(380px, 100%);
  text-align: center; animation: msg-in var(--dur-slow) var(--ease);
}
.login-mark { margin: 0 auto var(--space-4); width: 48px; height: 48px; border-radius: 14px; }
.login-card h1 { margin: 0 0 var(--space-1); font-size: 24px; letter-spacing: -0.02em; }
.login-sub { margin: 0 0 var(--space-5); color: var(--muted); font-size: 14px; }
.login-label { display: block; text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.login-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font: inherit; font-size: 15px; margin-bottom: var(--space-3);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { color: var(--danger); font-size: 13px; margin: 0 0 var(--space-2); }
.login-btn { width: 100%; padding: 11px; border-radius: 10px; font-size: 15px; font-weight: 600; }
