/* ============================================
   黑马记账 — iOS 风格设计系统
   ============================================ */

/* ----- iOS 设计变量 ----- */
:root {
  /* iOS 系统色 */
  --ios-blue: #007AFF;
  --ios-blue-dark: #0062CC;
  --ios-green: #34C759;
  --ios-red: #FF3B30;
  --ios-orange: #FF9500;
  --ios-yellow: #FFCC00;

  /* 语义色 */
  --color-income: var(--ios-green);
  --color-expense: var(--ios-red);
  --color-primary: var(--ios-blue);
  --color-primary-dark: var(--ios-blue-dark);
  --color-danger: var(--ios-red);
  --color-warning: var(--ios-orange);

  /* 背景与卡片 */
  --color-bg: #F2F2F7;
  --color-surface: #FFFFFF;
  --color-fill: #E9E9EB;        /* 输入框、分段控件填充 */
  --color-separator: #E5E5EA;
  --color-separator-opaque: #C6C6C8;

  /* 文字 */
  --color-text: #1C1C1E;
  --color-text-secondary: #6E6E73;
  --color-text-muted: #8E8E93;

  /* 圆角（iOS 标准） */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);

  --font-stack: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
                'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;

  --tab-height: 56px;
  --header-height: 96px;
}

/* ----- 基础重置 ----- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font-stack);
  font-size: 17px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

input, select, button, textarea {
  font-family: inherit;
  font-size: inherit;
  -webkit-appearance: none;
  appearance: none;
}

/* ----- App 容器 ----- */
.app-container {
  max-width: 500px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  position: relative;
  overflow: hidden;
}

/* ============================================
   顶部导航（iOS 大标题风格）
   ============================================ */
.header-bar {
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 20px 6px;
  background: rgba(242,242,247,0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  z-index: 10;
}

.header-book {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 12px;
  transition: background 0.15s;
  margin: -4px -10px;
}

.header-book:active { background: rgba(0,0,0,0.06); }

.header-book-icon {
  display: flex;
  align-items: center;
  color: var(--color-primary);
  line-height: 1;
}

.header-book-name {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--color-text);
}

/* ============================================
   主内容区
   ============================================ */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.screen {
  padding: 12px 16px 0;
  animation: screenIn 0.25s ease;
}

.screen.hidden { display: none; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   底部 Tab 栏（iOS 毛玻璃）
   ============================================ */
.tab-bar {
  height: calc(var(--tab-height) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  background: rgba(249,249,249,0.94);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--color-separator);
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.2s;
}

.tab-item .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.2s;
}

.tab-item.active .tab-icon {
  transform: translateY(-1px);
}

.tab-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

.tab-item:active .tab-icon { transform: scale(0.9); }

/* ============================================
   分组卡片（iOS inset grouped table 风格）
   ============================================ */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 4px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: none;
  padding: 14px 0 4px;
  letter-spacing: 0.3px;
}

/* ----- 今日概览 ----- */
.today-summary {
  display: flex;
  justify-content: space-around;
  text-align: center;
  padding: 20px 12px;
}

.today-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.today-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.today-amount {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  transition: color 0.3s ease;
}

.today-amount.expense { color: var(--color-expense); }
.today-amount.income { color: var(--color-income); }

/* ============================================
   分段控件（iOS Segmented Control）
   ============================================ */
.type-toggle {
  position: relative;
  display: flex;
  height: 32px;
  background: var(--color-fill);
  border-radius: 9px;
  padding: 2px;
  margin-bottom: 16px;
}

.seg-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: 28px;
  background: var(--color-surface);
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.08);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

.type-toggle.income-selected .seg-slider {
  transform: translateX(100%);
}

.type-btn {
  flex: 1;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-radius: 7px;
  position: relative;
  z-index: 1;
  transition: color 0.2s;
}

.type-btn.active {
  color: var(--color-expense);
}

