/* ==========================================================================
   家庭账本 HappyBook · 样式
   ========================================================================== */

:root {
  --brand: #f26a5a;
  --brand-soft: #ffe6e0;
  --brand-deep: #d9503f;
  --mint: #2fa48f;
  --mint-soft: #dcf5ef;
  --amber: #f2a93b;
  --violet: #8b7cf6;

  --bg: #fbf5f0;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-2: #fffaf7;
  --ink: #221b18;
  --ink-2: #6d605a;
  --ink-3: #a2968f;
  --line: rgba(60, 40, 30, 0.08);
  --line-strong: rgba(60, 40, 30, 0.14);

  --shadow-sm: 0 2px 8px -2px rgba(120, 72, 50, 0.12);
  --shadow: 0 12px 32px -16px rgba(120, 72, 50, 0.35);
  --shadow-lg: 0 24px 60px -24px rgba(120, 72, 50, 0.42);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-full: 999px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --bg-elevated: #181b21;
    --card: #1a1d24;
    --card-2: #20242c;
    --ink: #f3ece7;
    --ink-2: #b3a9a2;
    --ink-3: #7d746e;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --brand-soft: rgba(242, 106, 90, 0.18);
    --mint-soft: rgba(47, 164, 143, 0.18);
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow: 0 14px 36px -18px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 26px 60px -24px rgba(0, 0, 0, 0.9);
  }
}

:root[data-theme="dark"] {
  --bg: #101216;
  --bg-elevated: #181b21;
  --card: #1a1d24;
  --card-2: #20242c;
  --ink: #f3ece7;
  --ink-2: #b3a9a2;
  --ink-3: #7d746e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --brand-soft: rgba(242, 106, 90, 0.18);
  --mint-soft: rgba(47, 164, 143, 0.18);
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow: 0 14px 36px -18px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 26px 60px -24px rgba(0, 0, 0, 0.9);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

input:focus,
textarea:focus,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 背景装饰 */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
}

.blob-1 {
  width: 320px;
  height: 320px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(255, 154, 118, 0.55), transparent 70%);
}

.blob-2 {
  width: 280px;
  height: 280px;
  bottom: -100px;
  left: -90px;
  background: radial-gradient(circle, rgba(139, 124, 246, 0.35), transparent 70%);
}

@media (prefers-color-scheme: dark) {
  .blob {
    opacity: 0.28;
  }
}

/* 启动画面 */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  z-index: 50;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s;
}

.boot.hide {
  opacity: 0;
  visibility: hidden;
}

.boot-logo {
  font-size: 52px;
  animation: breathe 1.8s ease-in-out infinite;
}

.boot-text {
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.08em;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* 应用框架 */
.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
}

@media (min-width: 900px) {
  body {
    background:
      radial-gradient(1200px 600px at 15% -10%, rgba(255, 200, 170, 0.5), transparent 60%),
      radial-gradient(900px 500px at 110% 20%, rgba(180, 170, 255, 0.35), transparent 60%),
      var(--bg);
  }

  .app {
    max-width: 620px;
    padding-top: 8px;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) 18px 10px;
  background: linear-gradient(var(--bg) 62%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.topbar-month {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
}

.topbar-month .chev {
  color: var(--ink-3);
  font-size: 11px;
}

.avatars {
  display: flex;
  align-items: center;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--card);
  border: 2px solid var(--card);
  box-shadow: var(--shadow-sm);
  margin-left: -8px;
}

.avatar:first-child {
  margin-left: 0;
}

.avatar.me {
  border-color: var(--brand);
}

.view {
  flex: 1;
  padding: 4px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: viewIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* 通用卡片 */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--ink);
}

.card-title .sub {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-3);
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  padding: 4px 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-label .link {
  font-weight: 500;
  color: var(--brand);
  font-size: 12px;
}

/* 首页总览 */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #ff8a72, #f2604f 55%, #e04f6b);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 22px 20px 18px;
  box-shadow: 0 18px 40px -22px rgba(224, 79, 107, 0.9);
}

.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  top: -110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.hero::before {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  right: 40px;
  bottom: -90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.85;
  font-weight: 600;
}

.hero-amount {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 4px;
  position: relative;
  z-index: 1;
}

