/* ============================================================
 *  我的工作台（联网版）— 样式表
 *  设计原则：阅读障碍友好 · 极简 · 护眼
 *  首个模块：读书笔记
 * ============================================================ */

/* ========== 全局重置 ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ============================================================
 *  ★ 配色变量区
 * ============================================================ */
:root {
  --bg-page:       #F5E6C8;
  --bg-card:       #FFF8EE;
  --bg-card-hover: #FFFBF5;
  --text-primary:  #3E2723;
  --text-secondary:#7D6E63;
  --text-hint:     #A1887F;
  --border:        #E0D5C1;
  --shadow:        0 1px 4px rgba(62, 39, 35, 0.06);
  --accent:        #6D8C6A;
  --accent-hover:  #5A7A57;
  --accent-flash:  #81C784;
  --danger:        #C28080;
  --danger-hover:  #A86565;
  --sidebar-bg:    #F0DFBE;
}

/* ============================================================
 *  ★ 字号变量区
 * ============================================================ */
:root {
  --fs-base:   18px;
  --fs-sm:     14px;
  --fs-xs:     12px;
  --fs-lg:     22px;
  --fs-xl:     28px;
  --lh-base:   2.0;
  --lh-tight:  1.6;
}

/* ========== 页面基础 ========== */
body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
 *  工作台布局：左侧目录 + 右侧内容
 * ============================================================ */
.workspace-layout {
  display: flex;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---- 左侧目录 ---- */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 16px 12px;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sidebar-count {
  font-size: var(--fs-xs);
  color: var(--text-hint);
  font-weight: 400;
}
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.sidebar-list::-webkit-scrollbar {
  width: 4px;
}
.sidebar-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 目录中的每条笔记 */
.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  position: relative;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: var(--lh-tight);
}
.sidebar-item:hover {
  background: rgba(109, 140, 106, 0.12);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: rgba(109, 140, 106, 0.20);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-item .si-date {
  font-size: var(--fs-xs);
  color: var(--text-hint);
  display: block;
}
.sidebar-item .si-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 20px; /* 给删除按钮留空间 */
}
/* 目录项删除按钮：桌面端悬停才显示 */
.sidebar-item-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.sidebar-item:hover .sidebar-item-del {
  opacity: 1;
}
.sidebar-item-del:hover {
  color: var(--danger);
  background: rgba(194, 128, 128, 0.12);
}

/* 目录空状态 */
.sidebar-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-hint);
  font-size: var(--fs-sm);
  line-height: var(--lh-tight);
}

/* ---- 右侧主内容 ---- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 40px;
  max-width: 680px;
}

/* 移动端目录切换按钮 */
.sidebar-toggle {
  display: none;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.15s;
}
.sidebar-toggle:hover {
  background: var(--bg-page);
}

/* ========== 顶部标题栏 ========== */
.app-header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.app-header h1 {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 2px;
  margin-bottom: 4px;
}
.app-header .today-date {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ========== 用户信息栏 ========== */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.user-bar .user-email {
  color: var(--text-hint);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-hint);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ========== 卡片通用 ========== */
.card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.card:hover {
  box-shadow: 0 2px 8px rgba(62, 39, 35, 0.10);
}

/* ========== 输入区 ========== */
.input-card .card-title {
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.input-group {
  margin-bottom: 14px;
}
.input-group label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.input-group textarea,
.input-group input {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-base);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input-group textarea { resize: vertical; }
.input-group input { resize: none; }
.input-group textarea:focus,
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 140, 106, 0.15);
}
.input-group textarea::placeholder,
.input-group input::placeholder {
  color: var(--text-hint);
}

#excerptInput    { min-height: 72px; }
#reflectionInput { min-height: 48px; }

/* 编辑模式：输入卡片高亮 */
.input-card.editing {
  border: 2px solid var(--accent);
}

/* ========== 按钮 ========== */
.btn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.btn-save {
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  color: #FFF;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 10px 28px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.15s, transform 0.1s;
}
.btn-save:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.btn-save:active { transform: scale(0.97); }
.btn-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 取消编辑按钮 */
.btn-cancel {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
}
.btn-cancel:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* 编辑模式下的删除按钮 */
.btn-delete-edit {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--danger);
  background: none;
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s;
}
.btn-delete-edit:hover {
  background: var(--danger);
  color: #FFF;
}

