:root {
  --paper:#FAF3E6; --card:#FFFDF8; --ink:#1E3278; --ink-2:#56628F; --line:#E8DFCC;
  --red:#EC542B; --red-text:#C2401B; --yellow:#F2B93B; --misreg:rgba(236,84,43,.35);
  --chip:#FFFDF8;
  --num: ui-rounded, "SF Pro Rounded", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --txt: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --r:16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:#141A33; --card:#1C2444; --ink:#F3EDE0; --ink-2:#A5ACC8; --line:#2E3760;
    --red:#FF7A55; --red-text:#FF8F6F; --misreg:rgba(255,122,85,.3); --chip:#FFFDF8;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--txt);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
img { display: block; max-width: 100%; }
a { color: var(--ink); }
h1, h2, h3, p { margin: 0; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.shell {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 88px);
}

.page,
.page-today,
.page-ledger,
.page-funds,
.page-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  font-family: var(--num);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.section-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.section-total {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.date-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-2);
  font-family: var(--num);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.hero-left { gap: 4px; }

.hero-number {
  font-family: var(--num);
  font-size: clamp(52px, 17vw, 64px);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-shadow: 2px 2px 0 var(--misreg);
}

.hero-number.is-red { color: var(--red); }

.hero-meta {
  color: var(--ink-2);
  font-family: var(--num);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hero-insight {
  margin-top: 5px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.bar-thin { height: 4px; }

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.bar-fill.is-red { background: var(--red); }

.entry-form { width: 100%; }

.entry-box {
  padding: 8px 8px 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}

.entry-box:focus-within { border: 1.5px solid var(--ink); }

.entry-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.entry-input::placeholder { color: var(--ink-2); opacity: .8; }

.entry-input:focus {
  outline: none;
  outline-offset: 0;
}

.entry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 600;
}

.entry-btn:disabled { opacity: .45; cursor: default; }

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}

.muted {
  color: var(--ink-2);
  font-size: 13px;
}

.fine-print {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
}

.tx-card { padding: 4px 14px; }

.tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.tx-row:last-child { border-bottom: 0; }

.sticker {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--chip);
}

