/* ===================================
   万物手札 H5 - 主题系统
   设计理念：无界原生 x 模数框架 x 单色墨影 x 浮动焦点 x 暖光纸本
   版本：v2.5.0
   =================================== */

/* ===================================
   iOS 兼容性修复
   =================================== */

/* 防止 iOS 自动缩放 */
* {
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* iOS 安全区域支持 */
html {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* 平滑滚动 */
body {
  -webkit-overflow-scrolling: touch;
  min-height: 100vh; /* Fallback */
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

/* ===================================
   CSS 变量与主题系统
   =================================== */

:root {
  /* 基础尺寸 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* 圆角 */
  --border-radius-sm: 4px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Courier New', monospace;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.16);
  
  /* 动画 */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 明亮主题 */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --bg-card: #ffffff;
  --text-main: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;
  --primary: #007AFF;
  --primary-light: #E3F2FD;
  --border: #e0e0e0;
  --grid-line: 1px solid #e0e0e0;
  --grid-line-dark: 1px solid #d0d0d0;
}

/* 暗黑主题 */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-alt: #2a2a2a;
  --bg-card: #2a2a2a;
  --text-main: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --primary: #0A84FF;
  --primary-light: #1C3A5F;
  --border: #333333;
  --grid-line: 1px solid #333333;
  --grid-line-dark: 1px solid #444444;
}

/* 暖光主题 */
[data-theme="warm"] {
  --bg: #FFF8F0;
  --bg-alt: #F5EBE0;
  --bg-card: #FFF8F0;
  --text-main: #3A2E2E;
  --text-secondary: #7A6B6B;
  --text-muted: #A89B9B;
  --primary: #D48B5B;
  --primary-light: #F5E6D8;
  --border: #E8D5C4;
  --grid-line: 1px solid #E8D5C4;
  --grid-line-dark: 1px solid #D5C4B3;
}

/* 墨影主题 */
[data-theme="ink"] {
  --bg: #F0F0F0;
  --bg-alt: #E0E0E0;
  --bg-card: #F0F0F0;
  --text-main: #1A1A1A;
  --text-secondary: #4A4A4A;
  --text-muted: #7A7A7A;
  --primary: #2C3E50;
  --primary-light: #D5DBDB;
  --border: #C0C0C0;
  --grid-line: 1px solid #C0C0C0;
  --grid-line-dark: 1px solid #B0B0B0;
}

/* ===================================
   全局样式
   =================================== */

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s var(--ease-out),
              color 0.3s var(--ease-out);
}

/* ===================================
   页面切换系统
   =================================== */

.page {
  display: none;
}

.page.active {
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ===================================
   底部标签栏
   =================================== */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg);
  border-top: var(--grid-line-dark);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  transition: background-color 0.4s var(--ease-out),
              border-color 0.4s var(--ease-out);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  color: var(--text-muted);
  transition: color 0.3s var(--ease-out);
}

.tab-item.active {
  color: var(--primary);
}

.tab-icon {
  width: 24px;
  height: 24px;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
}

/* ===================================
   顶部导航
   =================================== */

.header {
  padding: var(--spacing-lg);
  text-align: center;
  position: relative;
}

.header-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 var(--spacing-xs);
  letter-spacing: 2px;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ===================================
   主题选择器
   =================================== */

.theme-selector {
  position: absolute;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s var(--ease-out);
}

.theme-toggle:hover {
  background: var(--bg-alt);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.theme-panel {
  position: absolute;
  top: 48px;
  right: 0;
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
  min-width: 200px;
}

.theme-panel.show {
  display: block;
}

.theme-panel h4 {
  margin: 0 0 var(--spacing-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.theme-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background-color 0.2s var(--ease-out);
}

.theme-option:hover {
  background: var(--bg-alt);
}

.theme-option.active {
  background: var(--primary-light);
  color: var(--primary);
}

.theme-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

/* ===================================
   主内容区
   =================================== */

.main-content {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  min-height: calc(100vh - 64px - env(safe-area-inset-bottom)); /* Fallback */
  min-height: calc(100dvh - 64px - env(safe-area-inset-bottom));
}

.page {
  display: none;
  padding: 0 var(--spacing-lg);
}

.page.active {
  display: block;
}

/* ===================================
   搜索栏
   =================================== */

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius-lg);
  margin: var(--spacing-md) 0;
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ===================================
   记录卡片
   =================================== */

.items-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.item-card {
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out),
              box-shadow 0.2s var(--ease-out),
              border-color 0.3s var(--ease-out);
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-sm);
}

.item-card-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  flex: 1;
  margin-right: var(--spacing-sm);
}

.item-card-category {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-alt);
  color: var(--text-muted);
  white-space: nowrap;
}

.item-card-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
}

.item-card-notes {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===================================
   空状态
   =================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl) 0;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state p {
  margin: 0;
  font-size: 16px;
}

.empty-state-hint {
  font-size: 13px;
  margin-top: var(--spacing-xs);
}

/* ===================================
   详情页
   =================================== */

.detail-page {
  padding: 0;
}

.page-header {
  display: flex;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: var(--grid-line);
  background: var(--bg);
}

.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: background-color 0.3s var(--ease-out);
}

.back-btn:hover {
  background: var(--bg-alt);
}

.back-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-main);
}

.page-header h2 {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-main);
  letter-spacing: 3px;
  margin-right: 40px;
}

.detail-content {
  padding: var(--spacing-lg);
}

.detail-field {
  margin-bottom: var(--spacing-lg);
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.detail-value {
  font-size: 16px;
  color: var(--text-main);
  line-height: 1.6;
}

.detail-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: var(--grid-line);
}

.detail-action-btn {
  flex: 1;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  background: var(--bg-alt);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  transition: background-color 0.3s var(--ease-out);
}

.detail-action-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.detail-action-btn svg {
  width: 18px;
  height: 18px;
}

/* ===================================
   表单页
   =================================== */

.form-page {
  padding: 0;
}

.form-container {
  padding: var(--spacing-lg);
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--spacing-md);
  border: var(--grid-line);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 14px;
  transition: border-color 0.3s var(--ease-out),
              box-shadow 0.3s var(--ease-out);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

/* Rich Editor Toolbar */
.rich-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-card);
  border: var(--grid-line);
  border-bottom: none;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  flex-wrap: wrap;
}

.rich-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.rich-toolbar-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.rich-toolbar-btn.active {
  background: var(--primary);
  color: white;
}

.rich-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color, #e0e0e0);
  margin: 0 4px;
}

/* Rich Editor Content */
.rich-editor {
  min-height: 180px;
  padding: var(--spacing-md);
  border: var(--grid-line);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  background: var(--bg-card);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s var(--ease-out),
              box-shadow 0.3s var(--ease-out);
  overflow-y: auto;
  max-height: 500px;
}

.rich-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.rich-editor:empty::before {
  content: attr(placeholder);
  color: var(--text-placeholder, #aaa);
  pointer-events: none;
}

.rich-editor blockquote {
  border-left: 3px solid var(--primary);
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--primary-light);
  color: var(--text-secondary);
}