.hero-amount .cur {
  font-size: 20px;
  font-weight: 600;
  opacity: 0.9;
}

.hero-amount .num {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hero-amount .dec {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.85;
}

.hero-meta {
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  opacity: 0.92;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

.hero-meta b {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.hero-budget {
  margin-top: 14px;
  position: relative;
  z-index: 1;
}

.budget-track {
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  border-radius: 99px;
  background: #fff;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.budget-fill.over {
  background: #ffe08a;
}

.budget-text {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-top: 6px;
  opacity: 0.92;
}

/* 语音主按钮 */
.talk-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

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

.talk-title {
  font-weight: 700;
  font-size: 15px;
}

.talk-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 3px;
  line-height: 1.5;
  white-space: pre-line;
}

.mic {
  position: relative;
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff9276, #ef5a4b);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px -8px rgba(239, 90, 75, 0.75);
  transition: transform 0.18s ease, box-shadow 0.2s;
}

.mic:active {
  transform: scale(0.94);
}

.mic svg {
  width: 28px;
  height: 28px;
}

.mic.recording {
  background: linear-gradient(145deg, #ff5a4a, #d63b2f);
}

.mic.recording::before,
.mic.recording::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(239, 90, 75, 0.55);
  animation: ripple 1.8s ease-out infinite;
}

.mic.recording::after {
  animation-delay: 0.9s;
}

.mic.recording svg {
  display: none;
}

.mic.recording .mic-dots {
  animation: dotsIn 0.2s ease;
}

@keyframes dotsIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: none; }
}

@keyframes ripple {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.75); opacity: 0; }
}

.mic-dots {
  display: none;
  gap: 3px;
  align-items: flex-end;
  height: 22px;
}

.mic-dots i {
  width: 3px;
  border-radius: 2px;
  background: #fff;
  animation: wave 0.9s ease-in-out infinite;
}

.mic-dots i:nth-child(1) { height: 8px; animation-delay: 0s; }
.mic-dots i:nth-child(2) { height: 16px; animation-delay: 0.12s; }
.mic-dots i:nth-child(3) { height: 11px; animation-delay: 0.24s; }
.mic-dots i:nth-child(4) { height: 18px; animation-delay: 0.36s; }
.mic-dots i:nth-child(5) { height: 9px; animation-delay: 0.48s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1); }
}

/* 快捷分类 */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-full);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.15s, background 0.2s;
}

.chip:active {
  transform: scale(0.96);
}

.chip .em {
  font-size: 15px;
}

.chip.active {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
}

/* 账单列表 */
.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-group {
  margin-bottom: 6px;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 6px 6px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
}

.day-head .day-sum {
  font-variant-numeric: tabular-nums;
}

.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  transition: background 0.15s;
  position: relative;
}

.entry + .entry {
  margin-top: 2px;
}

.entry:active {
  background: var(--card-2);
}

.entry-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--card-2);
  border: 1px solid var(--line);
}

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

.entry-note {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--card-2);
  border: 1px solid var(--line);
}

.entry-amount {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-amount.expense::before {
  content: "−";
  font-weight: 500;
  opacity: 0.6;
  margin-right: 1px;
}

.entry-amount.income {
  color: var(--mint);
}

.entry-amount.income::before {
  content: "+";
  margin-right: 1px;
}

.entry-del {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-3);
}

.empty-emoji {
  font-size: 40px;
  margin-bottom: 10px;
  filter: grayscale(0.2);
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 12.5px;
  line-height: 1.6;
}

/* 统计页 */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background: var(--card);
  border-radius: var(--r-md);
  padding: 14px 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.stat-box .k {
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.stat-box .v {
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  letter-spacing: -0.01em;
}

.stat-box .v small {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 2px;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.cat-row .cat-emoji {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--card-2);
  font-size: 17px;
  flex: 0 0 34px;
}

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

.cat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  font-weight: 600;
}

.cat-top .amt {
  font-variant-numeric: tabular-nums;
}

.cat-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  margin-top: 6px;
  overflow: hidden;
}

.cat-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffb199, var(--brand));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.cat-pct {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 双人对比 */
.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.duo-card {
  border-radius: var(--r-md);
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--card-2);
  position: relative;
  overflow: hidden;
}

.duo-card .who-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.duo-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: #fff;
}

