/* === 心情日记 PWA - 主样式 === */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --grad-start: #ffeaa7;
  --grad-mid: #fab1a0;
  --grad-end: #ff7675;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --border: #dfe6e9;
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #b2bec3;
  --success: #55efc4;
  --danger: #ff7675;
  --accent: #fab1a0;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--surface-muted);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--grad-start) 0%, var(--grad-mid) 60%, var(--surface) 100%);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* === 顶部栏 === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg,
    rgba(255, 234, 167, 0.92) 0%,
    rgba(250, 177, 160, 0.88) 60%,
    rgba(250, 177, 160, 0.78) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 12px rgba(250, 177, 160, 0.18);
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
}
.topbar .date {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === 内容区 === */
.content {
  flex: 1;
  padding: 8px 20px 100px;
  overflow-y: auto;
}

/* === Tab 内容切换 === */
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === 卡片 === */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* === 情绪选择器 === */
.mood-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  transition: transform 0.3s ease;
  border-radius: var(--radius-md);
  padding: 4px;
}
.mood-row.attention {
  animation: moodShake 0.5s ease;
  transform-origin: center;
}
.mood-row.needs-attention {
  animation: moodPulse 1.2s ease-in-out infinite;
  background: rgba(255, 230, 167, 0.35);
  box-shadow: 0 0 0 2px rgba(255, 167, 113, 0.5);
}
@keyframes moodShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes moodPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 167, 113, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255, 167, 113, 0.15); }
}
.mood-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mood-item:active { transform: scale(0.95); }
.mood-item.selected {
  background: var(--grad-mid);
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(250,177,160,0.4);
}
.mood-emoji { font-size: 32px; line-height: 1; }
.mood-label { font-size: 11px; color: var(--text-secondary); }
.mood-item.selected .mood-label { color: var(--text-primary); font-weight: 600; }

/* === 输入框 === */
.input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
  min-height: 80px;
}
.input:focus { border-color: var(--accent); }

/* === 按钮 === */
.btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--grad-mid) 0%, var(--grad-end) 100%);
  color: white;
  box-shadow: 0 6px 16px rgba(255,118,117,0.3);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
}
.btn-record {
  background: white;
  color: var(--text-primary);
  border: 2px solid var(--border);
}
.btn-record.recording {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,118,117,0.5); }
  50% { box-shadow: 0 0 0 12px rgba(255,118,117,0); }
}

/* === 成功提示 === */
.success-banner {
  background: var(--success);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 600;
  margin-top: 16px;
  display: none;
}
.success-banner.show { display: block; animation: slideUp 0.3s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === 底部导航 === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--grad-end); }
.nav-item .icon { font-size: 22px; line-height: 1; }

/* === 趋势图 === */
.chart-container {
  position: relative;
  height: 220px;
  margin: 16px 0;
}
.chart-tooltip {
  position: absolute;
  background: rgba(45,52,54,0.95);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  display: none;
  z-index: 5;
}
.chart-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 4px;
}

/* === 关键词云 === */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.keyword {
  background: var(--grad-start);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 20px;
  display: inline-block;
}
.keyword.lg { font-size: 16px; font-weight: 600; }
.keyword.md { font-size: 14px; }
.keyword.sm { font-size: 12px; opacity: 0.85; }

/* === 洞察卡片 === */
.insight-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.insight-emoji { font-size: 32px; line-height: 1; flex-shrink: 0; }
.insight-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.insight-body { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* === 我的页面 === */
.profile-card {
  text-align: center;
  padding: 32px 24px;
}
.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--grad-mid), var(--grad-end));
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: white;
  box-shadow: var(--shadow-md);
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .left { display: flex; align-items: center; gap: 12px; }
.menu-item .icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grad-start);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.menu-item .arrow { color: var(--text-muted); }

.upgrade-btn {
  background: linear-gradient(135deg, var(--grad-mid) 0%, var(--grad-end) 100%);
  color: white;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 700;
  margin-top: 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255,118,117,0.3);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUpModal 0.3s ease;
}
@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal-close {
  background: var(--surface-muted);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  position: absolute;
  top: 16px;
  right: 16px;
}