.rich-editor h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 6px;
}

.rich-editor ul, .rich-editor ol {
  padding-left: 24px;
  margin: 4px 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.form-action-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: background-color 0.3s var(--ease-out);
}

.form-action-btn:hover {
  background: var(--bg-alt);
}

.form-action-btn svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

/* ===================================
   个人页面
   =================================== */

.profile-container {
  padding: var(--spacing-lg) 0;
}

.profile-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--spacing-md);
}

.profile-avatar svg {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
}

.profile-name {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.settings-container {
  padding: 0 var(--spacing-lg);
}

.settings-section {
  margin-bottom: var(--spacing-xl);
}

.settings-section-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-sm);
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-item:hover {
  background: var(--bg-alt);
  transform: translateX(4px);
  border-color: var(--primary);
}

.settings-item:active {
  transform: scale(0.98) translateX(2px);
  background: var(--primary-light);
  transition: all 0.1s ease;
}

/* 点击涟漪效果 */
.settings-item::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
  pointer-events: none;
}

.settings-item:active::after {
  width: 300px;
  height: 300px;
  opacity: 0.1;
  transition: 0s;
}

.settings-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.danger-item {
  border-color: #ff4d4f33;
}

.danger-item:hover {
  background: #fff1f0;
}

.danger-item span {
  color: #ff4d4f;
}

.about-item {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-xs);
}

.about-version {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===================================
   悬浮操作按钮 (FAB)
   =================================== */

.fab {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: none; /* 默认隐藏，由 JS 控制显示 */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.3s var(--ease-spring);
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.fab:active {
  transform: scale(0.95);
}

.fab svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.5;
}

/* 移动端 FAB 位置调整 */
@media (max-width: 640px) {
  .fab {
    bottom: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
  }
  
  .fab svg {
    width: 20px;
    height: 20px;
  }
}

/* ===================================
   主题选择面板
   =================================== */

.theme-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 199;
}

.theme-overlay.active {
  display: block;
}

.theme-selector-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius-xl);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: transform 0.3s var(--ease-spring),
              opacity 0.3s var(--ease-out);
  max-width: 300px;
  width: 90%;
}

.theme-selector-panel.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.theme-selector-panel h3 {
  margin: 0 0 var(--spacing-md);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.theme-card {
  padding: var(--spacing-md);
  border: var(--grid-line);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out),
              box-shadow 0.2s var(--ease-out);
  text-align: center;
}

.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.theme-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto var(--spacing-sm);
  border: 2px solid var(--border);
}

.theme-name {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===================================
   提示消息
   =================================== */

.toast {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom) + var(--spacing-lg));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text-main);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: var(--grid-line);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out),
              transform 0.3s var(--ease-out);
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================================
   键盘快捷键帮助
   =================================== */

.hotkeys-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hotkeys-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.hotkeys-modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
}

.hotkeys-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: var(--grid-line);
}

.hotkeys-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.hotkeys-close {
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

.hotkeys-body {
  padding: var(--spacing-lg);
}

.hotkeys-group h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin: var(--spacing-md) 0 var(--spacing-sm);
  letter-spacing: 0.5px;
}

.hotkeys-group:first-child h4 {
  margin-top: 0;
}

.hotkeys-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}

.hotkeys-label {
  font-size: 14px;
  color: var(--text-main);
}

.hotkeys-item kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ===================================
   响应式设计
   =================================== */

@media (max-width: 480px) {
  .header {
    padding: var(--spacing-md);
  }
  
  .header-title {
    font-size: 20px;
  }
  
  .item-card {
    padding: var(--spacing-sm);
  }
  
  .item-card-title {
    font-size: 14px;
  }
}

/* ===================================
   桌面端响应式优化 (v6.3)
   设计理念：居中对齐、自适应宽度、多列网格
   =================================== */

/* ---- 平板端 (768px+) ---- */
@media (min-width: 768px) {
  .main-content {
    max-width: 960px;
    margin: 0 auto;
  }

  /* 底部标签栏居中约束 */
  .tab-bar {
    max-width: 560px;
    width: 100%;
    margin-left: auto !important;
    margin-right: auto !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  }

  .items-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
  }

  /* 卡片 hover 效果增强 */
  .item-card {
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  }

  .item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
  }

  /* 设置项最大宽度 */
  .settings-item {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }

  /* 表单页居中 */
  #page-form .form-layout {
    max-width: 680px;
    margin: 0 auto;
  }

  /* 详情页居中 */
  #page-detail {
    max-width: 680px;
    margin: 0 auto;
  }

  /* 回收站页居中 */
  #page-trash {
    max-width: 960px;
    margin: 0 auto;
  }

  /* 统计页居中 */
  #page-stats {
    max-width: 960px;
    margin: 0 auto;
  }
}

/* ---- 桌面端 (1024px+) ---- */
@media (min-width: 1024px) {
  .main-content {
    max-width: 1100px;
  }

  .tab-bar {
    max-width: 640px;
  }

  .items-container {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-xl);
  }

  /* 增大卡片间距 */
  .record-list {
    gap: var(--spacing-lg) !important;
  }
}

/* ---- 宽屏桌面 (1280px+) ---- */
@media (min-width: 1280px) {
  .main-content {
    max-width: 1200px;
  }

  .tab-bar {
    max-width: 720px;
  }

  .items-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- 大屏 (1600px+) ---- */
@media (min-width: 1600px) {
  .main-content {
    max-width: 1400px;
  }

  .tab-bar {
    max-width: 800px;
  }

  .items-container {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xl);
  }

  /* 放大字号 */
  body {
    font-size: 16px;
  }

  .header-bar-title {
    font-size: 24px;
  }
}

/* ---- 桌面端 UX 组件适配 ---- */
@media (min-width: 768px) {
  /* HeaderBar 撑满内容区 */
  .header-bar {
    padding: var(--spacing-md) var(--spacing-lg);
  }

  /* 分类标签居中排列 */
  #category-tabs-container {
    display: flex;
    justify-content: center;
    padding: var(--spacing-sm) 0;
  }

  .category-tabs {
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    flex-wrap: wrap;
    justify-content: center;
  }

  /* 精选卡片居中 */
  .featured-card {
    margin: var(--spacing-lg) auto;
    max-width: 600px;
  }

  /* 记录列表 (UX HomePage 版) 居中 */
  .record-list {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-xl);
  }

  /* 空状态居中 */
  .empty-state,
  .loading-state,
  .error-state {
    padding: var(--spacing-xl);
  }

  /* 个人页面居中 */
  .profile-container {
    max-width: 700px;
    margin: 0 auto;
  }

  /* 可视化区域居中 */
  #visuals-container {
    max-width: 700px;
    margin: 0 auto;
  }
}

