/* ============ 移动端优先设计系统 ============ */
:root {
  /* 色彩系统 - 清新护眼 */
  --primary: #5b8cff;      /* 主蓝色 - 视觉友好 */
  --primary-light: #edf2ff;
  --primary-dark: #4a7cff;
  --primary-rgb: 91, 140, 255;
  
  --secondary: #8a9bb2;    /* 中性灰蓝 */
  --success: #4cde8d;      /* 清新绿色 */
  --warning: #ffb74d;      /* 温暖橙色 */
  --danger: #ff6b6b;       /* 柔和红色 */
  
  /* 背景色系 - 轻盈透气 */
  --bg-body: #f9fafc;      /* 页面背景 */
  --bg-card: #ffffff;      /* 卡片背景 */
  --bg-input: #ffffff;     /* 输入框背景 */
  --bg-hover: #f8fafd;     /* 悬停背景 */
  
  /* 文字颜色 - 舒适对比 */
  --text-primary: #2d3748;  /* 主文字 - 深灰蓝 */
  --text-secondary: #64748b;/* 次要文字 */
  --text-muted: #94a3b8;   /* 辅助文字 */
  --text-light: #cbd5e1;   /* 弱化文字 */
  
  /* 边框系统 */
  --border-light: #e2e8f0;  /* 浅边框 */
  --border: #cbd5e0;       /* 常规边框 */
  --border-dark: #94a3b8;  /* 深边框 */
  
  /* 阴影系统 - 轻量化 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.15);
  
  /* 移动端间距系统 */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  
  /* 圆角系统 */
  --radius-sm: 0.375rem;  /* 6px */
  --radius: 0.5rem;       /* 8px */
  --radius-md: 0.75rem;   /* 12px */
  --radius-lg: 1rem;      /* 16px */
  --radius-xl: 1.25rem;   /* 20px */
  --radius-full: 9999px;
  
  /* 字体系统 */
  --font-sans: -apple-system, BlinkMacSystemFont, 
               "PingFang SC", "Hiragino Sans GB", 
               "Microsoft YaHei", "WenQuanYi Micro Hei", 
               sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  /* 安全区域支持 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  
  /* 动画速度 */
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
}

/* ============ 基础重置（移动端优化） ============ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 0;
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* 确保安全区域 */
body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ============ 布局容器 ============ */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* 平板 */
@media (min-width: 768px) {
  .container {
    max-width: 750px;
    padding: 0 var(--space-6);
  }
}

/* 桌面 */
@media (min-width: 1024px) {
  .container {
    max-width: 900px;
  }
}

/* ============ 移动端头部 ============ */
.mobile-header {
  background: var(--bg-card);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-3) 0;
  height: 60px;
  display: flex;
  align-items: center;
}

.mobile-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* 标题区域 */
.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.125rem;
}

.header-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
  background: var(--bg-hover);
  border-color: var(--border);
}

.mobile-menu-btn i {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

/* ============ 拇指友好的按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-5);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--duration-fast);
  gap: var(--space-2);
  min-height: 44px; /* 移动端最小触摸目标 */
  min-width: 44px;
  touch-action: manipulation;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* 触摸反馈 */
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(var(--primary-rgb), 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--duration-fast);
}

.btn:active::after {
  transform: translate(-50%, -50%) scale(20);
}

/* 按钮变体 */
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  min-height: 36px;
  min-width: 36px;
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: 1rem;
  min-height: 52px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* 浮动操作按钮（移动端重要操作） */
.fab {
  position: fixed;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  right: var(--space-6);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-normal);
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.fab:active {
  transform: translateY(0);
}

/* ============ 回到顶部按钮 ============ */
.back-to-top {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: var(--space-4);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 1001;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-normal);
}

.back-to-top.show {
  display: flex;
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

@media (min-width: 768px) {
  .fab {
    bottom: var(--space-6);
  }
  
  .back-to-top {
    bottom: var(--space-6);
    right: var(--space-6);
  }
}

/* ============ 卡片设计 ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
  transition: all var(--duration-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============ 表单元素（移动端优化） ============ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--duration-fast);
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* 移动端输入优化 */
@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px !important; /* 防止iOS缩放 */
  }
}

/* 密码显示切换 */
.password-toggle {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-2);
}

/* ============ 月记卡片（移动端优化） ============ */
.entry-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  border-left: 4px solid var(--primary);
  transition: all var(--duration-normal);
  position: relative;
  overflow: hidden;
}

.entry-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--primary-light) 50%, 
    transparent 100%);
}

.entry-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.entry-header {
  margin-bottom: var(--space-3);
}