/* 闪绿动画 */
.btn-save.flash-green {
  background: var(--accent-flash) !important;
  transition: background 0s;
}
.btn-save.flash-green.fading {
  background: var(--accent) !important;
  transition: background 0.6s ease-out;
}

.hint-text {
  font-size: var(--fs-sm);
  color: var(--text-hint);
}

/* ========== 记录列表 ========== */
.records-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.records-header .section-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
}
.records-header .record-count {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-hint);
  font-size: var(--fs-base);
  line-height: var(--lh-tight);
}
.empty-state .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.6;
}

/* ========== 单条记录卡片 ========== */
.note-card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 12px;
  position: relative;
  transition: box-shadow 0.2s, opacity 0.3s, transform 0.3s, border-color 0.2s;
  border: 2px solid transparent;
}
.note-card:hover {
  box-shadow: 0 2px 8px rgba(62, 39, 35, 0.10);
}
.note-card.removing {
  opacity: 0;
  transform: translateX(40px);
  pointer-events: none;
}
/* 高亮当前编辑的卡片 */
.note-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(109, 140, 106, 0.12);
}

.note-card .note-date {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}
.note-card .note-section {
  margin-bottom: 10px;
}
.note-card .note-label {
  font-size: var(--fs-sm);
  color: var(--text-hint);
  margin-bottom: 2px;
  letter-spacing: 1px;
}
.note-card .note-content {
  font-size: var(--fs-base);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.note-card .note-reflection {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  font-style: italic;
  color: #4E342E;
}

/* 卡片右上角按钮组 */
.note-card .card-actions {
  position: absolute;
  top: 14px;
  right: 12px;
  display: flex;
  gap: 2px;
}
.btn-edit,
.btn-delete {
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-edit:hover {
  color: var(--accent);
  background: rgba(109, 140, 106, 0.10);
}
.btn-delete:hover {
  color: var(--danger-hover);
  background: rgba(194, 128, 128, 0.10);
}

/* ========== 底部工具栏 ========== */
.footer-tools {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.btn-export {
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s;
}
.btn-export:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}
.btn-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.footer-note {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-hint);
}

/* ========== 加载 / Toast ========== */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  text-align: center;
  padding: 30px;
  color: var(--text-hint);
  font-size: var(--fs-base);
}

.toast {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: #FFF;
  max-width: 90vw;
  text-align: center;
  animation: toastIn 0.3s ease-out;
  pointer-events: none;
}
.toast.success { background: var(--accent); }
.toast.error   { background: var(--danger); }
.toast.info    { background: #7D8C6E; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
 *  认证界面
 * ============================================================ */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card .auth-title {
  text-align: center;
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text-hint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.auth-tab:hover { color: var(--text-primary); }

.auth-error {
  background: rgba(194, 128, 128, 0.12);
  color: var(--danger);
  font-size: var(--fs-sm);
  padding: 8px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  display: none;
  line-height: var(--lh-tight);
}
.auth-error.visible { display: block; }

.auth-success {
  background: rgba(109, 140, 106, 0.12);
  color: var(--accent);
  font-size: var(--fs-sm);
  padding: 8px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  display: none;
  line-height: var(--lh-tight);
}
.auth-success.visible { display: block; }

.auth-form .input-group { margin-bottom: 16px; }
.auth-form .btn-save { width: 100%; margin-top: 4px; }

/* ============================================================
 *  返回按钮
 * ============================================================ */
.btn-back {
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--accent); }

/* ============================================================
 *  首页（Home）样式
 * ============================================================ */

/* 顶栏 */
.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #FFF;
  border-bottom: 1px solid #E8E3D8;
  position: sticky;
  top: 0;
  z-index: 50;
}
.home-topbar-left { display: flex; align-items: center; }
.home-logo {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}
.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home-user {
  font-size: var(--fs-sm);
  color: var(--text-hint);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 主体 */
.home-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
}
.home-welcome {
  text-align: center;
  margin-bottom: 48px;
}
.home-welcome h2 {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.home-welcome p {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* 模块卡片网格 */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.module-card {
  position: relative;
  background: #FFF;
  border-radius: 12px;
  padding: 28px 24px 24px;
  text-align: center;
  cursor: default;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #EAE5D9;
}
.module-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

/* 已启用模块 */
.module-active {
  cursor: pointer;
  border-color: var(--accent);
}
.module-active:hover {
  box-shadow: 0 4px 20px rgba(109, 140, 106, 0.18);
  border-color: var(--accent-hover);
}

/* 即将推出模块 */
.module-coming {
  opacity: 0.65;
}
.module-coming:hover {
  transform: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.module-icon {
  font-size: 48px;
  margin-bottom: 16px;
  line-height: 1;
}
.module-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.module-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-tight);
}
.module-badge {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-hint);
  background: #F0EDE5;
  border-radius: 20px;
  padding: 3px 14px;
  letter-spacing: 1px;
}