/* ---- 桌面端 FAB 按钮跟随内容区 ---- */
@media (min-width: 768px) and (max-width: 1023px) {
  .fab {
    right: calc((100vw - 960px) / 2 + 24px);
    bottom: 100px;
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .fab {
    right: calc((100vw - 1100px) / 2 + 24px);
    bottom: 100px;
  }
}

@media (min-width: 1280px) and (max-width: 1599px) {
  .fab {
    right: calc((100vw - 1200px) / 2 + 24px);
    bottom: 100px;
  }
}

@media (min-width: 1600px) {
  .fab {
    right: calc((100vw - 1400px) / 2 + 24px);
    bottom: 100px;
  }
}

/* ===================================
   Photo Upload
   =================================== */
.photo-upload-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border: 2px dashed var(--grid-line, #e8e8e8);
  border-radius: var(--border-radius, 20px);
  background: var(--bg-alt, #fafafa);
  align-items: center;
}

.btn-photo-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary, #1a1a1a);
  color: var(--bg, #fff);
  border: none;
  border-radius: var(--border-radius, 20px);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-photo-add:active {
  opacity: 0.8;
}

.photo-hint {
  font-size: 12px;
  color: var(--text-muted, #b8b8b8);
  margin: 0;
  text-align: center;
}

.photo-preview {
  margin-top: 12px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--border-radius-sm, 12px);
  overflow: hidden;
  border: 1px solid var(--grid-line, #e8e8e8);
}

.photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}

.photo-remove:hover {
  background: rgba(255, 0, 0, 0.8);
  transform: scale(1.1);
}

/* Detail page photos */
.detail-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.detail-photo-item {
  aspect-ratio: 1;
  border-radius: var(--border-radius, 20px);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s;
  border: 1px solid var(--grid-line, #e8e8e8);
}

.detail-photo-item:hover {
  transform: scale(1.05);
}

.detail-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Photo viewer (fullscreen) */
.photo-viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
}

.photo-viewer-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
}

.photo-viewer-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--border-radius, 20px);
}

.photo-viewer-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.photo-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===================================
   Category Management
   =================================== */
.category-modal,
.category-manager-modal {
  max-width: 450px;
}

.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid-line, #e8e8e8);
  transition: background 0.2s;
}

.category-item:last-child {
  border-bottom: none;
}

.category-item:hover {
  background: var(--bg-alt, #fafafa);
}

.category-item.preset {
  background: var(--bg-alt, #fafafa);
  opacity: 0.7;
}

.category-name {
  font-size: 14px;
  color: var(--text-main, #1a1a1a);
  flex: 1;
}

.category-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--text-muted, #b8b8b8);
  color: #fff;
  border-radius: 12px;
  margin-left: 8px;
}

.category-delete-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  color: var(--text-muted, #999);
  padding: 0;
}

.category-delete-btn:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #ff4444;
}

/* ===================================
   Sync Modal
   =================================== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg, #fff);
  border-radius: var(--border-radius-xl);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  transform: scale(0.9);
  transition: transform 0.3s var(--ease-spring);
}

.modal.active .modal-content {
  transform: scale(1);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-main, #1a1a1a);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted, #999);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sync-status {
  padding: 12px;
  border-radius: var(--border-radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.sync-status.configured {
  background: #e8f5e9;
  color: #2e7d32;
}

.sync-status.not-configured {
  background: #fff3e0;
  color: #e65100;
}

.sync-config-form .form-group {
  margin-bottom: 12px;
}

.sync-config-form label {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-secondary, #666);
}

.sync-config-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #ddd);
  border-radius: var(--border-radius);
  font-size: 14px;
  box-sizing: border-box;
  background: var(--bg, #fff);
  color: var(--text-main, #1a1a1a);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary, #007AFF);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary:active {
  opacity: 0.8;
}

.sync-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn-sync {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--primary, #007AFF);
  background: var(--bg, #fff);
  color: var(--primary, #007AFF);
  border-radius: var(--border-radius);
  font-size: 14px;
  cursor: pointer;
}

.btn-sync:active {
  opacity: 0.8;
}

.btn-sync:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sync-log {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-alt, #f5f5f5);
  border-radius: var(--border-radius);
  font-size: 12px;
  max-height: 120px;
  overflow-y: auto;
  font-family: var(--font-mono, monospace);
}

.sync-log-item {
  margin-bottom: 4px;
  color: var(--text-secondary, #666);
}

.sync-log-item.success {
  color: #2e7d32;
}

.sync-log-item.error {
  color: #c62828;
}

/* ===================================
   分类和标签筛选
   =================================== */

.category-filter,
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, #eee);
}

