:root {
  color-scheme: light only;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-subtle: #e2e8f0;
  --bg-inverse: #0f172a;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-muted: #cbd5e1;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --accent: #0f172a;
  --accent-soft: #f1f5f9;
  --income: #f43f5e;
  --income-soft: #fff1f2;
  --expense: #10b981;
  --expense-soft: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-2xl: 28px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
}

/* ── Top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: calc(16px + var(--safe-top)) 24px 20px;
  background: rgba(248, 250, 252, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: none;
}

.topbar-label, .sheet-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.topbar h1, .sheet-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.sheet-head h2 { font-size: 22px; }

.topbar-stat {
  text-align: right;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: none;
  box-shadow: var(--shadow-sm);
  min-width: 88px;
}

.topbar-stat .stat-k {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.topbar-stat .stat-v {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.topbar-auth-btn {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.topbar-auth-btn:active { transform: scale(0.97); }

/* ── Main ── */
#main-content {
  padding: 4px 20px calc(112px + var(--safe-bottom));
}

.view-enter {
  animation: viewIn .35s cubic-bezier(.22, 1, .36, 1) both;
}

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

/* ── Balance hero (overview) ── */
.balance-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  padding: 24px 22px 20px;
  border-radius: var(--radius-2xl);
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 52%, #0f172a 100%);
  color: #f8fafc;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
}

.balance-hero-glow {
  position: absolute;
  top: -40px;
  right: -30px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
  pointer-events: none;
}

.balance-hero-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.balance-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.balance-hero-icon svg { width: 22px; height: 22px; }

.balance-hero-k {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e2e8f0;
}

.balance-hero-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.55);
}

