:root {
  --paper: #f7f8f6;
  --surface: #ffffff;
  --ink: #1f2824;
  --muted: #657068;
  --line: #e2e6e1;
  --green: #24624c;
  --green-soft: #e9f1ed;
  --coral: #e56b4a;
  --yellow: #f0c75e;
  --blue: #477c8f;
  --danger: #a94438;
  --shadow: 0 18px 48px rgba(31, 40, 36, 0.1);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(71, 124, 143, 0.35);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

.rail {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  height: 72px;
  padding: 0 clamp(28px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 20px;
  font-weight: 800;
}

.rail-nav { display: flex; gap: 4px; margin: 0; width: auto; }
.nav-item {
  border: 0;
  background: transparent;
  min-height: 40px;
  padding: 7px 13px;
  display: flex;
  place-items: center;
  gap: 3px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.nav-icon { font-size: 16px; line-height: 1; }
.nav-item.active { color: var(--green); background: var(--green-soft); font-weight: 700; }

.main-content { margin-left: 0; padding-top: 72px; }
.view { display: none; min-height: 100vh; padding: 58px clamp(28px, 5vw, 76px) 80px; }
.view.active { display: block; }
.view > * { max-width: 1120px; margin-left: auto; margin-right: auto; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 44px;
}

.home-header {
  margin-bottom: 14px;
}

.home-header h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.08;
  max-width: 12em;
}

.home-header #home-question {
  display: block;
}

.home-header .eyebrow {
  margin-bottom: 7px;
}

.home-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.home-meta-dot {
  color: var(--muted);
  font-weight: 500;
}

.home-meta #greeting {
  color: var(--muted);
  font-weight: 650;
  text-transform: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(34px, 4.5vw, 58px); line-height: 1.12; letter-spacing: 0; font-weight: 720; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: 0; }

.avatar-button, .icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.avatar-button { width: 44px; height: 44px; border-radius: 50%; font-weight: 800; }
.icon-button { width: 38px; height: 38px; border-radius: 8px; font-size: 26px; }