/* 页脚 */
.home-footer {
  text-align: center;
  padding: 32px 16px;
  font-size: 12px;
  color: var(--text-hint);
}

/* ============================================================
 *  健康管理页面样式
 * ============================================================ */
.health-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.health-header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.health-header h1 {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 2px;
  margin-bottom: 4px;
}
.health-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.health-card {
  margin-bottom: 16px;
}
.health-form {
  margin-top: 12px;
}
.health-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.health-form-row .input-group {
  margin-bottom: 0;
  min-width: 120px;
}
.health-form-row .btn-save {
  height: 44px;
}

/* BMI 卡片 */
.health-bmi-card {
  text-align: center;
  padding: 28px 24px;
  border-left: 4px solid var(--accent);
  transition: border-color 0.3s;
}
.bmi-value {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.bmi-label {
  font-size: var(--fs-sm);
  color: var(--text-hint);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.bmi-category {
  display: inline-block;
  font-size: var(--fs-lg);
  font-weight: 700;
  padding: 4px 20px;
  border-radius: 20px;
  margin-top: 4px;
}
.bmi-detail {
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* 体重记录列表 */
.health-record-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
}
.health-record-item:last-child {
  border-bottom: none;
}
.hr-date {
  width: 70px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.hr-weight {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 12px;
  flex-shrink: 0;
}
.hr-change {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-left: auto;
}
.hr-change.weight-up   { color: #C28080; }
.hr-change.weight-down { color: #6D8C6A; }
.hr-change.weight-same { color: var(--text-hint); }
.hr-change.weight-first{ color: var(--text-hint); font-weight: 400; }

.health-empty {
  text-align: center;
  padding: 30px 0;
  color: var(--text-hint);
  font-size: var(--fs-sm);
}

/* 体重记录删除按钮 */
.hr-del {
  font-family: inherit;
  font-size: 16px;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.health-record-item:hover .hr-del {
  opacity: 1;
}
.hr-del:hover {
  color: var(--danger);
  background: rgba(194, 128, 128, 0.10);
}

/* AI 顾问 */
.ai-hint {
  font-size: var(--fs-sm);
  color: var(--text-hint);
  margin-bottom: 12px;
  line-height: var(--lh-tight);
}
.ai-response {
  margin-top: 16px;
  padding: 16px 20px;
  background: #F8F6F0;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: var(--fs-base);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  white-space: pre-wrap;
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-response .ai-loading {
  color: var(--text-hint);
  font-style: italic;
}

/* ============================================================
 *  响应式：窄屏适配
 * ============================================================ */
@media (max-width: 768px) {
  .workspace-layout {
    flex-direction: column;
  }

  /* 侧边栏在移动端默认隐藏，点击按钮展开 */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 260px;
    min-width: 260px;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    left: 0;
  }

  /* 遮罩层 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
  }
  .sidebar-overlay.show {
    display: block;
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .main-content {
    padding: 12px 10px 32px;
    max-width: 100%;
  }
}

@media (max-width: 520px) {
  .card, .note-card { padding: 14px 16px; }
  .app-header h1 { font-size: var(--fs-lg); }
  :root { --fs-base: 16px; }
  .user-bar { flex-direction: column; gap: 6px; }

  /* 首页移动端适配 */
  .home-topbar { padding: 10px 16px; }
  .home-logo { font-size: var(--fs-base); }
  .home-main { padding: 24px 12px; }
  .home-welcome h2 { font-size: 24px; }
  .module-grid { grid-template-columns: 1fr; gap: 14px; }
  .module-card { padding: 20px 18px; }
  .module-icon { font-size: 36px; }

  /* 健康管理移动端适配 */
  .health-page { padding: 12px 10px 32px; }
  .bmi-value { font-size: 36px; }
  .health-form-row { flex-direction: column; }
  .health-form-row .btn-save { width: 100%; }
  .health-record-item { flex-wrap: wrap; }
  .hr-date { width: 60px; font-size: var(--fs-xs); }
}