/* === 编辑 modal 内的表情行（紧凑） === */
.modal .mood-row {
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
.modal .mood-item {
  padding: 10px 2px;
}
.modal .mood-emoji { font-size: 28px; }
.modal .mood-label { font-size: 10px; }

/* === 录音界面 === */
.record-area {
  text-align: center;
  padding: 32px 0;
}
.record-btn-big {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--grad-mid), var(--grad-end));
  color: white;
  font-size: 48px;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255,118,117,0.4);
  margin: 0 auto;
  display: block;
  transition: transform 0.1s;
}
.record-btn-big:active { transform: scale(0.95); }
.record-btn-big.recording {
  animation: pulseBig 1.2s infinite;
}
@keyframes pulseBig {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,118,117,0.6); }
  50% { box-shadow: 0 0 0 24px rgba(255,118,117,0); }
}
.record-timer {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 16px 0;
  color: var(--text-primary);
}
.recordings-list {
  margin-top: 24px;
}
.recording-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.play-btn {
  background: var(--grad-mid);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}

/* === 付费墙 === */
.paywall-hero {
  background: linear-gradient(135deg, var(--grad-mid) 0%, var(--grad-end) 100%);
  color: white;
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: 20px;
}
.paywall-hero h2 { font-size: 22px; margin-bottom: 8px; }
.paywall-hero p { opacity: 0.9; font-size: 14px; }
.price-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.price-card.selected { border-color: var(--grad-end); background: #fff5f4; }
.price-card .badge {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--grad-end);
  color: white;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 10px;
}
.price-card .price { font-size: 24px; font-weight: 700; color: var(--grad-end); }
.price-card .period { font-size: 13px; color: var(--text-secondary); }
.benefits { list-style: none; padding: 0; margin: 16px 0; }
.benefits li { padding: 8px 0; font-size: 14px; display: flex; gap: 8px; }

/* === 安装提示 === */
.install-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 440px;
  background: var(--text-primary);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--grad-end);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* === 工具类 === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state .big-emoji { font-size: 64px; margin-bottom: 12px; }
.tip { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.text-secondary { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

/* === 历史记录列表 === */
.history-item {
  display: flex;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.history-item:last-child { border-bottom: none; }
.history-emoji { font-size: 28px; line-height: 1; }
.history-body { flex: 1; min-width: 0; }
.history-time { font-size: 11px; color: var(--text-muted); }
.history-note {
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-actions { display: flex; gap: 8px; }
.history-action-btn {
  background: var(--surface-muted);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}
.history-action-btn.danger { color: var(--danger); }
.audio-play-btn {
  background: var(--grad-mid);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.audio-play-btn:hover { background: var(--grad-end); }

/* === 日历 === */
.cal-nav {
  background: var(--surface-muted);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cal-weekdays > div { padding: 4px 0; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  min-height: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  position: relative;
  transition: background 0.15s;
  background: transparent;
  border: none;
  font-family: inherit;
  padding: 4px;
}
.cal-day:hover { background: var(--surface-muted); }
.cal-day.empty { visibility: hidden; }
.cal-day.today {
  border: 2px solid var(--grad-end);
  font-weight: 700;
}
.cal-day.selected {
  background: var(--grad-mid);
  color: white;
  font-weight: 700;
}
.cal-day-num { line-height: 1; }
.cal-day-mood {
  position: absolute;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.cal-day.no-entry .cal-day-mood { display: none; }
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.cal-legend-item { display: flex; align-items: center; gap: 4px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* === 开关（iOS 风格） === */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: 0.3s;
}
.slider::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider {
  background: linear-gradient(135deg, var(--grad-mid), var(--grad-end));
}
input:checked + .slider::before {
  transform: translateX(20px);
}

/* === 删除确认 modal === */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-overlay.show { display: flex; animation: fadeIn 0.2s; }
.confirm-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.confirm-buttons { display: flex; gap: 8px; }
.confirm-buttons .btn { flex: 1; }

/* === 按钮 === */
.btn-danger {
  background: var(--danger);
  color: white;
}