.home-grid { display: grid; grid-template-columns: 1fr; gap: 0; border-block: 1px solid var(--line); }
.spend-panel { border-radius: 0; padding: 38px 0; min-height: 220px; }
.spend-panel { background: transparent; color: var(--ink); }
.spend-topline { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.change-label { color: var(--green); }
.amount { margin: 26px 0 34px; font-size: clamp(48px, 7vw, 76px); font-weight: 760; line-height: 1; }
.today-categories { display: grid; gap: 12px; }
.today-category { display: grid; grid-template-columns: minmax(90px, 1fr) auto; align-items: center; gap: 18px; }
.today-category span { min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.today-category small { color: var(--muted); font-size: 13px; font-weight: 600; }
.today-category strong { font-size: 15px; }
.today-category.empty { display: block; color: var(--muted); font-weight: 500; }

.budget-mini {
  margin-top: 22px;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafcf9;
}

.budget-mini-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.budget-mini-topline small {
  color: var(--green);
  font-size: 13px;
  letter-spacing: .02em;
}

.budget-mini-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.budget-mini-cell {
  padding: 12px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  gap: 6px;
}

.budget-mini-cell span {
  color: var(--muted);
  font-size: 12px;
}

.budget-mini-cell strong {
  font-size: 18px;
  line-height: 1.2;
}

.budget-mini p {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 620;
}

.space-switch {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.space-switch > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.space-switch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.space-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.space-chip.active {
  border-color: transparent;
  background: var(--green-soft);
  color: var(--green);
}

.family-member-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.family-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.family-member-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 11px 12px;
}

.danger-text {
  color: var(--danger);
}

.quick-section, .today-list-section { margin-top: 52px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.text-button { border: 0; background: transparent; color: var(--green); cursor: pointer; padding: 5px 0; font-weight: 700; }
.text-button.static { cursor: default; padding-right: 0; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-block: 1px solid var(--line); }
.quick-action {
  min-height: 168px;
  padding: 24px 26px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: grid;
  align-content: space-between;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.quick-action:last-child { border-right: 0; }
.quick-action:hover { transform: none; box-shadow: none; background: var(--surface); }
.quick-action strong { font-size: 22px; }
.quick-action small { color: var(--muted); line-height: 1.5; }
.quick-action.voice {
  background: linear-gradient(180deg, rgba(233, 241, 237, 0.88), rgba(233, 241, 237, 0.58));
}
.quick-action.voice strong { font-size: 24px; }
.quick-action.voice small { color: var(--ink); }
.quick-action.photo { background: linear-gradient(180deg, rgba(226, 240, 245, 0.9), rgba(226, 240, 245, 0.55)); }
.quick-action.manual { background: linear-gradient(180deg, rgba(253, 236, 229, 0.95), rgba(253, 236, 229, 0.62)); }
.action-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 20px; font-weight: 800; }
.voice .action-icon { color: var(--green); }
.photo .action-icon { color: var(--blue); }
.manual .action-icon { color: var(--coral); }

.transaction-list { background: transparent; border-top: 1px solid var(--line); }
.transaction-row {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
}
.transaction-emoji { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 20px; background: var(--surface); }
.transaction-copy { min-width: 0; }
.transaction-copy strong, .transaction-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-copy small { color: var(--muted); margin-top: 4px; }
.transaction-amount { font-size: 18px; font-weight: 800; }
.row-actions { display: flex; gap: 3px; opacity: 0; pointer-events: none; transform: translateX(8px); transition: opacity 150ms ease, transform 150ms ease; }
.transaction-row.actions-visible .row-actions { opacity: 1; pointer-events: auto; transform: translateX(0); }
.row-actions button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; font-weight: 800; }
.empty-state { padding: 46px 18px; text-align: center; color: var(--muted); border-bottom: 1px solid var(--line); }

.primary-command, .save-button, .secondary-button, .danger-button, .listen-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}
.primary-command, .save-button { border: 1px solid var(--ink); background: var(--ink); color: var(--surface); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.danger-button { border: 1px solid #dcb8b2; background: #fff7f5; color: var(--danger); }
.listen-button {
  width: 100%;
  border: 1px solid var(--green);
  background: var(--green-soft);
  color: var(--green);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.listen-button .voice-button-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}
.listen-button.is-recording {
  background: var(--green);
  color: var(--surface);
  transform: scale(.995);
}
.listen-button.is-recording .voice-button-dot { animation: voice-pulse 900ms ease-in-out infinite; }
.listen-button.is-cancelling {
  border-color: #cf8f84;
  background: #fff3f0;
  color: var(--danger);
}
.listen-button.is-processing {
  opacity: .72;
  cursor: wait;
}
@keyframes voice-pulse {
  0%, 100% { transform: scale(.75); opacity: .55; }
  50% { transform: scale(1.35); opacity: 1; }
}

.record-summary { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); margin-bottom: 40px; }
.summary-cell { padding: 22px 18px; border-right: 1px solid var(--line); }
.summary-cell:last-child { border-right: 0; }
.summary-cell span, .summary-cell strong { display: block; }
.summary-cell span { color: var(--muted); font-size: 13px; }
.summary-cell strong { margin-top: 8px; font-size: 24px; }
.day-group { margin-bottom: 40px; }
.day-heading { display: flex; justify-content: space-between; margin-bottom: 12px; }
.day-heading h2 { font-size: 18px; }
.day-heading span { color: var(--muted); }

.insight-lead { padding: 32px 0 42px; border-block: 1px solid var(--line); }
.insight-lead p { color: var(--muted); margin-bottom: 8px; }
.insight-lead strong { display: block; font-size: clamp(48px, 8vw, 84px); line-height: 1; }
.insight-lead span { display: block; margin-top: 18px; color: var(--muted); }

.journal-stack { display: grid; gap: 42px; }
.journal-section { display: grid; gap: 0; }

.budget-lead { display: grid; gap: 18px; padding: 8px 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.budget-lead p { margin: 0; max-width: 760px; color: var(--ink); font-size: 18px; line-height: 1.65; font-weight: 620; }
.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.budget-summary-card {
  min-height: 118px;
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  align-content: space-between;
}
.budget-summary-card span { color: var(--muted); font-size: 13px; }
.budget-summary-card strong { font-size: 24px; line-height: 1.2; }
.budget-summary-card.empty strong { color: var(--muted); font-size: 20px; }
.budget-form { margin-top: 0; }
.insight-layout { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 46px; padding-top: 46px; }
.breakdown-section h2 { margin-bottom: 26px; }
.category-row { display: grid; grid-template-columns: 42px minmax(90px, 1fr) 3fr auto; gap: 14px; align-items: center; margin-bottom: 20px; }
.category-track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.category-track span { display: block; height: 100%; background: var(--green); }
.category-row small { color: var(--muted); }
.story-section { color: var(--ink); padding: 0 0 0 36px; border-left: 1px solid var(--line); border-radius: 0; min-height: 320px; display: flex; flex-direction: column; }
.finding-list { list-style: none; padding: 0; margin: 30px 0; display: grid; gap: 0; }
.finding-list li { padding: 15px 0 15px 27px; border-bottom: 1px solid var(--line); font-size: 17px; line-height: 1.55; position: relative; }
.finding-list li::before { content: "↗"; position: absolute; left: 0; color: var(--green); font-weight: 800; }
.story-note { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.story-note span { color: var(--muted); }

.memory-lead { padding: 28px 0 36px; border-block: 1px solid var(--line); }
.memory-lead p { max-width: 760px; margin-bottom: 18px; color: var(--ink); font-size: 18px; line-height: 1.7; font-weight: 620; }
.memory-overview { margin-top: 34px; }
.memory-section-heading { margin-bottom: 18px; }
.memory-detail-section {
  margin-top: 48px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}
.memory-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 6px 0 30px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfa;
}
.memory-range-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, auto));
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #eef1ed;
}
.memory-range-button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.memory-range-button.active {
  background: var(--surface);
  color: var(--green);
  box-shadow: 0 1px 5px rgba(24, 42, 35, 0.08);
}
.memory-period-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.memory-period-nav strong {
  min-width: 130px;
  text-align: center;
  font-size: 16px;
}
.memory-period-nav button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
.memory-detail-block { margin-top: 30px; }
.memory-detail-block + .memory-detail-block {
  margin-top: 40px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}