.sticker img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.tx-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tx-name {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-sub {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-amount {
  flex: 0 0 auto;
  font-family: var(--num);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px 12px;
  border: 0;
  background: transparent;
}

.empty-illustration {
  width: 200px;
  height: auto;
}

.distribution-card { display: flex; flex-direction: column; gap: 4px; }

.dist-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px 38px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.dist-name { font-size: 14px; }

.mini-bar {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.mini-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.dist-amount {
  font-family: var(--num);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.dist-pct {
  color: var(--ink-2);
  font-family: var(--num);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.monitor-section { display: flex; flex-direction: column; gap: 6px; }

.monitor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.monitor-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 10px 3px;
}

.monitor-cell + .monitor-cell { border-left: 1px solid var(--line); }

.monitor-label {
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

.monitor-value {
  font-family: var(--num);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
  white-space: nowrap;
}

.monitor-value.is-red { color: var(--red-text); }

.monitor-target {
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

.banner {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
}

.banner-text { flex: 1; min-width: 0; }

.banner-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
}

.banner-red { border-color: var(--red-text); }
.banner-red .banner-text { color: var(--red-text); }

.banner-close { flex: 0 0 44px; }

.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.text-btn.is-red { color: var(--red-text); }
.text-btn:disabled { opacity: .45; cursor: default; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-btn.is-danger { color: var(--red-text); }

.icon { display: inline-flex; align-items: center; justify-content: center; }

.page-error { color: var(--red-text); font-size: 14px; }

.ledger-pool { display: flex; flex-direction: column; gap: 8px; }

.segment-bar {
  display: flex;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.segment-free { display: block; height: 100%; background: var(--ink); }
.segment-fund { display: block; height: 100%; background: var(--ink); opacity: .35; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--ink-2);
  font-size: 13px;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; }

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.legend-dot.is-fund { opacity: .35; }

.pool-total {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.list-card { padding: 2px 14px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.list-row:last-child { border-bottom: 0; }
.list-row.is-static { cursor: default; }

.list-label {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  font-size: 15px;
}

.list-sub { color: var(--ink-2); font-size: 13px; }

.list-value {
  font-family: var(--num);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.list-chevron { display: inline-flex; color: var(--ink-2); }

.goal-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.goal-illustration {
  flex: 0 0 96px;
  width: 96px;
  height: auto;
}

.goal-copy { display: flex; flex-direction: column; gap: 6px; }

.goal-title {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-self: flex-start;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
}

.spent-card { display: flex; flex-direction: column; }

.spent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.spent-row:last-child { border-bottom: 0; }

.spent-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.spent-name { font-size: 14px; }

.spent-amount {
  font-family: var(--num);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.spent-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
}

.spent-total-value {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.all-tx-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
}

.all-tx-entry > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fund-card { display: flex; flex-direction: column; gap: 4px; }

.fund-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.fund-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
}

.fund-balance {
  flex: 0 0 auto;
  font-family: var(--num);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.fund-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.fund-sub-list { padding: 0 0 8px 12px; }

.fund-sub-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  color: var(--ink-2);
  font-size: 13px;
}

.fund-sub-amount {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.new-fund { margin-top: 4px; }

.settings-card { display: flex; flex-direction: column; gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label { color: var(--ink-2); font-size: 13px; }
.field-hint { color: var(--ink-2); font-size: 13px; }

.input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
}

.input:focus {
  border: 1.5px solid var(--ink);
  outline: none;
  outline-offset: 0;
}

.input.is-error { border-color: var(--red); }

.input-prefix {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding-left: 11px;
}

.input-prefix:focus-within { border: 1.5px solid var(--ink); }

.input-prefix .input {
  border: 0;
  background: transparent;
  padding-left: 4px;
}

.static-value {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 16px;
}

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.btn:disabled { opacity: .45; cursor: default; }

.btn-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.btn-ghost { background: transparent; }

.btn-danger {
  border-color: var(--red);
  background: var(--red);
  color: var(--paper);
}

.full-width { width: 100%; }

.form-status {
  min-height: 18px;
  color: var(--ink-2);
  font-size: 13px;
}

.form-status:empty { display: none; }

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.tab {
  position: relative;
  display: flex;
  flex: 0 0 25%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  max-width: 107.5px;
  min-height: 56px;
  padding-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
  text-decoration: none;
}

.tab.is-active { color: var(--ink); font-weight: 600; }

.tab-icon { display: inline-flex; }

.tab-dot {
  width: 4px;
  height: 4px;
  margin-top: 1px;
  border-radius: 50%;
  background: transparent;
}

.tab.is-active .tab-dot { background: var(--red); }

.toast-root {
  position: fixed;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 68px);
  left: 0;
  z-index: 70;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 398px;
  min-height: 48px;
  padding: 4px 6px 4px 12px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  pointer-events: auto;
  animation: toastIn 180ms ease-out;
}

.toast-text { flex: 1; min-width: 0; }
.toast-actions { display: flex; gap: 2px; }

.toast-action {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--yellow);
  font-size: 14px;
  font-weight: 700;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30, 50, 120, .28);
  animation: fadeIn 160ms ease-out;
}

.sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  max-height: 92vh;
  max-height: 92dvh;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 12px);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  background: var(--card);
  box-shadow: 0 -8px 30px rgba(30, 50, 120, .16);
  animation: sheetUp 220ms cubic-bezier(.2, .8, .2, 1);
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0 8px;
  background: var(--card);
}

.sheet-heading { min-width: 0; }

.sheet-title {
  font-family: var(--num);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.sheet-title:focus { outline: none; }

.sheet-subtitle { margin-top: 2px; color: var(--ink-2); font-size: 13px; }

.sheet-close { flex: 0 0 44px; }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.sheet-actions .btn { flex: 1; }
.sheet-actions-split { justify-content: space-between; }

.dialog-stack { display: flex; flex-direction: column; gap: 12px; }

.dialog-note {
  padding-left: 8px;
  border-left: 2px solid var(--yellow);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
}

.confirm-text { font-size: 16px; line-height: 1.6; }

.entry-rows { display: flex; flex-direction: column; }

.entry-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.entry-item:last-child { border-bottom: 0; }

.entry-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-name {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.entry-name::placeholder { color: var(--ink-2); }
.entry-name:focus {
  border-bottom: 1.5px solid var(--ink);
  outline: none;
  outline-offset: 0;
}

.entry-amount {
  display: flex;
  flex: 0 0 96px;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
  border-bottom: 1px solid transparent;
}

.entry-amount:focus-within { border-bottom: 1.5px solid var(--ink); }

.entry-amount-mark {
  color: var(--ink-2);
  font-family: var(--num);
  font-size: 14px;
}

.entry-amount-input {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--num);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.entry-amount-input:focus {
  outline: none;
  outline-offset: 0;
}

.entry-amount-input.is-error { color: var(--red-text); }

.entry-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
}

.entry-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

.entry-pill .pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-pill.is-fund {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.entry-pill:focus-within { border-color: var(--ink); border-width: 1.5px; }
.entry-pill.is-fund:focus-within { border-color: var(--paper); }

.pill-control:focus-visible {
  outline: none;
  outline-offset: 0;
}

.entry-pill-category,
.entry-pill-date { flex-shrink: 0; }

.entry-pill-fund { flex-shrink: 1; }

.pill-control {
  position: absolute;
  top: -5px;
  right: 0;
  bottom: -5px;
  left: 0;
  z-index: 1;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  font-size: 16px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.entry-delete {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin-left: auto;
}

.add-row {
  align-self: flex-start;
  width: auto;
  margin-left: 4px;
  padding-left: 4px;
}

.sheet-entry .sheet-body { padding-bottom: 0; }
.sheet-entry .sheet-actions { flex: 0 0 auto; }

.report-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.report-section:last-child { padding-bottom: 0; border-bottom: 0; }

.report-title {
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 600;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.kv-label { color: var(--ink-2); }

.kv-value {
  font-family: var(--num);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.kv-value.is-red { color: var(--red-text); }

.sheet-tall { max-height: 92dvh; }

.tx-group { display: flex; flex-direction: column; }

.tx-group-date {
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
}

.install-guide {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--paper);
}

.install-card {
  width: 100%;
  max-width: 360px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
}

.install-mark {
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: .08em;
}

.install-title {
  margin-top: 6px;
  font-family: var(--num);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.install-step { display: flex; gap: 12px; }

.install-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--num);
  font-size: 14px;
  font-weight: 700;
}

.install-step-main { min-width: 0; }
.install-step-main h2 { font-size: 16px; font-weight: 600; }
.install-step-main p { margin-top: 2px; color: var(--ink-2); font-size: 14px; }

.install-share-icon {
  display: inline-flex;
  margin-top: 8px;
  color: var(--ink);
}

.install-warn {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--red-text);
  font-size: 13px;
  line-height: 1.6;
}

.install-wechat-icon {
  display: flex;
  justify-content: center;
  color: var(--ink);
}

.hidden { display: none !important; }

.copy-area {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

noscript {
  display: block;
  padding: 24px 16px;
  color: var(--ink-2);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes toastIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  .overlay { background: rgba(20, 26, 51, .58); }
  .sheet { box-shadow: 0 -8px 30px rgba(20, 26, 51, .55); }
  .toast-action { color: var(--red-text); }
  .empty-illustration,
  .chat-empty-image,
  .onboarding-goal,
  .goal-illustration {
    padding: 10px;
    border-radius: var(--r);
    background: var(--chip);
  }
}

@media (max-width: 359px) {
  .dist-row { grid-template-columns: 58px minmax(0, 1fr) 58px 36px; gap: 6px; }
  .form-grid.two { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 今天的对话入口 */
.chat-teasers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: -8px;
}

.chat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 0;
  scrollbar-width: none;
}

.chat-chips::-webkit-scrollbar { display: none; }

.chat-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

.chat-last {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
}

.chat-last-prefix { flex: 0 0 auto; color: var(--ink-2); }
.chat-last-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 全屏对话面板 */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

.chat-panel.is-open {
  display: flex;
  animation: chatUp 220ms cubic-bezier(.2, .8, .2, 1);
}

.chat-top {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: calc(env(safe-area-inset-top) + 4px) 12px 4px;
  border-bottom: 1px solid var(--line);
}

.chat-icon-btn { flex: 0 0 44px; }

.chat-money {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--num);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-money.is-red { color: var(--red-text); }

.chat-first-notice {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  padding: 9px 4px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.chat-first-notice p { flex: 1; min-width: 0; }
.chat-first-notice .icon-btn { flex: 0 0 44px; width: 44px; height: 44px; }

.chat-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 12px 16px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-row { display: flex; min-width: 0; }
.chat-row.is-user { justify-content: flex-end; }
.chat-row.is-assistant { justify-content: flex-start; }

.chat-row.is-streaming {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.chat-user-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-assistant-text {
  max-width: 100%;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-tool-status {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
}

.chat-tool-status:empty { display: none; }

.chat-empty {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
  padding: 12px 0;
  text-align: center;
}

.chat-empty-image { width: 160px; height: auto; }

.chat-empty-text {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
}

.chat-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.chat-note-line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.chat-note-text { flex: 0 1 auto; min-width: 0; }

.chat-memory {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.chat-memory-text { min-width: 0; overflow-wrap: anywhere; }
.chat-memory .text-btn { color: var(--ink-2); }

.chat-error {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  color: var(--red-text);
  font-size: 13px;
  line-height: 1.5;
}

.chat-error-text { flex: 0 1 auto; min-width: 0; }
.chat-error .text-btn { color: var(--red-text); }

.chat-composer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  outline: 0;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
}

.chat-input:focus {
  border: 1.5px solid var(--ink);
  outline: none;
  outline-offset: 0;
}

.chat-input:disabled { opacity: .6; }

.chat-send {
  flex: 0 0 auto;
  min-width: 56px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 22px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
}

.chat-send.is-stop {
  background: transparent;
  color: var(--ink);
}

.chat-send:disabled {
  opacity: .55;
  cursor: default;
}

/* 右上角菜单 */
.chat-menu-backdrop {
  position: absolute;
  inset: 0;
  z-index: 11;
  background: transparent;
}

.chat-menu {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 50px);
  right: 16px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.chat-menu[hidden],
.chat-menu-backdrop[hidden] { display: none; }

.chat-menu-item {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  text-align: left;
}

/* 提案卡片 */
.chat-proposal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.chat-proposal-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.chat-proposal-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-proposal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 0;
}

.chat-proposal-row.is-muted { opacity: .62; }

.chat-proposal-row .sticker { flex: 0 0 40px; }

.chat-proposal-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chat-proposal-name {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.chat-proposal-fund {
  align-self: flex-start;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.4;
}

.chat-proposal-amount {
  flex: 0 0 auto;
  font-family: var(--num);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat-proposal-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
}

.chat-proposal-total span:last-child {
  color: var(--ink);
  font-family: var(--num);
  font-size: 15px;
  font-weight: 600;
}

.chat-proposal-arrow {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1;
  padding-left: 14px;
}

.chat-proposal-note {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.chat-proposal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.chat-proposal-actions .btn {
  min-height: 44px;
  padding: 0 16px;
}

.chat-proposal-resolved {
  padding: 2px 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.chat-proposal-resolved.is-muted { opacity: .62; }
.chat-proposal-resolved.is-failed { color: var(--red-text); }
.chat-proposal-missing { color: var(--ink-2); font-size: 13px; }

@keyframes chatUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 设置里的智能助手 */
.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.mode-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--ink);
  font-size: 16px;
}

.mode-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ink);
}

.settings-subtitle {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
}

.agent-memories {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.agent-memory {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}

.agent-memory-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.4;
}

.agent-memory-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.5;
}

.memory-add {
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-add .input { flex: 1; }

.text-btn.is-muted { color: var(--ink-2); }

/* 首次启动 */
.onboarding {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--paper);
}

.onboarding-goal {
  width: 160px;
  height: auto;
  margin: 0 auto;
}

.onboarding-title {
  font-family: var(--num);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.onboarding-methods {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.onboarding-block,
.onboarding-actions,
.onboarding-blank {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding-label {
  font-size: 15px;
  font-weight: 600;
}

.onboarding-textarea {
  min-height: 96px;
  resize: vertical;
}

.onboarding-blank-toggle {
  align-self: flex-start;
  padding-left: 0;
  padding-right: 0;
  color: var(--ink-2);
}

.onboarding-blank-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}

.onboarding-blank-form[hidden] { display: none; }

.onboarding-error {
  color: var(--red-text);
  font-size: 13px;
  line-height: 1.6;
}

.onboarding-error:empty { display: none; }