.type-toggle.income-selected .type-btn.active {
  color: var(--color-income);
}

.type-btn:active { opacity: 0.7; }

/* ============================================
   金额输入（iOS 键盘风格）
   ============================================ */
.amount-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--color-fill);
  border-radius: var(--radius-md);
  transition: box-shadow 0.2s;
}

.amount-input-wrapper:focus-within {
  background: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.currency-prefix {
  font-size: 30px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

.amount-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 30px;
  font-weight: 600;
  outline: none;
  color: var(--color-text);
  min-width: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.amount-input::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 22px;
}

.amount-input::-webkit-inner-spin-button,
.amount-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================
   分类网格（iOS 格子）
   ============================================ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.category-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-fill);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
  justify-content: center;
}

.category-chip:active {
  transform: scale(0.95);
}

.category-chip.active {
  background: rgba(0,122,255,0.12);
  color: var(--color-primary);
  font-weight: 600;
}

.category-chip.active .cat-icon {
  transform: scale(1.15);
}

.cat-icon {
  display: flex;
  align-items: center;
  line-height: 1;
  transition: transform 0.2s;
}

/* ============================================
   表单输入
   ============================================ */
.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.form-row > * { flex: 1; }

.input-field {
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  outline: none;
  background: var(--color-fill);
  transition: background 0.2s, box-shadow 0.2s;
  color: var(--color-text);
}