.duo-amount {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
  letter-spacing: -0.02em;
}

.duo-amount small {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
}

.duo-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.duo-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  margin-top: 10px;
  overflow: hidden;
}

.duo-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 7 日柱状图 */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 96px;
  padding-top: 8px;
}

.spark-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.spark-bar {
  width: 100%;
  max-width: 26px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #ffb199, var(--brand));
  min-height: 4px;
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.spark-bar.zero {
  background: var(--line);
}

.spark-day {
  font-size: 10.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.spark-day.today {
  color: var(--brand);
}

/* AI 分析卡 */
.ai-card {
  background: linear-gradient(160deg, #f4f0ff, #eef7ff);
  border: 1px solid rgba(139, 124, 246, 0.22);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

:root[data-theme="dark"] .ai-card {
  background: linear-gradient(160deg, rgba(139, 124, 246, 0.14), rgba(47, 164, 143, 0.1));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-card {
    background: linear-gradient(160deg, rgba(139, 124, 246, 0.14), rgba(47, 164, 143, 0.1));
  }
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--violet);
  margin-bottom: 10px;
}

.ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 4px rgba(139, 124, 246, 0.18);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.16); }
  50% { box-shadow: 0 0 0 7px rgba(139, 124, 246, 0.06); }
}

.ai-headline {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 12px;
}

.ai-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-list li {
  position: relative;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

.ai-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--violet);
  opacity: 0.7;
}

.ai-tip {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.7);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

:root[data-theme="dark"] .ai-tip {
  background: rgba(255, 255, 255, 0.06);
}

.ai-loading {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--ink-3);
  font-size: 13px;
}

.ai-loading i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet);
  animation: bounce 1.2s infinite;
}

.ai-loading i:nth-child(2) { animation-delay: 0.15s; }
.ai-loading i:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 底部导航 */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 560px;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 14px var(--safe-b);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
  z-index: 30;
}

@supports (background: color-mix(in srgb, red 50%, blue)) {
  .tabbar {
    background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
  }
}

@media (min-width: 900px) {
  .tabbar {
    max-width: 620px;
    border-radius: 22px 22px 0 0;
    border: 1px solid var(--line);
    border-bottom: none;
  }
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
  border-radius: 14px;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 600;
  transition: color 0.2s, background 0.2s;
  min-width: 64px;
}

.tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.9;
}

.tab.active {
  color: var(--brand);
}

.tab.center {
  position: relative;
  top: -14px;
  color: #fff;
}

.tab.center .tab-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff9276, #ef5a4b);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 22px -8px rgba(239, 90, 75, 0.8);
  margin-bottom: 2px;
}

.tab.center .tab-fab svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
}

/* 底部弹层 */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 8, 0.42);
  backdrop-filter: blur(2px);
  z-index: 60;
  animation: fadeIn 0.22s ease;
}

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

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + var(--safe-b));
  z-index: 61;
  box-shadow: 0 -20px 60px -20px rgba(60, 30, 20, 0.5);
  animation: sheetUp 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-overflow-scrolling: touch;
}

@keyframes sheetUp {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.sheet.closing {
  animation: sheetDown 0.24s ease forwards;
}

@keyframes sheetDown {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, 100%); }
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 4px auto 14px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.sheet-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 16px;
}

/* 表单 */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line-strong);
  background: var(--card-2);
  font-size: 16px;
  transition: border-color 0.2s, background 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--card);
}

.amount-input {
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  padding: 16px;
  border: none;
  background: transparent;
}

.amount-input::placeholder {
  color: var(--ink-3);
  font-weight: 600;
}

.amount-wrap {
  background: var(--card-2);
  border-radius: var(--r-md);
  border: 1.5px solid var(--line-strong);
  position: relative;
}

.amount-wrap .yen {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-3);
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: var(--r-full);
  background: var(--card-2);
  border: 1px solid var(--line);
  gap: 4px;
}