.balance-hero-main {
  position: relative;
  margin-top: 22px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.balance-hero-num {
  font-size: clamp(48px, 12vw, 56px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
}

.balance-hero-unit {
  font-size: 22px;
  font-weight: 700;
  color: rgba(248, 250, 252, 0.72);
  letter-spacing: -0.02em;
}

.balance-hero-yuan {
  position: relative;
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: rgba(226, 232, 240, 0.62);
  font-variant-numeric: tabular-nums;
}

.balance-hero-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.balance-hero-stat {
  padding: 10px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
}

.balance-hero-stat-k {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(226, 232, 240, 0.55);
  white-space: nowrap;
}

.balance-hero-stat-v {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance-hero-stat.income .balance-hero-stat-v { color: #fb7185; }
.balance-hero-stat.expense .balance-hero-stat-v { color: #34d399; }
.balance-hero-stat.up .balance-hero-stat-v { color: #34d399; }
.balance-hero-stat.down .balance-hero-stat-v { color: #fb7185; }

/* ── Bento dashboard ── */
.bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.bento-card {
  border-radius: var(--radius-xl);
  padding: 20px;
  border: none;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.bento-card.hero {
  grid-column: 1 / -1;
  padding: 28px 24px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.bento-card.hero .k {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.bento-card.hero .v {
  margin-top: 10px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.bento-card.hero .s {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.bento-card .k {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.bento-card .v {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.bento-card.income .v { color: var(--income); }
.bento-card.expense .v { color: var(--expense); }

/* ── Surfaces ── */
.surface, .panel {
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-xl);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.surface-flush {
  padding: 12px;
}

.surface-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.surface-desc {
  margin: 6px 0 18px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.55;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 2px 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.section-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ── Transaction list ── */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: var(--radius-lg);
  border: none;
  transition: background-color 0.2s ease;
}

@media (hover: hover) {
  .tx-row:hover { background: #f8fafc; }
}

.tx-row:active { background: #f1f5f9; }

.tx-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.tx-main { flex: 1; min-width: 0; }

.tx-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tx-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.chip-type {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.chip-type.income { background: var(--income-soft); color: var(--income); }
.chip-type.expense { background: var(--expense-soft); color: var(--expense); }

.tx-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.tx-amt {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tx-amt.income { color: var(--income); }
.tx-amt.expense { color: var(--expense); }

.btn-text {
  border: 0;
  background: none;
  padding: 0;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.2s ease;
  font-family: inherit;
}

.btn-text:hover { color: var(--text-secondary); }

.tx-actions {
  display: flex;
  gap: 14px;
  margin-top: 8px;
}

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

/* ── Category chips ── */
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.cat-chip-pick {
  border: none;
  background: var(--bg-muted);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.cat-chip-pick:hover { background: var(--bg-subtle); }

.cat-chip-pick:active {
  background: var(--accent);
  color: #fff;
}

.cat-manage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  min-height: 32px;
}

.cat-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 14px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: none;
  font-size: 13px;
  font-weight: 500;
}

.cat-chip-del {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.cat-chip-del:active {
  background: var(--expense-soft);
  color: var(--expense);
}

.cat-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.cat-add-row input {
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font-size: 15px;
  background: var(--bg-muted);
  color: var(--text);
  font-family: inherit;
}

.cat-add-row input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.cat-add-btn {
  width: auto;
  padding: 12px 18px;
  white-space: nowrap;
}

.reminder-summary {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.reminder-help,
.account-hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-tertiary);
}

#reminder-panel[hidden] { display: none; }

#reminder-weekly-field[hidden],
#reminder-monthly-field[hidden] { display: none; }

/* ── Empty ── */
.empty {
  text-align: center;
  padding: 56px 28px;
}

.empty-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}

.empty-mark svg { width: 22px; height: 22px; }

.empty h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.empty p {
  margin: 0;
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

/* ── Controls ── */
.segment, .ctrl-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  border: none;
  margin-bottom: 16px;
}

.segment-item { flex: 1; position: relative; }
.segment-item input { position: absolute; opacity: 0; pointer-events: none; }

.segment-item span {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  transition: all 0.2s ease;
}

.segment-item input:checked + span {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.ctrl-btn {
  flex: 1;
  border: 0;
  background: none;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ctrl-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.ctrl-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  border: none;
  scrollbar-width: none;
}

.ctrl-scroll::-webkit-scrollbar { display: none; }

.ctrl-btn--pill {
  flex: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  white-space: nowrap;
}

.ctrl-scroll .ctrl-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

/* ── Balance ── */
.metric-hero {
  text-align: center;
  padding: 12px 0 8px;
  margin-bottom: 8px;
}

.metric-hero .k {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.metric-hero .v {
  margin-top: 10px;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.metric-hero .s {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.period-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.metric-box {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
}

.metric-box .k {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.metric-box .v {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--text);
}

.metric-box .s {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.flow-tags {
  display: flex;
  gap: 8px;
}

.flow-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.flow-tag.in { background: var(--income-soft); color: var(--income); }
.flow-tag.out { background: var(--expense-soft); color: var(--expense); }
.flow-tag svg { width: 12px; height: 12px; }

/* ── Balance stats ── */
.balance-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.balance-stat-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  border: none;
}

.balance-stat-card.highlight {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.balance-stat-card.highlight .k { color: rgba(255, 255, 255, 0.65); }
.balance-stat-card.highlight .s { color: rgba(255, 255, 255, 0.5); }
.balance-stat-card.highlight .v { color: #fff; }

.balance-stat-card.net {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
}

.balance-stat-card .k {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.balance-stat-card .v {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--text);
}

.balance-stat-card .v.income { color: var(--income); }
.balance-stat-card .v.expense { color: var(--expense); }
.balance-stat-card .v.up { color: var(--income); }
.balance-stat-card .v.down { color: var(--expense); }

.balance-stat-card .s {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.trend-range-scroll { margin-bottom: 14px; }

.balance-chart-box {
  position: relative;
  height: 220px;
  margin-top: 8px;
}

.balance-period-row {
  padding: 14px 12px;
  border-radius: var(--radius-lg);
  border: none;
  transition: background-color 0.2s ease;
}

.balance-period-row + .balance-period-row {
  margin-top: 4px;
}

.balance-period-row.active {
  background: var(--bg-muted);
}

.balance-period-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.balance-period-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.balance-period-net {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.balance-period-net.up { color: var(--income); }
.balance-period-net.down { color: var(--expense); }

.balance-period-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ── Chart / stats ── */
.chart-wrap {
  position: relative;
  margin: 12px 0 20px;
}

.chart-box {
  position: relative;
  height: 280px;
}

.chart-center-btn {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  border-radius: 50%;
  margin: 18%;
  transition: background-color 0.2s ease;
}

.chart-center-btn:hover { background: rgba(248, 250, 252, 0.8); }
.chart-center-btn:active { background: rgba(241, 245, 249, 0.9); }

.chart-center-btn .chart-center-k,
.chart-center-btn .chart-center-v,
.chart-center-btn .chart-center-hint { pointer-events: none; }

.chart-center-hint {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.stat-detail-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.stat-item-clickable {
  width: calc(100% + 16px);
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background-color 0.2s ease;
  border-radius: var(--radius-lg);
  margin: 0 -8px;
  padding: 14px 12px;
}

.stat-item-clickable:hover { background: #f8fafc; }
.stat-item-clickable:active { background: #f1f5f9; }

.balance-stat-clickable {
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.15s ease, opacity 0.15s ease;
  border: none;
}

.balance-stat-clickable:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.balance-period-clickable {
  cursor: pointer;
}

.balance-period-clickable:hover { background: #f8fafc; }

#stat-detail-list .tx-list { margin-bottom: 0; }

.chart-center-k {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.chart-center-v {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border: none;
}

.stat-item + .stat-item {
  border-top: 1px solid var(--border);
}

.stat-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.stat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-info { flex: 1; min-width: 0; }

.stat-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
}

.stat-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}

.stat-progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.stat-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-right strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.stat-right small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ── Settings ── */
.setting-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.setting-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-muted);
  border: none;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.setting-icon svg { width: 18px; height: 18px; color: var(--text-secondary); }

.setting-body { flex: 1; min-width: 0; }

.setting-body h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.setting-body p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.55;
}

/* ── Form ── */
.field { display: block; margin-bottom: 16px; }

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.field input, .field select, textarea {
  width: 100%;
  border: none;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-muted);
  color: var(--text);
  transition: box-shadow 0.2s ease;
  font-family: inherit;
}

.field input:focus, .field select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
  background: var(--bg-elevated);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.switch-field { margin-bottom: 16px; }

.amount-input {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--bg-muted);
}

.amount-input input {
  border: 0;
  padding: 0;
  flex: 1;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  background: transparent;
}

.amount-input input:focus { outline: none; box-shadow: none; }

.amount-input span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.field-hint {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.switch {
  position: relative;
  display: inline-flex;
}

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch i {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--bg-subtle);
  transition: background 0.2s;
  position: relative;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

.option-list { margin: 14px 0; }

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.option:last-child { border-bottom: 0; }

.preview {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  border: none;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.preview:empty { display: none; }

.format-help {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.format-help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.format-help pre {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  border: none;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 15px 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.2s ease;
  font-family: inherit;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text);
  border: none;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row .btn-full { grid-column: 1 / -1; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--bg-muted);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.icon-btn:hover { background: var(--bg-subtle); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── Dock + FAB ── */
.dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom));
  width: min(390px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  border: none;
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.dock-item {
  border: 0;
  background: none;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  border-radius: 16px;
  font-size: 10px;
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
  font-family: inherit;
}

.dock-item svg { width: 20px; height: 20px; }

.dock-item.active {
  color: var(--text);
  background: var(--bg-muted);
}

.fab {
  position: fixed;
  right: max(20px, calc(50% - 198px));
  bottom: calc(88px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
  z-index: 45;
}

.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.94); }

/* ── Sheet modal ── */
.sheet {
  border: 0;
  padding: 0;
  width: min(430px, 100%);
  max-height: 100dvh;
  background: transparent;
  margin: 0 auto;
}

.sheet[open] {
  display: flex;
  align-items: flex-end;
}

.sheet::backdrop {
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(4px);
}

.sheet-panel {
  width: 100%;
  max-height: 92dvh;
  overflow: auto;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  background: var(--bg);
  border: none;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.08);
}

.sheet-grabber {
  width: 40px;
  height: 4px;
  margin: 6px auto 16px;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 431px) {
  .sheet { border-radius: var(--radius-2xl); align-items: center; }
  .sheet-panel { border-radius: var(--radius-2xl); max-height: 88dvh; }
}