.entry-date-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.entry-date {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.entry-date i {
  color: var(--primary);
  font-size: 0.875rem;
}

.entry-meta {
  display: flex;
  gap: var(--space-1);
}

.entry-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.entry-time i {
  font-size: 0.6875rem;
}

/* ============ 关键修复：内容区域空白问题 ============ */
.entry-content {
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: justify;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-light);
  
  /* 重置所有内部元素的边距 */
  > * {
    margin-top: 0;
    margin-bottom: 0;
  }
}

/* 控制换行间距（关键修复） */
.entry-content br {
  display: block;
  content: "";
  margin-bottom: 0.5em;
  height: 0;
  line-height: 0;
}

/* 如果有段落标签，控制其间距 */
.entry-content p {
  margin: 0 0 0.75em 0;
  line-height: 1.6;
}

.entry-content p:last-child {
  margin-bottom: 0;
}

/* 移除旧版的空行样式（如果存在） */
.entry-content .empty-line,
.entry-content .content-line {
  display: none;
}

/* 修复首行缩进问题 */
.entry-content br + br {
  margin-bottom: 0.75em;
}

/* ============ 年份导航（移动端滑动） ============ */
.year-nav-container {
  position: sticky;
  top: 60px; /* 在头部下方 */
  z-index: 900;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-3) 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.year-scroll-wrapper {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  padding-bottom: 4px;
}

.year-scroll-wrapper::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.year-links {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  min-width: min-content;
}

.year-link {
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-body);
  border-radius: var(--radius-full);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border-light);
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.year-link:hover,
.year-link.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 滑动提示 */
.scroll-hint {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, var(--bg-card));
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* ============ 年份分组 ============ */
.year-section {
  margin-bottom: var(--space-6);
}

.year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding: var(--space-3) var(--space-4) 0;
  position: sticky;
  top: 110px; /* 在头部和导航下方 */
  z-index: 800;
  background: var(--bg-body);
  gap: var(--space-2);
}

.year-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.year-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

/* ============ 移动端底部导航 ============ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: var(--space-2) var(--space-4) calc(var(--space-2) + var(--safe-bottom));
  z-index: 1000;
  display: flex;
  justify-content: space-around;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2);
  color: var(--text-muted);
  text-decoration: none;
  flex: 1;
  max-width: 100px;
  transition: color var(--duration-fast);
}

.nav-item i {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.nav-item span {
  font-size: 0.75rem;
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
}

/* ============ 空状态设计 ============ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--text-secondary);
}

.empty-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-6);
  color: var(--text-light);
  font-size: 2rem;
  border: 1px solid var(--border-light);
}

.empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-description {
  max-width: 300px;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ============ 模态框（移动端优化） ============ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp var(--duration-normal);
  box-shadow: var(--shadow-xl);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: none;
  background: var(--bg-body);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
}

/* ============ 加载状态 ============ */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinner 1s linear infinite;
  margin: var(--space-8) auto;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* 骨架屏加载 */
.skeleton {
  background: linear-gradient(90deg, 
    var(--bg-card) 25%, 
    var(--bg-hover) 50%, 
    var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ 工具类 ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.hidden { display: none !important; }
.block { display: block !important; }

/* ============ 响应式调整 ============ */
@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
  
  .mobile-menu-btn {
    display: none;
  }
}

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }
  
  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }
  
  .entry-card {
    padding: var(--space-3);
  }
  
  .year-header {
    top: 100px;
    margin-bottom: var(--space-3);
  }
  
  .entry-date-container {
    gap: 4px;
  }
  
  .entry-date {
    font-size: 0.875rem;
  }
  
  .entry-time {
    font-size: 0.6875rem;
  }
  
  /* 移动端内容更紧凑 */
  .entry-content {
    font-size: 0.875rem;
    line-height: 1.5;
  }
  
  .entry-content br {
    margin-bottom: 0.4em;
  }
  
  .entry-content p {
    margin-bottom: 0.6em;
  }
}

/* ============ 打印样式 ============ */
@media print {
  .mobile-header,
  .year-nav-container,
  .mobile-bottom-nav,
  .fab,
  .btn,
  .back-to-top {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
    padding: 0 !important;
  }
  
  .entry-card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  .entry-content {
    border-top: none !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
}
/* 添加到style.css的最末尾 */
.entry-content * {
    all: unset !important;
    display: inline !important;
}

.entry-content {
    all: unset !important;
    display: block !important;
    color: var(--text-primary) !important;
    line-height: 1.6 !important;
    font-size: 0.9375rem !important;
    text-indent: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}