.segmented button {
  flex: 1;
  padding: 9px;
  border-radius: var(--r-full);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.segmented button.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.segmented.income button.on {
  color: var(--mint);
}

.cat-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cat-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  background: var(--card-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all 0.18s;
}

.cat-pick .em {
  font-size: 20px;
}

.cat-pick.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.cat-pick:active {
  transform: scale(0.95);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 20px;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 15.5px;
  transition: transform 0.15s, opacity 0.2s;
}

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

.btn-primary {
  background: linear-gradient(145deg, #ff8b72, #ee5a4a);
  color: #fff;
  box-shadow: 0 12px 26px -12px rgba(238, 90, 74, 0.9);
}

.btn-ghost {
  background: var(--card-2);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
}

.btn-danger {
  background: rgba(242, 106, 90, 0.12);
  color: var(--brand-deep);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
}

/* 解析预览 */
.preview {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--card-2);
  padding: 14px;
  margin-bottom: 12px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preview-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--mint-soft);
  color: var(--mint);
}

.preview-badge.local {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px dashed var(--line);
}

.preview-item:first-of-type {
  border-top: none;
}

.preview-item .em {
  font-size: 20px;
}

.preview-item .txt {
  flex: 1;
  min-width: 0;
}

.preview-item .txt b {
  font-size: 14px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-item .txt span {
  font-size: 11.5px;
  color: var(--ink-3);
}

.preview-item .amt {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.preview-raw {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin-top: 10px;
  line-height: 1.5;
  border: 1px solid var(--line);
}

.voice-hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  min-height: 20px;
  margin-top: 10px;
}

.voice-hint.live {
  color: var(--brand);
  font-weight: 600;
}

/* 登录 */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 22px calc(28px + var(--safe-b));
  max-width: 460px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 12px 18px rgba(240, 100, 80, 0.3));
}

.login-title {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 12px;
}

.login-sub {
  font-size: 13.5px;
  color: var(--ink-3);
  margin-top: 6px;
}

.accounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.account {
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--r-lg);
  padding: 20px 12px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.18s, border-color 0.2s, box-shadow 0.2s;
}

.account:active {
  transform: scale(0.97);
}

.account.on {
  border-color: var(--brand);
  box-shadow: 0 16px 36px -18px rgba(238, 90, 74, 0.85);
}

.account .acc-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  margin: 0 auto 10px;
}

.account .acc-name {
  font-weight: 700;
  font-size: 15px;
}

.account .acc-role {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 18px;
}

.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  transition: all 0.18s;
}

.pin-dot.filled {
  background: var(--brand);
  border-color: var(--brand);
  transform: scale(1.12);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.key {
  height: 58px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 22px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  transition: transform 0.12s, background 0.15s;
  font-variant-numeric: tabular-nums;
}

.key:active {
  transform: scale(0.95);
  background: var(--card-2);
}

.key.fn {
  font-size: 15px;
  color: var(--ink-2);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.login-tip {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 18px;
  line-height: 1.7;
}

/* 我的页面 */
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(140deg, var(--brand-soft), rgba(255, 255, 255, 0));
  border: 1px solid var(--line);
}

.profile-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  box-shadow: var(--shadow);
}

.profile-name {
  font-size: 20px;
  font-weight: 800;
}

.profile-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.menu {
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  width: 100%;
  text-align: left;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item .mi-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--card-2);
}

.menu-item .mi-body {
  flex: 1;
}

.menu-item .mi-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 1px;
}

.menu-item .mi-chev {
  color: var(--ink-3);
  font-size: 18px;
}

.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--mint-soft);
  color: var(--mint);
}

.badge.off {
  background: var(--line);
  color: var(--ink-3);
}

/* 提示条 */
.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 460px);
}

.toast {
  background: rgba(30, 22, 18, 0.94);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-full);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  text-align: center;
}

.toast.success {
  background: rgba(31, 122, 106, 0.96);
}

.toast.error {
  background: rgba(190, 60, 45, 0.96);
}

.toast.out {
  animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--amber);
  color: #3a2600;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 5px;
  z-index: 95;
}

/* 杂项 */
.muted {
  color: var(--ink-3);
}

.mono {
  font-variant-numeric: tabular-nums;
}

.center {
  text-align: center;
}

.spacer {
  height: 4px;
}

.hidden {
  display: none !important;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  margin-right: 5px;
}

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

/* 深色模式下 hero 保持鲜艳 */
@media (prefers-color-scheme: dark) {
  .hero {
    box-shadow: 0 18px 44px -24px rgba(224, 79, 107, 0.6);
  }
}
