/* MiSans Latin（数字与英文优先） */
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-ExtraLight.woff2") format("woff2"); font-weight: 200; font-display: swap; }
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-Semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "MiSans Latin"; src: url("/fonts/MiSansLatin/MiSansLatin-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* MiSans 中文 */
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-ExtraLight.woff2") format("woff2"); font-weight: 200; font-display: swap; }
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-Semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "MiSans"; src: url("/fonts/MiSans/MiSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --page-bg:
    radial-gradient(72% 52% at 10% 8%, #E7E9FE 0%, rgba(231, 233, 254, 0) 62%),
    radial-gradient(48% 38% at 22% 5%, rgba(240, 228, 253, 0.82) 0%, rgba(240, 228, 253, 0) 58%),
    radial-gradient(56% 44% at 94% 47%, #F1DCFD 0%, rgba(241, 220, 253, 0) 58%),
    radial-gradient(72% 56% at 82% 70%, #E0E6FE 0%, rgba(224, 230, 254, 0) 62%),
    radial-gradient(72% 48% at 18% 91%, #EDE0FD 0%, rgba(237, 224, 253, 0) 58%),
    #FCFCFE;
  --ink: #202443;
  --ink-soft: #5E6180;
  --ink-muted: #7F829E;
  --ink-lilac: #7B68C4;
  --primary: #6335F5;
  --primary-2: #8545F5;
  --primary-grad: linear-gradient(90deg, #6335F5 0%, #8545F5 55%, #7B8CFF 100%);
  --green-jp: #1E8F5A;
  --red-jp: #C9364A;
  --shadow-card: 0 14px 36px -10px rgba(99, 53, 245, 0.09), 0 3px 10px -2px rgba(32, 36, 67, 0.03);
  --shadow-soft: 0 8px 22px -8px rgba(99, 53, 245, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: "MiSans Latin", "MiSans", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #F4F3FB;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  outline: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.text-field-input {
  font-size: 16px !important;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  caret-color: var(--primary);
  border: 1.5px solid transparent;
  transition: background 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.text-field-input:focus {
  background: #FFFFFF !important;
  border-color: rgba(99, 53, 245, 0.35);
  box-shadow: 0 0 0 3px rgba(99, 53, 245, 0.12);
}

.text-field-input::placeholder {
  color: #B8BACF;
  opacity: 1;
}

button {
  cursor: pointer;
}

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

/* 主画布：手机全屏沉浸；宽屏居中无假手机外壳 */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--page-bg);
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}

@media (min-width: 640px) {
  body {
    padding: 16px 12px;
    background:
      radial-gradient(60% 60% at 15% 15%, #EAE8FF 0%, rgba(234, 232, 255, 0) 60%),
      radial-gradient(50% 50% at 85% 85%, #F6E6FE 0%, rgba(246, 230, 254, 0) 60%),
      #F2F1FA;
  }
  .app-shell {
    height: calc(100dvh - 32px);
    min-height: calc(100dvh - 32px);
    overflow-y: auto;
    transform: translateZ(0);
    border-radius: 32px;
    box-shadow: 0 24px 64px -16px rgba(99, 53, 245, 0.18);
  }
}

/* 纯无边框悬浮色块 */
.float-card {
  background: #FFFFFF;
  border-radius: 26px;
  box-shadow: var(--shadow-card);
}

.tint-lilac {
  background: linear-gradient(145deg, #F6F3FF 0%, #EFEAFF 100%);
  border-radius: 18px;
  box-shadow: 0 8px 20px -8px rgba(99, 53, 245, 0.09);
}

.tint-ice {
  background: linear-gradient(145deg, #F4F7FF 0%, #EBF0FF 100%);
  border-radius: 18px;
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.08);
}

.tint-blush {
  background: linear-gradient(145deg, #FFF5F9 0%, #FCEBF3 100%);
  border-radius: 18px;
  box-shadow: 0 8px 20px -8px rgba(219, 39, 119, 0.08);
}

/* 顶部按钮 */
.icon-circle-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 18px -6px rgba(99, 53, 245, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: transform 0.16s ease;
  flex-shrink: 0;
}
.icon-circle-btn:active {
  transform: scale(0.94);
}

/* 悬浮四格返回首页 */
.floating-grid-btn {
  width: 40px;
  height: 40px;
  border-radius: 16px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: transform 0.16s ease;
  flex-shrink: 0;
}
.floating-grid-btn:active {
  transform: scale(0.92);
}

/* 主按钮渐变大胶囊 */
.primary-pill-btn {
  width: 100%;
  padding: 15px 24px;
  border-radius: 999px;
  background: var(--primary-grad);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.4px;
  box-shadow: 0 12px 28px -6px rgba(99, 53, 245, 0.40);
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.primary-pill-btn:active {
  transform: scale(0.98);
}

.small-pill-btn {
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6335F5 0%, #8545F5 100%);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 8px 18px -6px rgba(99, 53, 245, 0.35);
}
.small-pill-btn:active {
  transform: scale(0.95);
}

/* 页面容器：顶部预留充足状态栏安全距离，避免贴顶遮挡 */
.page-pad {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(36px + env(safe-area-inset-top)) 16px calc(22px + env(safe-area-inset-bottom));
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 40px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

/* 登录 / PIN 页 */
.pin-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(44px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
}

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

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 2px 6px rgba(99, 53, 245, 0.16), 0 4px 12px rgba(99, 53, 245, 0.10);
  transition: transform 0.16s ease, background 0.16s ease;
}

.pin-dot.filled {
  background: linear-gradient(135deg, #6335F5 0%, #8545F5 100%);
  box-shadow: 0 6px 16px rgba(99, 53, 245, 0.40);
  transform: scale(1.08);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad-key {
  height: 52px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  box-shadow: 0 8px 20px -8px rgba(99, 53, 245, 0.16), 0 2px 6px rgba(32, 36, 67, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}

.keypad-key:active {
  transform: scale(0.95);
  background: #F3F0FF;
}

.keypad-key.text-key {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
}

/* 首页：汇总卡 + Tab + 堆叠切片 */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  padding: 13px 14px;
  border-radius: 24px;
}

.tabs-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.tabs-strip::-webkit-scrollbar {
  display: none;
}

.tab-item {
  position: relative;
  height: 32px;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 300;
  color: var(--ink-muted);
  flex-shrink: 0;
  transition: color 0.16s ease;
}
.tab-item.active {
  font-weight: 600;
  color: var(--ink);
}
.tab-item.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 999px;
  background: var(--primary);
}

/* 日常三张堆叠切片 */
.stack-wrap {
  position: relative;
  padding-top: 2px;
}

.slice-layer {
  margin: 0 auto;
  border-radius: 24px 24px 0 0;
  padding: 12px 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.slice-layer-2 {
  width: 88%;
  background: linear-gradient(135deg, #FDE8F2 0%, #FADCEB 100%);
  box-shadow: 0 -4px 16px -4px rgba(219, 39, 119, 0.10), 0 8px 20px -8px rgba(32, 36, 67, 0.08);
}

.slice-layer-1 {
  width: 94%;
  margin-top: -12px;
  background: linear-gradient(135deg, #EAE5FF 0%, #E1DAFE 100%);
  box-shadow: 0 -6px 18px -4px rgba(99, 53, 245, 0.14), 0 10px 24px -8px rgba(99, 53, 245, 0.12);
}

.slice-front {
  position: relative;
  margin-top: -12px;
  border-radius: 28px;
  padding: 18px;
  background: linear-gradient(170deg, #FFFFFF 55%, #FAF8FF 100%);
  box-shadow: 0 -10px 26px -6px rgba(99, 53, 245, 0.14), 0 18px 42px -12px rgba(99, 53, 245, 0.16);
  cursor: pointer;
}

.slice-front-static {
  cursor: default;
  margin-top: 0;
}

/* 首页底部锁定操作条：无论怎么上下滚动都始终悬浮固定在底部 */
.sticky-bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 25;
  margin-top: auto;
  margin-left: -16px;
  margin-right: -16px;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(252, 252, 254, 0) 0%, rgba(250, 249, 254, 0.90) 34%, rgba(248, 247, 254, 0.98) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* 抽屉 */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 36, 67, 0.22);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
}

.drawer-panel {
  width: 78%;
  max-width: 310px;
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 0 32px 32px 0;
  padding: calc(44px + env(safe-area-inset-top)) 20px 30px;
  box-shadow: 16px 0 42px -10px rgba(99, 53, 245, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.15s ease;
}
.drawer-item:active {
  background: #F4F1FF;
}

.drawer-sub {
  padding: 4px 12px 10px 44px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 轻新拟态开关 */
.soft-switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #E7E5F5;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.soft-switch.on {
  background: linear-gradient(90deg, #6335F5 0%, #8545F5 100%);
  box-shadow: 0 4px 14px rgba(99, 53, 245, 0.35);
}
.soft-switch-knob {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(32, 36, 67, 0.18);
  transition: transform 0.2s ease;
}
.soft-switch.on .soft-switch-knob {
  transform: translateX(20px);
}

/* 记账分类标签：大图标大胶囊，自适应流式不规则排布 */
.cat-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 10px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px -8px rgba(99, 53, 245, 0.16);
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  max-width: 100%;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}
.cat-chip.selected {
  background: linear-gradient(135deg, #6335F5 0%, #8545F5 100%);
  color: #FFFFFF;
  box-shadow: 0 12px 26px -6px rgba(99, 53, 245, 0.38);
}
.cat-chip:active {
  transform: scale(0.95);
}

.cat-chip-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cat-chip.selected .cat-chip-icon {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #FFFFFF !important;
}

/* 底部浮层键盘面板 */
.record-sheet {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 30px 30px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -14px 40px -10px rgba(99, 53, 245, 0.16);
}

/* 可拖动并半隐藏嵌入屏幕边缘的完整圆球客服入口（放大至 58px，露出 44px 易点击热区） */
.cs-floating-orb {
  position: fixed;
  z-index: 45;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 28px -4px rgba(99, 53, 245, 0.28), 0 3px 10px rgba(32, 36, 67, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), left 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.cs-floating-orb.dock-right {
  transform: translateX(14px);
  opacity: 0.94;
}

.cs-floating-orb.dock-left {
  transform: translateX(-14px);
  opacity: 0.94;
}

.cs-floating-orb.dock-right:hover,
.cs-floating-orb.dock-left:hover,
.cs-floating-orb.is-active {
  transform: translateX(0);
  opacity: 1;
}

.cs-orb-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #E11D48;
  box-shadow: 0 0 0 2px #FFFFFF;
}

/* Telegram 风格聊天布局 */
.chat-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
}

@media (min-width: 640px) {
  .chat-page {
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
  }
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 14px 14px;
  user-select: none;
  touch-action: pan-y;
}

.chat-bubble-in {
  background: #FFFFFF;
  border-radius: 22px 22px 22px 6px;
  box-shadow: var(--shadow-card);
  color: var(--ink);
}

.chat-bubble-out {
  background: linear-gradient(135deg, #6335F5 0%, #8545F5 100%);
  border-radius: 22px 22px 6px 22px;
  box-shadow: 0 10px 24px -8px rgba(99, 53, 245, 0.32);
  color: #FFFFFF;
}

.chat-date-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #6C6F8D;
  font-size: 12px;
  font-weight: 300;
  box-shadow: 0 4px 12px -4px rgba(99, 53, 245, 0.10);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(10px);
  z-index: 90;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(32, 36, 67, 0.92);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 300;
  box-shadow: 0 10px 24px rgba(32, 36, 67, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 弹窗底板 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(32, 36, 67, 0.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 30px 30px 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px -10px rgba(99, 53, 245, 0.18);
  max-height: 88dvh;
  overflow-y: auto;
}