.memory-detail-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.memory-detail-block-head h3 { margin: 0; }
.memory-detail-block-head span { color: var(--muted); font-size: 13px; }
.memory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line);
}
.memory-stats article {
  min-height: 134px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: space-between;
}
.memory-stats article:last-child { border-right: 0; }
.memory-stats span, .memory-stats small { color: var(--muted); }
.memory-stats strong { font-size: clamp(20px, 2.3vw, 30px); }
.memory-stats small { font-size: 12px; line-height: 1.5; }

.memory-spotlight { margin-top: 34px; }
.memory-feature {
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfa, #f7faf6);
  display: grid;
  gap: 12px;
}
.memory-feature-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.memory-feature strong {
  font-size: 22px;
  line-height: 1.5;
}
.memory-feature p {
  margin: 0;
  color: var(--ink);
  line-height: 1.7;
  font-weight: 620;
}
.memory-feature small {
  color: var(--muted);
  line-height: 1.6;
}
.memory-feature-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.memory-clue-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}
.memory-clue-grid article {
  min-height: 126px;
  padding: 20px 18px;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: space-between;
}
.memory-clue-grid article:last-child { border-right: 0; }
.memory-clue-grid span, .memory-clue-grid small { color: var(--muted); }
.memory-clue-grid strong { font-size: clamp(20px, 2.3vw, 28px); }
.memory-clue-grid small { font-size: 12px; line-height: 1.5; }