.input-field:focus {
  background: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.input-field::placeholder {
  color: var(--color-text-muted);
}

/* iOS 日期选择器 */
input[type="date"] {
  position: relative;
}

/* ============================================
   提交按钮（iOS 大按钮）
   ============================================ */
.btn-primary {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  letter-spacing: 1px;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.btn-primary:hover { opacity: 0.9; }

/* ============================================
   交易列表（iOS 列表）
   ============================================ */
.txn-date-header {
  padding: 10px 4px 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.txn-date-weekday {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 12px;
}

.txn-item {
  display: flex;
  align-items: center;
  padding: 11px 4px;
  gap: 12px;
  border-bottom: 0.5px solid var(--color-separator);
  transition: background 0.1s;
}

.txn-item:last-child { border-bottom: none; }
.txn-item:active { background: #F7F7FA; }

.txn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.txn-info {
  flex: 1;
  min-width: 0;
}

.txn-cat {
  font-size: 16px;
  font-weight: 500;
}

.txn-note {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.txn-amount {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.txn-del {
  color: var(--color-text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 50%;
  transition: all 0.15s;
  flex-shrink: 0;
}

.txn-del:active {
  color: var(--color-danger);
  background: rgba(255,59,48,0.1);
}

/* ----- 空状态 ----- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--color-text-muted);
}
.empty-text { font-size: 16px; }

/* ----- 搜索框 ----- */
.search-bar { margin-bottom: 8px; }

.search-input {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 16px;
  outline: none;
  background: var(--color-fill);
  transition: box-shadow 0.2s;
}

.search-input:focus {
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* ============================================
   统计页面
   ============================================ */

/* 月份导航 */
.month-navigator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.month-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, color 0.2s;
}

.month-arrow:active {
  transform: scale(0.9);
  color: var(--color-primary);
}

.month-label {
  font-size: 20px;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
  letter-spacing: -0.5px;
}

/* 统计卡片行 */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-mini-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}

.stat-mini-card:active { transform: scale(0.96); }

.stat-mini-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.stat-mini-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.stat-mini-value.expense { color: var(--color-expense); }
.stat-mini-value.income { color: var(--color-income); }
.stat-mini-value.balance { color: var(--color-primary); }

/* 图表容器 */
.chart-container {
  position: relative;
  height: 260px;
  margin: 6px 0 12px;
}

.chart-container canvas { width: 100% !important; }

.chart-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--color-text-muted);
  font-size: 15px;
}

/* 预算卡片 */
.budget-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 14px 0 10px;
}

.budget-empty {
  font-size: 15px;
  color: var(--color-text-muted);
  padding-bottom: 12px;
}

.budget-bar-wrap {
  height: 8px;
  background: var(--color-fill);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0 12px;
}

.budget-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  background: linear-gradient(90deg, #34C759, #30D158);
}

.budget-bar.warning {
  background: linear-gradient(90deg, #FF9500, #FFCC00);
}

.budget-bar.danger {
  background: linear-gradient(90deg, #FF3B30, #FF6961);
}

.budget-bar.danger.pulse {
  animation: pulse-bar 1.5s ease-in-out infinite;
}

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.budget-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.budget-pct { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }

.budget-ok { color: var(--ios-green); }
.budget-warning { color: var(--ios-orange); }
.budget-danger { color: var(--ios-red); }

.budget-status { font-size: 14px; }

.btn-budget-set {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-xl);
  background: rgba(0,122,255,0.12);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-budget-set:active { background: rgba(0,122,255,0.22); }

/* ============================================
   设置页面
   ============================================ */

/* 账本卡片 */
.book-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 16px;
}

.book-card {
  width: calc(50% - 5px);
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--color-fill);
  box-shadow: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.book-card:active { transform: scale(0.96); }

.book-card.active {
  background: rgba(0,122,255,0.12);
}

.book-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 8px;
}

.book-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
}

.book-current-tag {
  font-size: 10px;
  color: var(--color-primary);
  background: rgba(0,122,255,0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.book-card-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.book-card-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: transparent;
  color: var(--color-text-muted);
  text-align: center;
}

.book-card-add .book-card-icon { background: var(--color-fill); }

/* 设置菜单（iOS 分组列表） */
.settings-menu {
  margin-bottom: 20px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--color-separator);
  cursor: pointer;
  font-weight: 400;
  font-size: 16px;
  transition: background 0.15s;
}

.settings-item:last-child { border-bottom: none; }
.settings-item:active { background: #F7F7FA; }

.settings-item.danger { color: var(--color-danger); }

.settings-about {
  padding: 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ============================================
   弹窗（iOS Sheet 风格）
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.35s cubic-bezier(0.32, 1, 0.4, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: relative;
}

/* iOS sheet 顶部把手 */
.modal-content::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--color-separator-opaque);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 0;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--color-fill);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background 0.15s;
}

.modal-close:active { background: #d1d1d6; }

.modal-body { padding: 20px; }

.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  margin-top: 16px;
}

.modal-label:first-child { margin-top: 0; }

.modal-input {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 17px;
  outline: none;
  background: var(--color-fill);
  transition: box-shadow 0.2s;
  color: var(--color-text);
}

.modal-input:focus {
  box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 0 20px 20px;
}

.btn-cancel {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-fill);
  color: var(--color-text);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-cancel:active { opacity: 0.7; }

.btn-confirm {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-confirm:active { opacity: 0.8; }

.btn-danger {
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255,59,48,0.12);
  color: var(--color-danger);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  margin-right: auto;
  transition: opacity 0.15s;
}

.btn-danger:active { opacity: 0.7; }

/* 图标选择器 */
.icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-option {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-fill);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s, color 0.2s;
}

.icon-option:active { transform: scale(0.9); }

.icon-option.active {
  background: rgba(0,122,255,0.15);
  color: var(--color-primary);
}

/* 颜色选择器 */
.color-grid {
  display: flex;
  gap: 12px;
}

.color-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  font-size: 16px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.color-option:active { transform: scale(0.9); }

.color-option.active {
  border-color: var(--color-text);
  transform: scale(1.1);
}

/* ============================================
   Toast
   ============================================ */

.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(28,28,30,0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 24px;
  border-radius: 14px;
  font-weight: 500;
  font-size: 15px;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: rgba(52,199,89,0.95); }