.category-item,
.tag-item {
  padding: 6px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 20px;
  background: var(--bg-card, #fff);
  color: var(--text-secondary, #666);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.category-item:hover,
.tag-item:hover {
  border-color: var(--primary, #007AFF);
  color: var(--primary, #007AFF);
}

.category-item.active,
.tag-item.active {
  background: var(--primary, #007AFF);
  border-color: var(--primary, #007AFF);
  color: #fff;
}

/* 标签云 */
.tag-cloud {
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.tag-cloud-item {
  padding: 6px 14px;
  background: var(--bg-alt, #f5f5f5);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary, #666);
}

.tag-cloud-item:hover {
  background: var(--primary, #007AFF);
  color: #fff;
  transform: scale(1.05);
}

.empty-tags {
  text-align: center;
  color: var(--text-muted, #999);
  padding: 20px;
}

/* 表单标签输入 */
.form-hint {
  font-size: 12px;
  color: var(--text-muted, #999);
  margin-top: 4px;
  margin-bottom: 0;
}

/* 卡片标签显示 */
.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
}

.tag-small {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg-alt, #f5f5f5);
  border-radius: 10px;
  color: var(--text-muted, #888);
}

/* 标签 Chip 输入框 */
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background: var(--bg);
  min-height: 44px;
  transition: border-color 0.2s;
}

.tag-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.tag-chip-input {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  animation: chipIn 0.2s var(--ease-spring);
}

@keyframes chipIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tag-chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 16px;
  line-height: 1;
  margin-left: 2px;
}

.tag-chip-remove:hover {
  opacity: 1;
  color: var(--danger, #ff4d4f);
}

.tag-input-field {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text-main);
  flex: 1;
  min-width: 100px;
}

.tag-input-field::placeholder {
  color: var(--text-muted);
}

/* 详情页标签 */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 13px;
  padding: 4px 10px;
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
  border-radius: 14px;
  color: var(--primary, #007AFF);
}

/* 登录按钮 (未登录时显示) */
.profile-login-btn {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  margin-top: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}
.profile-login-btn:hover { opacity: 0.9; transform: scale(1.02); }
.profile-login-btn:active { transform: scale(0.97); }
.profile-login-btn svg { flex-shrink: 0; }

/* ===================================
   水墨风主题 (4 个)
   =================================== */

/* 青山绿水 - 青绿山水 */
[data-theme="cyan-mountain"] {
  --bg: #F7FBF8;
  --bg-alt: #E8F5E9;
  --bg-card: #F7FBF8;
  --text-main: #1B3A2D;
  --text-secondary: #4A7C5F;
  --text-muted: #7BAF8F;
  --primary: #2D6A4F;
  --primary-light: #D8F3DC;
  --border: #B7E4C7;
  --grid-line: 1px solid #B7E4C7;
  --grid-line-dark: 1px solid #95D5B2;
}

/* 暗香疏影 - 梅花 */
[data-theme="plum-blossom"] {
  --bg: #FFF5F7;
  --bg-alt: #FFE8EE;
  --bg-card: #FFF5F7;
  --text-main: #3D1C2F;
  --text-secondary: #8B4567;
  --text-muted: #B87A9A;
  --primary: #C2185B;
  --primary-light: #FCE4EC;
  --border: #F8BBD0;
  --grid-line: 1px solid #F8BBD0;
  --grid-line-dark: 1px solid #F48FB1;
}

/* 竹雨松风 - 竹青 */
[data-theme="bamboo-rain"] {
  --bg: #F5FFF5;
  --bg-alt: #E0F7E0;
  --bg-card: #F5FFF5;
  --text-main: #1A3320;
  --text-secondary: #3E6B48;
  --text-muted: #6B9E7A;
  --primary: #2E7D32;
  --primary-light: #E8F5E9;
  --border: #A5D6A7;
  --grid-line: 1px solid #A5D6A7;
  --grid-line-dark: 1px solid #81C784;
}

/* 远水含烟 - 水墨淡彩 */
[data-theme="distant-water"] {
  --bg: #F8F9FA;
  --bg-alt: #ECEFF1;
  --bg-card: #F8F9FA;
  --text-main: #263238;
  --text-secondary: #546E7A;
  --text-muted: #90A4AE;
  --primary: #455A64;
  --primary-light: #ECEFF1;
  --border: #CFD8DC;
  --grid-line: 1px solid #CFD8DC;
  --grid-line-dark: 1px solid #B0BEC5;
}

/* ===================================
   响应式优化
   =================================== */

/* ===================================
   UX 打磨: 标签 Chip 输入系统
   =================================== */

.tag-input-wrapper {
  position: relative;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  background: var(--bg, #fff);
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: text;
}

.tag-input-wrapper:focus-within {
  border-color: var(--primary, #007AFF);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  background: linear-gradient(135deg, var(--primary, #007AFF), #5856d6);
  color: #fff;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  animation: chipPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  white-space: nowrap;
  max-width: 150px;
}

.tag-chip .chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-chip .chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}

.tag-chip .chip-remove:hover {
  background: rgba(255, 255, 255, 0.5);
}

.tag-chip.duplicate {
  animation: chipShake 0.4s ease;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
}

.tag-input-field {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--text, #333);
  padding: 2px 4px;
  line-height: 24px;
}

.tag-input-field::placeholder {
  color: var(--text-muted, #bbb);
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  max-height: 150px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
}

.tag-suggestions.show {
  display: block;
}

.tag-suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #333);
  transition: background 0.15s;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
  color: var(--primary, #007AFF);
}

.tag-suggestion-item .tag-count {
  float: right;
  color: var(--text-muted, #999);
  font-size: 11px;
}

/* ===================================
   UX 打磨: 图片压缩反馈
   =================================== */

.photo-upload-progress {
  position: relative;
  background: var(--bg-alt, #f5f5f5);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: none;
}

.photo-upload-progress.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary, #666);
}

.progress-bar {
  height: 4px;
  background: var(--border, #e0e0e0);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary, #007AFF), #5856d6);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.photo-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}

.photo-size-comparison {
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-size-original {
  color: var(--text-muted, #999);
  text-decoration: line-through;
}

.photo-size-arrow {
  color: var(--text-secondary, #666);
}

.photo-size-compressed {
  color: var(--success, #34c759);
  font-weight: 600;
}

.photo-compression-ratio {
  padding: 2px 6px;
  background: rgba(52, 199, 89, 0.1);
  color: var(--success, #34c759);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.photo-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.photo-preview-item img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.photo-preview-item .photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.photo-preview-item .photo-remove:hover {
  background: rgba(255, 59, 48, 0.9);
}

.photo-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(52, 199, 89, 0.1), rgba(0, 122, 255, 0.05));
  border-radius: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary, #666);
}

.photo-summary .summary-total {
  font-weight: 600;
  color: var(--primary, #007AFF);
}

/* ===================================
   动画关键帧
   =================================== */

@keyframes chipPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes chipShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.photo-upload-progress.active .progress-header {
  animation: progressPulse 1.5s ease infinite;
}

/* ===================================
   日历视图
   =================================== */

.calendar-container {
  background: var(--bg, #fff);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-alt, #f5f5f5);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text, #333);
  transition: background 0.2s;
}

.cal-nav-btn:hover {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
  color: var(--primary, #007AFF);
}

.cal-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cal-year {
  font-size: 14px;
  color: var(--text-secondary, #666);
}

.cal-month {
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #333);
}

.cal-week-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #333);
}

.cal-views-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: center;
}

.cal-view-btn {
  padding: 4px 16px;
  border-radius: 16px;
  border: 1px solid var(--border, #e0e0e0);
  background: var(--bg, #fff);
  color: var(--text-secondary, #666);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.cal-view-btn.active {
  background: var(--primary, #007AFF);
  color: #fff;
  border-color: var(--primary, #007AFF);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

.cal-weekday {
  font-size: 12px;
  color: var(--text-muted, #999);
  font-weight: 500;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* CalendarPlugin 实际使用的类名（与 .cal-* 等效） */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
  padding: 0 4px;
}
.calendar-weekdays .weekday {
  font-size: 12px;
  color: var(--text-muted, #999);
  font-weight: 500;
  padding: 4px 0;
}
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  min-height: 44px;
}
.calendar-day:hover { background: var(--bg-alt, #f5f5f5); }
.calendar-day.other-month { opacity: 0.3; }
.calendar-day.today { background: var(--primary-light, rgba(0, 122, 255, 0.1)); }
.calendar-day.today .day-number { color: var(--primary, #007AFF); font-weight: 700; }
.calendar-day.selected { background: var(--primary, #007AFF); color: #fff; }
.calendar-day .day-number { font-size: 14px; font-weight: 500; }
.calendar-day .day-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary, #007AFF);
}
.calendar-day.selected .day-indicator { background: #fff; }

/* 日历导航按钮 */
.calendar-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-alt, #f5f5f5);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text, #333);
}
.calendar-nav-btn svg { width: 18px; height: 18px; }
.calendar-nav-btn:hover { background: var(--primary-light, rgba(0, 122, 255, 0.1)); }

.calendar-title { display: flex; align-items: baseline; gap: 8px; flex: 1; justify-content: center; }
.calendar-title h2 { font-size: 16px; margin: 0; }

.calendar-view-toggle { display: flex; gap: 4px; }
.calendar-view-toggle button {
  padding: 2px 12px;
  border-radius: 12px;
  border: 1px solid var(--border, #e0e0e0);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}
.calendar-view-toggle button.active {
  background: var(--primary, #007AFF);
  color: #fff;
  border-color: var(--primary, #007AFF);
}

/* 日历日期详情 */
.day-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e0e0e0);
}
.day-detail h3 { font-size: 14px; margin: 0 0 8px; }
.day-detail-empty { color: var(--text-muted, #999); font-size: 13px; }
.day-detail-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e0e0e0);
}
.day-detail-item h4 { font-size: 14px; margin: 0 0 4px; }
.day-detail-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.day-detail-tags .tag { font-size: 11px; color: var(--primary, #007AFF); }
.day-detail-notes { font-size: 12px; color: var(--text-secondary, #666); margin: 0; }

/* 周视图 */
.week-view { display: flex; flex-direction: column; gap: 8px; }
.week-day { padding: 8px; border-radius: 8px; background: var(--bg-alt, #f5f5f5); }
.week-day.today { border-left: 3px solid var(--primary, #007AFF); }
.week-day-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.week-day-name { font-weight: 600; }
.week-day-date { color: var(--text-muted, #999); }
.week-day-items { display: flex; flex-direction: column; gap: 4px; }
.week-item { padding: 4px 8px; background: #fff; border-radius: 4px; font-size: 12px; }
.week-empty { font-size: 12px; color: var(--text-muted, #999); }

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  min-height: 44px;
}

.cal-day:hover {
  background: var(--bg-alt, #f5f5f5);
}

.cal-day.other-month {
  opacity: 0.3;
}

.cal-day.today {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
}

.cal-day.today .cal-day-number {
  color: var(--primary, #007AFF);
  font-weight: 700;
}

.cal-day.selected {
  background: var(--primary, #007AFF);
  color: #fff;
}

.cal-day.selected .cal-day-number {
  color: #fff;
  font-weight: 700;
}

.cal-day-number {
  font-size: 14px;
  color: var(--text, #333);
  line-height: 1;
}

.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, #007AFF);
}

.cal-day.selected .cal-dot {
  background: rgba(255, 255, 255, 0.7);
}

/* 周视图 */
.cal-week-grid {
  display: flex;
  gap: 8px;
}

.cal-week-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-alt, #f5f5f5);
}

.cal-week-item:hover {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
}

.cal-week-item.today {
  background: var(--primary-light, rgba(0, 122, 255, 0.15));
  border: 2px solid var(--primary, #007AFF);
}

.cal-week-item.selected {
  background: var(--primary, #007AFF);
  color: #fff;
}

.cal-week-item.selected .cal-week-day-name,
.cal-week-item.selected .cal-week-day-num,
.cal-week-item.selected .cal-week-count {
  color: #fff;
}

.cal-week-item.today .cal-week-day-num {
  color: var(--primary, #007AFF);
  font-weight: 700;
}

.cal-week-day-name {
  font-size: 11px;
  color: var(--text-muted, #999);
  margin-bottom: 4px;
}

.cal-week-day-num {
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #333);
}

.cal-week-count {
  font-size: 11px;
  color: var(--primary, #007AFF);
  margin-top: 4px;
}

/* 日历日列表 */
.calendar-day-items {
  margin-top: 8px;
}

.calendar-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.calendar-day-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #333);
}

.cal-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--border, #e0e0e0);
  background: var(--bg, #fff);
  color: var(--primary, #007AFF);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.cal-back-btn:hover {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
}

/* ===================================
   模板系统
   =================================== */

.btn-use-template {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px dashed var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--bg, #fff);
  color: var(--primary, #007AFF);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-use-template:hover {
  background: var(--primary-light, rgba(0, 122, 255, 0.05));
  border-color: var(--primary, #007AFF);
}

.template-selector {
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  animation: templateSlideIn 0.2s ease;
}

@keyframes templateSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #333);
}

.template-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-alt, #f5f5f5);
  color: var(--text-secondary, #666);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.template-close-btn:hover {
  background: var(--primary, #007AFF);
  color: #fff;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.template-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--bg-alt, #f9f9f9);
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  background: var(--primary-light, rgba(0, 122, 255, 0.1));
  border-color: var(--primary, #007AFF);
  transform: translateY(-2px);
}

.template-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.template-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.template-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #333);
}

.template-desc {
  font-size: 11px;
  color: var(--text-muted, #999);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===================================
   模板管理页
   =================================== */

#page-template-manager {
  padding-bottom: 80px;
  overflow-y: auto;
}

.template-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: var(--grid-line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.tm-back-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--border-radius-sm);
}

.tm-back-btn:hover {
  background: var(--bg-alt);
}

.tm-back-btn svg {
  width: 20px;
  height: 20px;
}

.tm-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.template-manager-content {
  padding: var(--spacing-lg);
}

.template-manager-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.template-manager-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: var(--grid-line);
  border-radius: var(--border-radius);
}

.template-item-icon {
  font-size: 24px;
  margin-right: var(--spacing-md);
}

.template-item-info {
  flex: 1;
}

.template-item-name {
  font-weight: 600;
  font-size: 16px;
}

.template-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.template-item-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-sm.btn-use {
  background: var(--primary);
  color: white;
}

.btn-sm.btn-use:hover {
  opacity: 0.9;
}

.btn-sm.btn-delete {
  background: transparent;
  color: #ff4d4f;
  border: 1px solid #ff4d4f;
}

.btn-sm.btn-delete:hover {
  background: #ff4d4f;
  color: white;
}

.btn-add-template {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  width: 100%;
  padding: var(--spacing-md);
  margin-top: var(--spacing-lg);
  background: var(--bg-alt);
  border: 2px dashed var(--border);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-template:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===================================
   表单页面适配
   =================================== */

#page-form {
  padding-bottom: 80px; /* 防止底部导航栏遮挡 */
  overflow-y: auto;
}

/* ===================================
   时间线/故事模式
   =================================== */

.timeline-container {
  padding: 16px;
  padding-bottom: 80px;
  position: relative;
}

/* 那年今日 */
.timeline-on-this-day {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 时间线区块头部 */
.timeline-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.timeline-section-header .header-icon {
  font-size: 20px;
}

.timeline-section-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-main);
  font-weight: 600;
}

/* 年份标题 */
.timeline-year-header {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin: 24px 0 16px;
  padding-left: 8px;
  border-left: 4px solid var(--primary);
}

/* 月份标题 */
.timeline-month-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 16px 0 8px;
  padding-left: 28px; /* 对齐时间线 */
}

/* 时间线容器 */
.timeline-month-items {
  position: relative;
  padding-left: 24px;
}

/* 时间线竖线 */
.timeline-month-items::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

/* 时间线条目 */
.timeline-item {
  position: relative;
  margin-bottom: 16px;
}

/* 时间线圆点 */
.timeline-dot {
  position: absolute;
  left: -21px; /* 24px padding - 3px dot */
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--primary);
  z-index: 1;
}

/* 时间线卡片 */
.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.timeline-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-category {
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.timeline-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.timeline-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.timeline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.tag-pill {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
}

.timeline-photos {
  margin-top: 8px;
}

.photo-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-alt);
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-hint {
  font-size: 13px;
  margin-top: 4px;
}

/* ===================================
   数据可视化
   =================================== */

.visuals-container {
  padding: 16px;
  margin-bottom: 16px;
}

.visuals-header {
  margin-bottom: 20px;
}

.visuals-header h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text-main);
}

.visuals-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.visuals-summary strong {
  color: var(--primary);
  font-weight: 600;
}

.visuals-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* 热力图 */
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--bg-alt);
  transition: transform 0.2s;
}

.heatmap-cell:hover {
  transform: scale(1.5);
}

.heatmap-cell.level-0 { background: var(--bg-alt); }
.heatmap-cell.level-1 { background: rgba(0, 122, 255, 0.2); }
.heatmap-cell.level-2 { background: rgba(0, 122, 255, 0.5); }
.heatmap-cell.level-3 { background: rgba(0, 122, 255, 0.8); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.heatmap-legend .heatmap-cell {
  width: 10px;
  height: 10px;
}

/* 趋势图 */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 10px;
}

.trend-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.trend-bar {
  width: 100%;
  max-width: 24px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: height 0.5s ease;
}

.trend-bar-value {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-main);
  white-space: nowrap;
}

.trend-bar-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

/* 分类分布条 */
.category-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-label {
  width: 60px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.cat-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.cat-value {
  width: 60px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* 分类占比列表 (新版) */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.category-name {
  font-weight: 500;
  color: var(--text-main);
}

.category-count {
  color: var(--text-muted);
  font-size: 12px;
}

.category-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ===================================
   模板管理页面样式
   =================================== */

.template-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: var(--grid-line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tm-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.tm-back-btn:hover {
  background: var(--bg-alt);
}

.tm-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.template-manager-content {
  padding: var(--spacing-md);
  min-height: calc(100vh - 120px); /* Fallback */
  min-height: calc(100dvh - 120px);
}

.template-manager-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.template-manager-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.template-manager-empty p {
  margin: 8px 0;
  font-size: 16px;
}

.template-manager-empty .hint {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.8;
}

.template-manager-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-md);
}

.template-manager-card {
  background: var(--bg);
  border: var(--grid-line);
  border-radius: 12px;
  padding: var(--spacing-md);
  transition: transform 0.2s, box-shadow 0.2s;
}

.template-manager-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.template-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.template-card-header .template-icon {
  font-size: 28px;
  line-height: 1;
}

.template-card-info {
  flex: 1;
  min-width: 0;
}

.template-card-info .template-name {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-info .template-category {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.template-manager-card .template-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-sm.btn-use {
  background: var(--primary);
  color: white;
}

.btn-sm.btn-use:hover {
  opacity: 0.9;
}

.btn-sm.btn-delete {
  background: transparent;
  color: #ff4d4f;
  border: 1px solid #ff4d4f;
}

.btn-sm.btn-delete:hover {
  background: #ff4d4f;
  color: white;
}

/* ===================================
   Toast 提示
   =================================== */
/* ===================================
   分类管理弹窗
   =================================== */
.category-manager-list {
  margin-top: 16px;
}

.category-manager-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #eee;
}

.category-manager-item:last-child {
  border-bottom: none;
}

.category-name {
  font-weight: 500;
}

.category-actions {
  display: flex;
  gap: 8px;
}

.btn-sm.btn-edit {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-sm.btn-edit:hover {
  background: var(--primary);
  color: white;
}

.btn-danger-outline {
  background: transparent;
  color: #ff4d4f;
  border: 1px solid #ff4d4f;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-danger-outline:hover {
  background: #ff4d4f;
  color: white;
}

.empty-hint {
  text-align: center;
  color: #999;
  padding: 20px;
}

.btn-add-category {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 10px;
  margin-bottom: 16px;
  background: var(--bg-alt);
  border: 2px dashed var(--border);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-category:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===================================
   v3.4.0 UX 改进
   =================================== */

/* 在编辑/详情页面隐藏 FAB (v3.4.0 改进) */
.page-form.active ~ .fab,
.page-detail.active ~ .fab,
body:has(.page-form.active) .fab,
body:has(.page-detail.active) .fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

/* 改进搜索框 - 增大高度和点击区域 */
.search-bar {
  min-height: 48px;
  padding: 10px 16px;
}

.search-input {
  font-size: 16px; /* 防止 iOS 缩放 */
  min-height: 28px;
  padding: 4px 0;
}

/* 改进分类筛选 - 增大按钮尺寸 */
.category-filter {
  padding: 8px 0;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.category-item {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 15px;
  border-radius: 20px;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 增强卡片点击反馈 */
.item-card {
  position: relative;
  overflow: hidden;
}

.item-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.item-card:active::after {
  opacity: 0.06;
}

/* 增大卡片内边距和行高 */
.item-card {
  padding: 16px;
}

.item-card-title {
  font-size: 17px;
  line-height: 1.4;
  margin-bottom: 6px;
}

.item-card-category {
  font-size: 14px;
  line-height: 1.4;
}

.item-notes {
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0;
}

.item-date {
  font-size: 13px;
  padding: 4px 8px;
}

/* 空状态样式 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 120px;
  height: 120px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.empty-state h3,
.empty-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.empty-state p,
.empty-desc {
  font-size: 14px;
  margin: 0 0 24px;
  max-width: 280px;
}

.empty-add-btn,
.btn-primary-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary, #007AFF);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring),
              background 0.2s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.empty-add-btn:hover,
.btn-primary-empty:hover {
  background: #0056CC;
  transform: scale(1.05);
}

.empty-add-btn:active,
.btn-primary-empty:active {
  transform: scale(0.95);
}

/* 按钮通用改进 - 增大点击区域并增强反馈 */
button,
[role="button"],
.clickable {
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* 按钮按下效果 */
button:active,
[role="button"]:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* 涟漪效果容器 */
button::before,
.settings-item::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: currentColor;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease, opacity 0.3s ease;
  pointer-events: none;
}

button:active::before,
.settings-item:active::before {
  width: 200px;
  height: 200px;
  opacity: 0.1;
  transition: 0s;
}

/* 设置项改进 */
.settings-item {
  min-height: 52px;
  padding: 14px 16px;
  font-size: 15px;
}

/* 表单按钮改进 */
.form-back-btn,
.form-save-btn {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 16px;
}

/* 模态框按钮改进 */
.modal-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* 导航栏图标和文字改进 */
.tab-item {
  min-height: 64px;
  padding: 8px 4px;
}

.tab-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}

.tab-label {
  font-size: 12px;
  font-weight: 500;
}








/* ===================================
   v3.4.0 新增：Sticky 表单布局 & Bottom Sheet
   =================================== */

#page-form {
  padding: 0 !important; /* 覆盖旧样式 */
  overflow: hidden !important;
  height: 100vh; /* Fallback */
  height: 100dvh;
  display: none; /* 默认隐藏，由 .active 控制 */
}

#page-form.active {
  display: block;
}

.form-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.form-header-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.form-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.form-back-btn {
  background: none;
  border: none;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  cursor: pointer;
  min-height: 44px;
}

.header-spacer {
  width: 24px; /* 占位，保持标题居中 */
}

.form-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 20px;
}

.form-footer-sticky {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.form-save-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background-color: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.2s;
}

.form-save-btn:active {
  opacity: 0.8;
}

/* 模板快捷入口 */
.btn-use-template, .btn-save-template {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--primary);
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.btn-use-template:hover, .btn-save-template:hover {
  background: var(--primary-light);
}

/* 底部抽屉 (Bottom Sheet) */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-sheet-overlay.active .bottom-sheet-content {
  transform: translateY(0);
}

.bottom-sheet-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bottom-sheet-header h3 {
  margin: 0;
  font-size: 18px;
}

.bottom-sheet-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.bottom-sheet-body {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.template-sheet-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg-alt);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.template-sheet-item:active, .template-sheet-item:hover {
  border-color: var(--primary);
}

.template-sheet-item h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
}

.template-sheet-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===================================
   v4.0.2 新增：iOS 键盘弹出适配
   =================================== */

/* 当键盘弹出时，减小表单区域高度 */
@media screen and (max-height: 500px) {
  .form-layout {
    padding-bottom: 20px;
  }
  .form-footer-sticky {
    padding-bottom: env(safe-area-inset-bottom, 10px);
  }
}

/* 防止 iOS 键盘弹出时页面缩放 */
input, textarea, select {
  font-size: 16px !important; /* iOS Safari 小于 16px 会触发缩放 */
}

/* 表单输入框聚焦时，确保可见 */
input:focus, textarea:focus {
  scroll-into-view: smooth;
}

/* ===================================
   搜索插件 UI (Search Plugin)
   =================================== */

/* 搜索清除按钮 */
.search-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.search-clear-btn svg {
  width: 16px;
  height: 16px;
}

.search-clear-btn:hover {
  background: var(--bg-alt);
  color: var(--text-main);
}

/* 搜索框加载中状态 */
.search-input.searching {
  opacity: 0.6;
}

/* 搜索历史下拉 */
.search-history-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  z-index: 150;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.clear-history-btn {
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
}

.clear-history-btn:hover {
  color: var(--primary);
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-history-item:hover {
  background: var(--bg-alt);
  color: var(--primary);
}

.search-history-item svg {
  flex-shrink: 0;
  opacity: 0.5;
}

/* 搜索空状态 */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.search-empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.search-query-hint {
  color: var(--text-secondary);
  background: var(--bg-alt);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* 搜索高亮标记 (用于搜索结果中的关键词高亮) */
.search-highlight {
  background: rgba(255, 235, 59, 0.4);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

/* 收藏页搜索过滤支持 */
.favorites-list-item.hidden-by-search {
  display: none;
}

/* ===================================
   元数据徽章 (Metadata Badges) - v6.3
   显示字数、阅读时间、情绪标签等
   =================================== */

/* 记录列表项中的元数据容器 */
.record-list-item .metadata-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

/* 通用徽章 */
.metadata-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  line-height: 1.4;
}

/* 图标徽章 */
.metadata-icon-badges {
  padding: 2px 6px;
}

.metadata-icon-badges svg {
  opacity: 0.6;
}

/* 情绪标签 chips 容器 */
.emotion-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* 单个情绪标签 chip */
.emotion-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

/* 情绪颜色映射 */
.emotion-开心 {
  background: #fef3c7;
  color: #92400e;
}
.emotion-悲伤 {
  background: #dbeafe;
  color: #1e40af;
}
.emotion-愤怒 {
  background: #fee2e2;
  color: #991b1b;
}
.emotion-兴奋 {
  background: #fce7f3;
  color: #9d174d;
}
.emotion-平静 {
  background: #e0f2fe;
  color: #0369a1;
}
.emotion-焦虑 {
  background: #f3e8ff;
  color: #6b21a8;
}
.emotion-放松 {
  background: #d1fae5;
  color: #065f46;
}
.emotion-惊喜 {
  background: #fef9c3;
  color: #854d0e;
}
.emotion-期待 {
  background: #ccfbf1;
  color: #115e59;
}
.emotion-难过 {
  background: #dbeafe;
  color: #1e40af;
}

/* 暗黑主题适配 */
[data-theme="dark"] .emotion-开心 { background: #422006; color: #fcd34d; }
[data-theme="dark"] .emotion-悲伤 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .emotion-愤怒 { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .emotion-兴奋 { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .emotion-平静 { background: #0c4a6e; color: #7dd3fc; }
[data-theme="dark"] .emotion-焦虑 { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .emotion-放松 { background: #022c22; color: #6ee7b7; }
[data-theme="dark"] .emotion-惊喜 { background: #422006; color: #fde047; }
[data-theme="dark"] .emotion-期待 { background: #042f2e; color: #5eead4; }
[data-theme="dark"] .emotion-难过 { background: #1e3a5f; color: #93c5fd; }

/* ===================================
   Markdown 导入/导出 (v6.2)
   =================================== */

/* 导入预览模态框遮罩 */
.md-import-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: mdFadeIn 0.2s ease;
}

@keyframes mdFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 模态框主体 */
.md-import-modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: mdSlideUp 0.3s var(--ease-spring);
}

@keyframes mdSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 模态框头部 */
.md-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: var(--grid-line);
}

.md-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-main);
}

.md-modal-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: background 0.2s;
}

.md-modal-close-btn:hover {
  background: var(--bg-alt);
}

/* 模态框内容 */
.md-modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

.md-import-info p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.md-import-info strong {
  color: var(--text-main);
}

.md-record-names {
  margin: 8px 0 12px 20px;
  padding: 0;
  list-style: disc;
  max-height: 160px;
  overflow-y: auto;
}

.md-record-names li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 2px 0;
}

.md-import-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-alt);
  border-radius: var(--border-radius);
  border-left: 3px solid var(--primary);
}

/* 模态框底部按钮 */
.md-modal-footer {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  border-top: var(--grid-line);
}

.md-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.md-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.md-btn-cancel {
  background: var(--bg-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.md-btn-cancel:hover:not(:disabled) {
  background: var(--border);
}

.md-btn-confirm {
  background: var(--primary);
  color: #fff;
}

.md-btn-confirm:hover:not(:disabled) {
  opacity: 0.9;
}

/* ===================================
   Review Plugin - 回顾机制 (v6.3)
   那年今日、每周回顾、月度总结
   =================================== */

/* 首页回顾区域容器 */
.home-review-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 16px;
}

/* 回顾区块 */
.review-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* 回顾区块头部 */
.review-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-alt);
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
}

.review-section-header:hover {
  background: var(--primary-light);
}

.review-section-icon {
  font-size: 18px;
}

.review-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

.review-section-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
}

.review-section-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

/* 回顾区块内容 */
.review-section-body {
  padding: 12px;
  transition: max-height 0.3s ease;
}

/* ========== 那年今日 ========== */

/* 横向滚动轮播 */
.on-this-day-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.on-this-day-carousel::-webkit-scrollbar {
  display: none;
}

/* 那年今日卡片 */
.on-this-day-card {
  flex: 0 0 200px;
  scroll-snap-align: start;
  background: var(--bg-alt);
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
}

.on-this-day-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.on-this-day-card-cover {
  width: 100%;
  height: 100px;
  overflow: hidden;
  background: var(--bg);
}

.on-this-day-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.on-this-day-card-content {
  padding: 10px;
}

.on-this-day-card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.on-this-day-card-date {
  font-size: 11px;
  color: var(--primary);
  margin: 4px 0;
  font-weight: 500;
}

.on-this-day-card-summary {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.on-this-day-footer {
  text-align: center;
  padding-top: 8px;
}

/* ========== 每周回顾 ========== */

/* 每周统计栏 */
.weekly-stats-bar {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--bg-alt);
  border-radius: var(--border-radius);
  margin-bottom: 12px;
}

.weekly-stats-bar-full {
  margin: 0 16px 16px;
}

.weekly-stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.weekly-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.weekly-stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* 每周时间线 */
.weekly-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 按天分组 */
.weekly-day-group {
  position: relative;
  padding-left: 20px;
}

.weekly-day-group::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.weekly-day-group:last-child::before {
  display: none;
}

.weekly-day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.weekly-day-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 8px;
}

.weekly-day-date {
  font-size: 12px;
  color: var(--text-muted);
}

.weekly-day-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.weekly-day-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 每周单条 */
.weekly-item {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 44px;
}

.weekly-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.weekly-item-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 36px;
}

.weekly-item-content {
  flex: 1;
  min-width: 0;
}

.weekly-item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.weekly-item-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.weekly-item-cover {
  margin: 6px 0;
  border-radius: 8px;
  overflow: hidden;
  max-height: 120px;
}

.weekly-item-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.weekly-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* 每周操作区 */
.weekly-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ========== 月度总结 ========== */

.monthly-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.monthly-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--bg-alt);
  border-radius: var(--border-radius);
  gap: 4px;
}

.monthly-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.monthly-stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.monthly-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 8px 0;
}

.monthly-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.monthly-tag-chip {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  font-weight: 500;
}

.monthly-tag-count {
  font-size: 10px;
  opacity: 0.7;
}

.monthly-actions {
  margin-top: 12px;
}

/* 回顾操作按钮 */
.review-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  min-height: 36px;
}

.review-action-btn:hover {
  opacity: 0.9;
}

.review-action-btn:active {
  transform: scale(0.97);
}

.review-view-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--border-radius);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 32px;
}

.review-view-more-btn:hover {
  background: var(--primary-light);
}

/* ========== 全屏回顾页面 ========== */

.review-full-page {
  min-height: 100vh;
  padding-bottom: 80px;
  background: var(--bg);
}

.review-full-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 56px;
}

.review-full-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  padding: 8px;
  border-radius: var(--border-radius-sm);
}

.review-full-back-btn:hover {
  background: var(--bg-alt);
}

.review-full-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

.review-full-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 全屏回顾卡片 */
.review-full-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.review-full-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.review-full-card-cover {
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  background: var(--bg-alt);
}

.review-full-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.review-full-card-content {
  padding: 12px;
}

.review-full-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.review-full-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

.review-full-card-badge {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.review-full-card-date {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0;
}

.review-full-card-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0;
  line-height: 1.5;
}

.review-full-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

/* 全屏空状态 */
.review-full-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.review-full-empty svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.review-full-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.review-full-empty-desc {
  font-size: 14px;
  margin: 0 0 4px;
}

.review-full-empty-hint {
  font-size: 12px;
  opacity: 0.7;
  margin: 0;
}

.review-full-empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  cursor: pointer;
  margin-top: 16px;
  min-height: 44px;
}

.review-full-empty-btn:hover {
  opacity: 0.9;
}

/* ========== 桌面端响应式 ========== */
@media (min-width: 768px) {
  .home-review-section {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
  }
  .on-this-day-card { flex: 0 0 220px; }
  .review-full-list { max-width: 700px; margin-left: auto; margin-right: auto; }
}

/* ========== v7.0.0 用户认证 UI ========== */
.auth-header { padding: 24px 20px 16px; position: relative; }
.auth-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 24px; cursor: pointer; color: #999; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.auth-close:hover { background: #f0f0f0; }
.auth-tabs { display: flex; border-bottom: 1px solid #eee; }
.auth-tab { flex: 1; padding: 12px; background: none; border: none; font-size: 15px; cursor: pointer; color: #999; border-bottom: 2px solid transparent; transition: all 0.2s; }
.auth-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.auth-body { padding: 20px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 500; }
.auth-field input { width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.2s; box-sizing: border-box; }
.auth-field input:focus { border-color: #2563eb; }
.auth-submit-btn:hover { background: #1d4ed8; }
.auth-status { margin-top: 12px; text-align: center; font-size: 13px; min-height: 20px; color: #666; }

/* 心情追踪 UI */
.mood-picker { display: flex; justify-content: center; gap: 12px; padding: 8px 0; }
.mood-option { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; background: #f8f8f8; }
.mood-option:hover { transform: scale(1.1); }
.mood-option.selected { border-color: #2563eb; background: #e8f0fe; transform: scale(1.15); }
.mood-selector { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.mood-label { font-size: 13px; color: #999; }
.mood-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.mood-badge.great { background: #dcfce7; color: #16a34a; }
.mood-badge.good { background: #d1fae5; color: #059669; }
.mood-badge.neutral { background: #fef3c7; color: #d97706; }
.mood-badge.bad { background: #fee2e2; color: #dc2626; }
.mood-badge.awful { background: #ede9fe; color: #7c3aed; }

/* 快速输入框 UI */
.quick-input-bar { display: flex; gap: 8px; padding: 12px 16px; background: #fff; border-top: 1px solid #f0f0f0; position: sticky; bottom: 0; align-items: center; }
.quick-input-field { flex: 1; padding: 10px 14px; border: 1px solid #e0e0e0; border-radius: 20px; font-size: 14px; outline: none; background: #f8f8f8; transition: all 0.2s; }
.quick-input-field:focus { border-color: #2563eb; background: #fff; }
.quick-send-btn { width: 36px; height: 36px; border-radius: 50%; background: #2563eb; color: white; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.quick-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.quick-send-btn:not(:disabled):hover { background: #1d4ed8; transform: scale(1.05); }

/* 连续打卡 UI */
.streak-badge { display: flex; align-items: center; gap: 4px; padding: 4px 10px; background: linear-gradient(135deg, #ff6b35, #ff4444); color: white; border-radius: 16px; font-size: 12px; font-weight: 600; }
.streak-flame { animation: streak-flicker 1.5s ease-in-out infinite alternate; }
@keyframes streak-flicker { 0% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.15) rotate(3deg); } 100% { transform: scale(1) rotate(-1deg); } }

/* Toast 提示 */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px); padding: 10px 20px; background: rgba(0,0,0,0.75); color: white; border-radius: 20px; font-size: 14px; z-index: 9999; opacity: 0; pointer-events: none; transition: all 0.3s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: none; }

/* ========== v7.0.0 页面过渡动画 ========== */
.page {
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.page.active {
  opacity: 1;
  transform: translateX(0);
}

/* View Transitions API 动画 */
::view-transition-old(root) {
  animation: fadeOut 0.25s ease forwards;
}
::view-transition-new(root) {
  animation: fadeIn 0.25s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-20px); }
}

/* 心跳动画 (连续打卡) */
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 心情选择弹跳 */
.mood-option {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, border-color 0.2s;
}