.memory-section { margin-top: 44px; }
.memory-list { display: grid; gap: 14px; }
.memory-month-group { display: grid; gap: 14px; }
.memory-month-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 2px;
}
.memory-month-title strong {
  font-size: 20px;
}
.memory-month-title span {
  color: var(--muted);
  font-size: 13px;
}
.memory-card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 14px;
}
.memory-card-head { display: grid; gap: 8px; }
.memory-card-head .memory-date { color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.memory-card-head strong { font-size: 21px; line-height: 1.45; }
.memory-card-head small { color: var(--muted); line-height: 1.6; }
.memory-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.memory-card-meta strong { color: var(--ink); font-size: 18px; }
.memory-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.memory-chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.memory-chip.soft { background: #fafaf7; color: var(--muted); }

.profile-metrics { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); margin-bottom: 48px; }
.profile-metrics article { min-height: 146px; padding: 24px 20px; border-right: 1px solid var(--line); display: grid; align-content: space-between; }
.profile-metrics article:last-child { border-right: 0; }
.profile-metrics span, .profile-metrics small { color: var(--muted); }
.profile-metrics strong { font-size: clamp(20px, 2.3vw, 29px); }
.profile-metrics small { font-size: 12px; }
.profile-account-card {
  max-width: 850px;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 14px;
}
.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-size: 20px;
  font-weight: 800;
}
.profile-account-copy { min-width: 0; display: grid; gap: 5px; }
.profile-account-copy strong { font-size: 19px; }
.profile-account-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-account-action {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  cursor: pointer;
}
.profile-account-card:has(.profile-account-action:hover) { border-color: #cbd5cf; }
.profile-menu {
  max-width: 850px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}
.profile-menu-row {
  width: 100%;
  min-height: 76px;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 14px;
  text-align: left;
  cursor: pointer;
}
.profile-menu-row:last-child { border-bottom: 0; }
.profile-menu-row:hover { background: #fafbf9; }
.profile-menu-row > span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.profile-menu-row strong { font-size: 17px; }
.profile-menu-row small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.profile-menu-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
}
.profile-menu-icon.family { color: var(--green); background: var(--green-soft); }
.profile-menu-icon.settings { color: var(--blue); background: rgba(71, 124, 143, 0.11); }
.profile-menu-chevron { color: var(--muted); font-size: 26px; text-align: right; }
.profile-settings-dialog { width: min(720px, calc(100vw - 28px)); }
.profile-settings-dialog .settings-form { max-width: none; }
.profile-settings-save { width: 100%; margin-top: 18px; }
.account-dialog-copy { margin: -8px 0 2px; color: var(--muted); line-height: 1.65; }
.account-dialog .save-button, .account-dialog .secondary-button { width: 100%; }
.settings-form { max-width: 850px; margin-left: 0; }
.settings-section { border-top: 1px solid var(--line); padding: 28px 0 10px; margin-bottom: 26px; }
.settings-section h2 { margin-bottom: 12px; }
.account-section { border-top: 0; padding-top: 0; }
.account-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.account-card > div:first-child { display: grid; gap: 6px; }
.account-card p { color: var(--muted); max-width: 620px; }
.account-card .save-button, .account-card .secondary-button { min-height: 46px; white-space: nowrap; }
.auth-shell { display: grid; gap: 18px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 12px; background: var(--soft); }
.auth-tabs button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tabs button.active { background: var(--surface); color: var(--green); box-shadow: 0 1px 4px rgba(31, 40, 36, 0.08); }
.auth-field { display: grid; gap: 8px; font-weight: 700; }
.auth-field input { width: 100%; min-height: 54px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font: inherit; }
.auth-submit { width: 100%; min-height: 54px; margin-top: 2px; }
.budget-fixed-group { display: grid; gap: 12px; padding: 8px 0 2px; }
.setting-group-head { display: grid; gap: 4px; padding: 4px 0 2px; }
.setting-group-head strong { font-size: 15px; }
.setting-group-head small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.setting-row { min-height: 82px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.setting-row span { display: grid; gap: 5px; }
.setting-row small { color: var(--muted); }
.setting-row-controls { display: grid; gap: 10px; width: min(340px, 45%); }
.setting-row-controls input, .setting-row-controls select { width: 100%; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.setting-row input, .setting-row select {
  width: min(220px, 45%);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 11px 12px;
}
.privacy-copy { padding: 18px 0; }
.privacy-copy p { color: var(--muted); margin: 8px 0 0; }
.family-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(33, 102, 73, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.family-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green, #216649);
  box-shadow: 0 0 0 4px rgba(33, 102, 73, 0.08);
}
.family-status.empty {
  background: rgba(110, 118, 114, 0.08);
  color: var(--muted);
}
.family-status.empty::before {
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(110, 118, 114, 0.08);
}
.family-steps { display: grid; gap: 6px; padding: 8px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.family-steps span { display: block; }
.family-members-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 16px; }
.family-members-heading small { color: var(--muted); }
.settings-form > .save-button { margin-top: 12px; min-width: 140px; }

.bottom-nav { display: none; }
.mobile-brandbar { display: none; }

.entry-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.entry-dialog::backdrop { background: rgba(31, 40, 36, 0.55); }
.dialog-shell { padding: 28px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; margin-bottom: 26px; }
.dialog-header h2 { font-size: 28px; }
.entry-mode-panel { display: grid; gap: 11px; }
.entry-mode-panel.hidden, .hidden { display: none !important; }
.entry-mode-panel > label, .form-row label { font-weight: 800; }
.entry-mode-panel input, .entry-mode-panel textarea, .entry-mode-panel select {
  width: 100%; border: 1px solid var(--line); background: white; border-radius: 8px; padding: 12px;
}
.entry-mode-panel textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.voice-capture-controls, .natural-text-entry { display: grid; gap: 11px; }
.natural-text-entry label { font-weight: 800; }
.text-entry-toggle {
  width: fit-content;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}
.text-entry-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.field-help { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.5; }
.voice-status {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.voice-status[hidden] { display: none !important; }
.voice-status.is-action {
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.voice-status:disabled {
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  cursor: default;
  opacity: 1;
}
.upload-zone { min-height: 220px; border: 1px dashed var(--blue); border-radius: 8px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 24px; background: #f5fafb; text-align: center; }
.upload-icon { font-size: 38px; color: var(--blue); }
.upload-zone small { color: var(--muted); }
.photo-source-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 390px); margin-top: 14px; }
.camera-button, .gallery-button { min-height: 48px; padding: 0 14px; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 800; }
.camera-button { background: var(--ink); color: white; border: 1px solid var(--ink); }
.gallery-button { background: white; color: var(--ink); border: 1px solid var(--line); }
.receipt-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--paper); }
.receipt-preview figure { position: relative; aspect-ratio: 3 / 4; margin: 0; overflow: hidden; border-radius: 6px; background: white; }
.receipt-preview img { width: 100%; height: 100%; object-fit: cover; }
.receipt-preview figcaption { position: absolute; inset: auto 5px 5px; padding: 3px 5px; border-radius: 4px; background: rgba(31, 40, 36, 0.78); color: white; font-size: 11px; }
.amount-field { display: flex; align-items: center; border-bottom: 2px solid var(--ink); }
.amount-field span { font-size: 30px; }
.amount-field input { border: 0; font-size: 44px; font-weight: 800; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row label { display: grid; gap: 8px; }
.parse-preview { margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.preview-heading { padding: 10px 14px; background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 800; }
.preview-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.preview-row:last-child { border-bottom: 0; }
.preview-copy { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 7px 10px; }
.preview-name { font-weight: 700; }
.preview-copy small { color: var(--muted); font-size: 13px; }
.preview-actions { display: inline-flex; gap: 10px; align-items: center; }
.preview-actions .text-button { padding: 0; font-size: 13px; }
.confidence-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 8px; border: 1px solid #e8b4a5; border-radius: 999px; background: #fff5f1; color: var(--danger); font-size: 12px; font-weight: 800; line-height: 1; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 50;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: var(--surface);
  border-radius: 8px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 180ms ease;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  z-index: 51;
  transform: translate(-50%, 140%) scale(0.98);
  background: rgba(36, 98, 76, 0.96);
  color: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
  pointer-events: none;
}
.copy-toast.show {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

@media (max-width: 760px) {
  body { background: var(--surface); }
  .rail { display: none; }
  .main-content { margin-left: 0; padding-top: 0; }
  .view { padding: max(18px, env(safe-area-inset-top)) 20px calc(94px + env(safe-area-inset-bottom)); background: var(--surface); }
  .mobile-brandbar { display: flex; align-items: center; justify-content: space-between; min-height: 42px; margin-bottom: 22px; }
  .mobile-brandbar strong { display: flex; align-items: center; gap: 8px; font-size: 18px; }
  .mobile-brandbar strong span { width: 28px; height: 28px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 6px; font-size: 15px; }
  .mobile-brandbar .avatar-button { width: 38px; height: 38px; }
  .page-header { margin-bottom: 24px; align-items: center; }
  .page-header:not(.home-header) { padding-top: 8px; }
  .home-header { margin-bottom: 12px; }
  .home-header h1 { font-size: 25px; line-height: 1.12; max-width: none; }
  .home-meta { gap: 5px; }
  h1 { font-size: 25px; line-height: 1.18; }
  h2 { font-size: 18px; }
  .eyebrow { margin-bottom: 7px; font-size: 12px; }
  .home-grid, .insight-layout { grid-template-columns: 1fr; }
  .home-grid { border-block: 1px solid var(--line); }
  .spend-panel { min-height: auto; padding: 22px 0; }
  .spend-topline { font-size: 13px; }
  .amount { margin: 20px 0 24px; font-size: 50px; }
  .today-categories { gap: 10px; }
  .budget-mini { margin-top: 18px; padding: 15px 15px 14px; border-radius: 10px; }
  .budget-mini-grid { margin-top: 12px; gap: 8px; }
  .budget-mini-cell { padding: 10px 10px 9px; }
  .budget-mini-cell strong { font-size: 16px; }
  .space-switch {
    margin-top: 12px;
    padding: 10px 12px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .space-switch > span {
    flex: 0 0 auto;
    min-width: 3.5em;
    font-size: 11px;
  }
  .space-switch-actions {
    flex-wrap: nowrap;
    gap: 6px;
    margin-left: auto;
  }
  .space-chip { min-height: 30px; padding: 0 10px; font-size: 12px; }
  .family-member-row { grid-template-columns: 1fr; }
  .quick-section, .today-list-section { margin-top: 24px; }
  .section-heading { margin-bottom: 12px; }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-action {
    min-height: 112px;
    padding: 12px 8px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 6px;
  }
  .quick-action:last-child { border-right: 0; }
  .quick-action.voice { background: var(--green-soft); }
  .quick-action.photo { background: rgba(226, 240, 245, 0.92); }
  .quick-action.manual { background: rgba(253, 236, 229, 0.95); }
  .quick-action .action-icon { width: 30px; height: 30px; font-size: 14px; flex: 0 0 auto; }
  .quick-action strong, .quick-action.voice strong { font-size: 16px; line-height: 1.2; }
  .quick-action small { font-size: 10px; line-height: 1.35; }
  .journal-stack { gap: 22px; }
  .budget-lead { padding: 4px 0 16px; margin-bottom: 18px; }
  .budget-lead p { font-size: 14px; }
  .budget-summary-grid { grid-template-columns: 1fr 1fr; }
  .budget-summary-card { min-height: 86px; padding: 12px 10px; }
  .budget-summary-card strong { font-size: 17px; }
  .record-summary { grid-template-columns: 1fr; }
  .summary-cell { padding: 12px 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-cell:last-child { border-bottom: 0; }
  .summary-cell strong { font-size: 18px; }
  .transaction-row { grid-template-columns: 36px 1fr auto; min-height: 58px; padding: 8px 0; gap: 8px; }
  .transaction-emoji { width: 32px; height: 32px; font-size: 15px; }
  .transaction-copy strong { font-size: 14px; }
  .transaction-copy small { margin-top: 2px; font-size: 11px; }
  .transaction-amount { font-size: 15px; }
  .row-actions { grid-column: 2 / 4; justify-content: flex-end; margin-top: -8px; }
  .category-row { grid-template-columns: 36px 1fr auto; }
  .category-track { grid-column: 2 / 4; }
  .story-section { border-left: 0; border-top: 1px solid var(--line); padding: 28px 0 0; }
  .memory-overview { margin-top: 20px; }
  .memory-detail-section { margin-top: 30px; padding-top: 24px; }
  .memory-filter-toolbar {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 22px;
    padding: 8px;
  }
  .memory-range-switch { grid-template-columns: repeat(4, 1fr); }
  .memory-range-button { min-height: 38px; padding: 0 6px; font-size: 13px; }
  .memory-period-nav { justify-content: space-between; }
  .memory-period-nav strong { font-size: 14px; }
  .memory-detail-block { margin-top: 22px; }
  .memory-detail-block + .memory-detail-block { margin-top: 28px; padding-top: 24px; }
  .memory-detail-block-head { margin-bottom: 12px; }
  .memory-lead { padding: 16px 0 20px; }
  .memory-lead p { font-size: 14px; }
  .memory-stats { grid-template-columns: 1fr 1fr; }
  .memory-stats article { min-height: 90px; padding: 12px 10px; border-bottom: 1px solid var(--line); }
  .memory-stats article:nth-child(2) { border-right: 0; }
  .memory-stats article:nth-child(n+3) { border-bottom: 0; }
  .memory-spotlight { margin-top: 24px; }
  .memory-feature { padding: 14px 12px; }
  .memory-feature strong { font-size: 17px; }
  .memory-clue-grid { grid-template-columns: 1fr; }
  .memory-clue-grid article { min-height: 90px; border-right: 0; border-bottom: 1px solid var(--line); }
  .memory-clue-grid article:last-child { border-bottom: 0; }
  .memory-section { margin-top: 30px; }
  .memory-card { padding: 13px 12px; }
  .memory-card-head strong { font-size: 16px; }
  .memory-card-meta { align-items: flex-start; flex-direction: column; }
  .insight-lead { padding: 18px 0 22px; }
  .insight-lead strong { font-size: 44px; }
  .insight-layout { gap: 22px; padding-top: 22px; }
  .finding-list li { font-size: 14px; }
  .profile-metrics { grid-template-columns: 1fr 1fr; margin-bottom: 32px; }
  .profile-metrics article { min-height: 92px; padding: 13px 10px; border-bottom: 1px solid var(--line); }
  .profile-metrics article:nth-child(2) { border-right: 0; }
  .profile-metrics article:nth-child(n+3) { border-bottom: 0; }
  #view-profile .page-header { margin-bottom: 16px; }
  #view-profile .page-header .eyebrow { display: none; }
  #view-profile .page-header h1 { font-size: 25px; }
  #view-profile .space-switch { margin-bottom: 22px; }
  #view-profile .profile-metrics { margin-bottom: 22px; }
  #view-profile .profile-metrics article { min-height: 102px; padding: 14px 12px; }
  #view-profile .profile-metrics strong { font-size: 19px; }
  .profile-account-card { min-height: 82px; padding: 13px 14px; grid-template-columns: 46px minmax(0, 1fr) 34px; gap: 11px; }
  .profile-avatar { width: 46px; height: 46px; font-size: 18px; }
  .profile-account-copy strong { font-size: 17px; }
  .profile-account-copy p { font-size: 12px; }
  .profile-account-action { width: 34px; height: 34px; font-size: 26px; }
  .profile-menu { margin-top: 14px; }
  .profile-menu-row { min-height: 70px; padding: 10px 14px; grid-template-columns: 40px minmax(0, 1fr) 24px; gap: 11px; }
  .profile-menu-icon { width: 40px; height: 40px; }
  .setting-row { align-items: flex-start; flex-direction: column; padding: 18px 0; gap: 12px; }
  .setting-row input, .setting-row select { width: 100%; }
  .account-card { align-items: flex-start; flex-direction: column; padding: 18px 16px; }
  .account-card .inline-actions, .account-card .inline-actions button { width: 100%; }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    min-height: 68px;
    padding: 4px 8px max(4px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 254, 249, 0.96);
  }
  .bottom-nav .nav-item {
    min-height: 56px;
    padding: 5px 2px;
    display: grid;
    grid-template-rows: 22px auto;
    place-items: center;
    gap: 2px;
    font-size: 11px;
    line-height: 1.1;
  }
  .bottom-nav .nav-icon { width: 20px; height: 20px; display: grid; place-items: center; }
  .bottom-nav .nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .home-header .avatar-button { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .dialog-shell { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
  .entry-dialog {
    width: 100vw;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    border-radius: 12px 12px 0 0;
  }
  .dialog-header { margin-bottom: 20px; }
  .dialog-header h2 { font-size: 24px; }
  .entry-mode-panel textarea { min-height: 96px; }
  .upload-zone { min-height: 240px; padding: 20px 16px; }
  .photo-source-actions { grid-template-columns: 1fr; width: 100%; }
  .camera-button, .gallery-button { min-height: 52px; }
  .receipt-preview { grid-template-columns: repeat(2, 1fr); }
  .amount-field input { font-size: 40px; }
  .dialog-actions { position: sticky; bottom: 0; padding-top: 12px; background: var(--surface); }
  .dialog-actions button { flex: 1; min-height: 48px; }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); width: calc(100% - 40px); text-align: center; }
  .copy-toast { bottom: calc(130px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .view { padding-inline: 16px; }
  h1 { font-size: 24px; }
  .home-header h1 { font-size: 25px; }
  .amount { font-size: 45px; }
  .change-label { max-width: 130px; text-align: right; }
}

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