.toast-error { background: rgba(255,59,48,0.95); }
.toast-warning { background: rgba(255,149,0,0.95); }

/* ============================================
   抖动动画
   ============================================ */

.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ============================================
   登录/注册界面（微信风格）
   ============================================ */

/* 登录模式下隐藏 App 外壳 */
.app-container.auth-mode .header-bar,
.app-container.auth-mode .tab-bar,
.app-container.auth-mode .screen:not(#screen-auth) {
  display: none;
}

.screen-auth {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 0;
  background: #fff;
}

.app-container.auth-mode .screen-auth {
  display: flex;
}

.auth-wrap {
  width: 100%;
  max-width: 320px;
  padding: 0 24px;
  text-align: center;
}

.auth-logo {
  width: 66px;
  height: 66px;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--color-primary), #5AC8FA);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 6px 20px rgba(0,122,255,0.28);
}

.auth-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  color: var(--color-text);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 44px;
}

/* 登录/注册分页 */
.auth-page {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

.auth-page.hidden { display: none; }

.auth-back {
  width: 100%;
  margin-bottom: 28px;
  text-align: left;
}

.auth-back-icon { font-size: 18px; margin-right: 2px; }

/* 带图标的下划线输入框（QQ/微信风格） */
.auth-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-separator);
  margin-bottom: 20px;
  text-align: left;
  transition: border-color 0.2s;
}

.auth-field:focus-within {
  border-bottom-color: var(--color-primary);
}

.auth-field-icon {
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  margin-right: 6px;
  flex-shrink: 0;
}

.auth-field:focus-within .auth-field-icon {
  color: var(--color-primary);
}

.auth-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 2px;
  font-size: 16px;
  color: var(--color-text);
  outline: none;
  min-width: 0;
}

.auth-input::placeholder {
  color: var(--color-text-muted);
}

/* 大圆角主按钮 */
.auth-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 25px;
  background: var(--color-primary);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 14px;
  transition: opacity 0.15s;
}

.auth-btn:active { opacity: 0.8; }

.auth-switch {
  margin-top: 22px;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.auth-link {
  color: #576B95;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.auth-link:active { opacity: 0.7; }

/* ============================================
   响应式
   ============================================ */

@media (min-width: 501px) {
  .app-container {
    border-left: 0.5px solid var(--color-separator);
    border-right: 0.5px solid var(--color-separator);
  }

  .modal-content {
    border-radius: var(--radius-xl);
    margin-bottom: 24px;
  }
}

@media (max-width: 360px) {
  .stats-cards { grid-template-columns: 1fr; }
  .category-grid { gap: 6px; }
  .category-chip { padding: 8px 4px; font-size: 12px; }
  .book-card { width: 100%; }
  .header-book-name { font-size: 28px; }
}

/* ============================================
   贪吃蛇小游戏
   ============================================ */

.snake-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px;
}

.snake-back {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.snake-back:active { opacity: 0.6; }

.snake-back-icon {
  font-size: 24px;
  line-height: 1;
}

.snake-title {
  font-size: 17px;
  font-weight: 700;
}

.snake-score {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.snake-best {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.snake-canvas-wrap {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

#snakeCanvas {
  display: block;
  width: 100%;
}

.snake-controls { margin-bottom: 12px; }

.snake-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto 16px;
}

.snake-btn[data-dir="up"] { grid-column: 2; }
.snake-btn[data-dir="left"] { grid-column: 1; }
.snake-btn[data-dir="right"] { grid-column: 3; }
.snake-btn[data-dir="down"] { grid-column: 2; }

.snake-btn {
  height: 60px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.snake-btn:active {
  transform: scale(0.92);
  opacity: 0.8;
}

.snake-btn-action {
  color: var(--color-primary);
}

.snake-restart {
  display: block;
  margin: 0 auto;
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--color-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.snake-restart:active { opacity: 0.8; }

.snake-hint {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: 4px;
}
