/* ============================================================
   每日复盘 · Notion 风格深色主题
   背景 #121212 / 卡片 #1F1F1F / 边框 #2C2C2C
   ============================================================ */
:root {
  --bg: #121212;
  --bg-elev: #1a1a1a;
  --card: #1f1f1f;
  --card-hover: #252525;
  --border: #2c2c2c;
  --text: #e8e8e6;
  --text-2: #9b9b98;
  --text-3: #6a6a67;
  --accent: #5b8def;
  --danger: #e05d5d;
  --radius: 14px;
  --topbar-h: 56px;
  --bottombar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; color: var(--text); }
.hidden { display: none !important; }

/* ---------- 应用骨架 ---------- */
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }

/* ---------- 顶部导航 ---------- */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--card-hover); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--text); flex-shrink: 0;
}
.seg {
  display: flex; gap: 2px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px;
}
.seg-btn {
  min-width: 44px; height: 32px; border-radius: 999px;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all .15s ease;
}
.seg-btn.active { background: var(--card-hover); color: var(--text); }
.topbar-right { font-size: 19px; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }

/* ---------- 视图容器 ---------- */
.view-container { flex: 1; overflow-y: auto; padding-bottom: calc(var(--bottombar-h) + var(--safe-bottom) + 16px); }
.view { padding: 16px 16px 8px; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 区块标题（Notion 风） ---------- */
.section { margin-top: 18px; }
.section-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  padding: 0 2px 10px; user-select: none;
}
.section-head .chev { transition: transform .15s ease; font-size: 10px; }
.section-head.collapsed .chev { transform: rotate(-90deg); }

/* ---------- 最近卡片（横滑） ---------- */
.recent-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.recent-scroll::-webkit-scrollbar { display: none; }
.recent-card {
  flex: 0 0 150px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 12px 12px; text-align: left;
  display: flex; flex-direction: column; gap: 26px; transition: background .15s ease;
}
.recent-card:active { background: var(--card-hover); }
.recent-card .rc-icon { font-size: 26px; }
.recent-card .rc-title {
  font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-card .rc-date { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---------- 列表（月分组） ---------- */
.month-group { margin-bottom: 6px; }
.month-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 8px; border-radius: 10px; text-align: left;
  transition: background .12s ease;
}
.month-item:active { background: var(--card-hover); }
.li-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-mood { font-size: 18px; flex-shrink: 0; }

/* ---------- 编辑页 ---------- */
.edit-head { padding-top: 6px; }
.edit-back { font-size: 14px; color: var(--text-2); padding: 6px 2px; display: inline-flex; align-items: center; gap: 4px; }
.edit-title { font-size: 26px; font-weight: 700; margin: 10px 0 4px; letter-spacing: .3px; }
.edit-meta { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }

/* 心情选择 */
.mood-row { display: flex; gap: 8px; margin-bottom: 16px; }
.mood-btn {
  flex: 1; height: 52px; font-size: 24px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  filter: grayscale(.65); opacity: .55; transition: all .15s ease;
}
.mood-btn.selected { filter: none; opacity: 1; border-color: var(--accent); background: var(--card-hover); }

/* 模板块 */
.block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.block-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; font-size: 14px; font-weight: 600; }
.block-head .bh-icon { font-size: 16px; }
.block textarea {
  width: 100%; min-height: 96px; background: transparent; border: none; outline: none;
  resize: none; padding: 4px 14px 14px; font-size: 15px; line-height: 1.65;
}
.block textarea::placeholder { color: var(--text-3); }

/* 保存状态 */
.save-state { text-align: right; font-size: 11px; color: var(--text-3); height: 16px; margin-top: 2px; }

/* 删除按钮 */
.danger-zone { margin-top: 20px; }
.btn-danger {
  width: 100%; padding: 12px; border-radius: 12px; font-size: 14px;
  background: transparent; border: 1px solid var(--border); color: var(--danger);
}
.btn-danger:active { background: rgba(224, 93, 93, .08); }

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-size: 18px; font-weight: 700; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 34px; height: 34px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--text-3); padding: 6px 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 14px;
  color: var(--text); position: relative;
}
.cal-cell.dim { color: var(--text-3); opacity: .45; }
.cal-cell.today { border: 1px solid var(--accent); }
.cal-cell.has-entry { background: var(--card); border: 1px solid var(--border); }
.cal-cell.has-entry:active { background: var(--card-hover); }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

/* ---------- 统计 ---------- */
.stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 8px; text-align: center; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 110px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 22px; border-radius: 4px 4px 2px 2px; background: var(--accent); opacity: .85; min-height: 3px; }
.bar.empty { background: var(--border); }
.bar-x { font-size: 9px; color: var(--text-3); }

/* ---------- 设置 ---------- */
.set-group { margin-bottom: 20px; }
.set-label { font-size: 12px; color: var(--text-3); padding: 0 2px 8px; }
.set-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.set-row:last-child { border-bottom: none; }
.set-row:active { background: var(--card-hover); }
.set-row .sr-icon { font-size: 17px; }
.set-row .sr-main { flex: 1; }
.set-row .sr-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.set-row .sr-arrow { color: var(--text-3); font-size: 13px; }

/* 模板编辑 */
.tpl-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tpl-icon-input { width: 44px; text-align: center; font-size: 17px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; }
.tpl-label-input { flex: 1; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; outline: none; }
.tpl-del { color: var(--danger); font-size: 15px; padding: 6px; }
.tpl-add { width: 100%; padding: 11px; color: var(--accent); font-size: 14px; }

/* ---------- 底部操作栏 ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  height: calc(var(--bottombar-h) + var(--safe-bottom));
  padding: 0 18px var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to top, rgba(18,18,18,.97) 65%, rgba(18,18,18,0));
}
.bb-icon {
  width: 44px; height: 44px; border-radius: 50%; font-size: 19px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.bb-icon:active { background: var(--card-hover); }
.bb-ai {
  flex: 1; margin: 0 12px; height: 44px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 14px; color: var(--text); letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.bb-ai:active { background: var(--card-hover); }
.bb-ai.disabled { color: var(--text-3); }

/* ---------- 搜索弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 0;
  backdrop-filter: blur(2px);
}
.search-panel { width: 100%; max-width: 480px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; animation: fadeIn .15s ease; }
.search-panel input {
  width: 100%; background: transparent; border: none; outline: none;
  padding: 16px; font-size: 16px; border-bottom: 1px solid var(--border);
}
.search-results { max-height: 46vh; overflow-y: auto; }
.sr-item { display: flex; gap: 10px; padding: 12px 16px; width: 100%; text-align: left; border-bottom: 1px solid var(--border); align-items: center; }
.sr-item:active { background: var(--card-hover); }
.sr-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottombar-h) + var(--safe-bottom) + 20px);
  transform: translateX(-50%); z-index: 60;
  background: var(--card-hover); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; padding: 10px 18px; border-radius: 999px;
  animation: fadeIn .15s ease; max-width: 80vw; text-align: center;
}

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .e-icon { font-size: 38px; margin-bottom: 12px; }
.empty .e-text { font-size: 14px; line-height: 1.8; }

/* 桌面端微调 */
@media (min-width: 641px) { body { background: #0d0d0d; } }
