/* ── 回顾布局 ─────────────────────────────────────────────────── */
#tab-history {
  max-width: 1040px;
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

#history-left-col {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#history-calendar-sidebar {
  background: #fffdf9;
  border: 1px solid #ddd3c8;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 14px rgba(90,52,18,0.07), 0 1px 3px rgba(90,52,18,0.04);
}

/* ── 日历 ─────────────────────────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
  line-height: 1;
}
.cal-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

#cal-month-label { font-size: 13px; color: var(--text); letter-spacing: .5px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }

.cal-weekday { font-size: 11px; color: var(--muted); text-align: center; padding: 5px 0 8px; }

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 52px;
  font-size: 13px;
  color: var(--muted);
  position: relative;
  user-select: none;
}

.cal-day-num {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  line-height: 1;
}

.cal-lunar {
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  opacity: 0.75;
}

/* 分数颜色变量 */
:root {
  --score-1: #d95858;
  --score-2: #e0844a;
  --score-3: #c9a020;
  --score-4: #4ea84e;
  --score-5: #3a9db5;
}

/* 可补写的空白日期 */
.cal-cell.cal-can-fill { cursor: pointer; }
.cal-cell.cal-can-fill .cal-day-num::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.2);
  transition: opacity .2s ease, transform .2s ease;
  z-index: -1;
}
.cal-cell.cal-can-fill:hover .cal-day-num::before {
  opacity: 0.13;
  transform: scale(1);
}
.cal-cell.cal-can-fill:hover { color: var(--accent); }

/* 补写弹窗 */
.cal-fill-popover {
  position: fixed;
  z-index: 3000;
  background: var(--bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15), 0 2px 6px rgba(0,0,0,.08);
  padding: 14px 16px;
  width: 156px;
  animation: cfp-in .15s ease;
}
@keyframes cfp-in {
  from { opacity: 0; transform: scale(.92) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.cfp-date {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 10px;
  line-height: 1.4;
}
.cfp-fill-btn {
  display: block;
  width: 100%;
  padding: 8px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  margin-bottom: 6px;
  transition: opacity .15s;
}
.cfp-fill-btn:hover { opacity: .85; }
.cfp-cancel-btn {
  display: block;
  width: 100%;
  padding: 7px 0;
  background: none;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.cfp-cancel-btn:hover { border-color: var(--muted); color: var(--text); }

.cal-cell.cal-has-entry { cursor: pointer; font-weight: 500; }
.cal-cell.cal-has-entry .cal-day-num::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transition: background .15s;
  z-index: -1;
}
.cal-cell.cal-has-entry:hover .cal-day-num::after { background: rgba(0,0,0,.06); }

.cal-score-1 { color: var(--score-1); }
.cal-score-2 { color: var(--score-2); }
.cal-score-3 { color: var(--score-3); }
.cal-score-4 { color: var(--score-4); }
.cal-score-5 { color: var(--score-5); }

/* 日历格子填色背景 */
.cal-cell.cal-has-entry.cal-score-1 .cal-day-num::after { background: #fdf2f2; }
.cal-cell.cal-has-entry.cal-score-2 .cal-day-num::after { background: #fdf6f0; }
.cal-cell.cal-has-entry.cal-score-3 .cal-day-num::after { background: #fdfbf0; }
.cal-cell.cal-has-entry.cal-score-4 .cal-day-num::after { background: #f2faf2; }
.cal-cell.cal-has-entry.cal-score-5 .cal-day-num::after { background: #f0f8fb; }

.cal-cell.cal-today .cal-day-num { color: var(--accent); font-weight: 700; }
.cal-cell.cal-today.cal-has-entry .cal-day-num { color: #fff !important; }
.cal-cell.cal-today.cal-score-1 .cal-day-num::after { background: var(--score-1) !important; border-color: var(--score-1) !important; }
.cal-cell.cal-today.cal-score-2 .cal-day-num::after { background: var(--score-2) !important; border-color: var(--score-2) !important; }
.cal-cell.cal-today.cal-score-3 .cal-day-num::after { background: var(--score-3) !important; border-color: var(--score-3) !important; }
.cal-cell.cal-today.cal-score-4 .cal-day-num::after { background: var(--score-4) !important; border-color: var(--score-4) !important; }
.cal-cell.cal-today.cal-score-5 .cal-day-num::after { background: var(--score-5) !important; border-color: var(--score-5) !important; }

/* 节假日 */
.cal-cell.cal-holiday .cal-day-num { color: #d94040; }
.cal-cell.cal-holiday .cal-lunar   { color: #d94040; opacity: 0.9; }

/* 生日 */
.cal-cell.cal-birthday .cal-day-num { color: #c0609a; font-weight: 700; }
.cal-cell.cal-birthday .cal-lunar   { font-size: 14px; opacity: 1; }

/* 补班工作日 */
.cal-cell.cal-workday .cal-lunar { color: var(--accent); opacity: 0.9; }
.cal-cell.cal-workday .cal-lunar::after { content: '班'; }

/* 日历图例 */
.cal-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cal-legend-item {
  font-size: 10px;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 3px;
}
.cal-legend-item::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  #tab-history { flex-direction: column; }
  #history-left-col { width: 100%; position: static; }
}

/* ── 历史记录瀑布流 ───────────────────────────────────────────── */
#history-main {
  flex: 1;
  min-width: 0;
}

#history-list {
  column-count: 3;
  column-gap: 12px;
}

.history-item {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 12px;
  will-change: transform;
}

/* 顶部彩色封面区 */
.hi-cover {
  position: relative;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 80px;
}
.hi-cover-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hi-cover-emoji { font-size: 28px; line-height: 1; }
.hi-cover-score {
  font-size: 22px;
  font-weight: 600;
  opacity: .75;
}

/* 高分卡片（9-10分）：字号更大，亮点展示更多行 */
.hi-mood-hi .hi-cover-emoji { font-size: 36px; }
.hi-mood-hi .hi-cover-score { font-size: 28px; }
.hi-mood-hi .hi-cover       { padding: 22px 17px 18px; }
.hi-mood-hi .hi-highlight   { -webkit-line-clamp: 5; font-size: 13px; }

/* 低分卡片（≤4分）：字号略小，亮点截短 */
.hi-mood-lo .hi-cover-emoji { font-size: 22px; }
.hi-mood-lo .hi-cover-score { font-size: 16px; }
.hi-mood-lo .hi-cover       { padding: 14px 14px 12px; }
.hi-mood-lo .hi-highlight   { -webkit-line-clamp: 2; }
.hi-cover-date {
  font-size: 11px;
  opacity: .65;
  margin-top: 2px;
}
.hi-cover-feeling {
  font-size: 11px;
  opacity: .65;
}
.hi-birthday-badge {
  display: inline-block;
  font-size: 10px;
  background: rgba(192, 96, 154, 0.15);
  color: #c0609a;
  border-radius: 8px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

/* 卡片内容区 */
.hi-body { padding: 12px 14px 14px; }

.hi-activities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.hi-act {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 20px;
}
.hi-highlight {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hi-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hi-enc, .hi-social-enc {
  font-size: 11px;
  color: var(--muted);
}
.hi-enc-story {
  color: var(--accent);
}
.hi-social-enc::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  margin-right: 4px;
  vertical-align: middle;
}

@media (max-width: 900px) { #history-list { column-count: 2; } }
@media (max-width: 600px) { #history-list { column-count: 1; } }

/* ── 统计面板 ─────────────────────────────────────────────────── */
#stats-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stats-grid {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.stats-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0;
  border-right: 1px solid var(--border);
}
.stats-item:last-child { border-right: none; }

.stats-num {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.stats-label {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.stats-dates {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

/* 封面区分数背景 */
.score-card-1 .hi-cover { background: #fae8e8; }
.score-card-2 .hi-cover { background: #faeee4; }
.score-card-3 .hi-cover { background: #faf6e4; }
.score-card-4 .hi-cover { background: #e8f6e8; }
.score-card-5 .hi-cover { background: #e4f4f8; }

/* ── 分数染色卡片（done-card / sidebar-item / history-item 共用） ── */
.score-card-1 { background: #fdf2f2; border-color: rgba(217, 88, 88, 0.35); }
.score-card-2 { background: #fdf6f0; border-color: rgba(224,132, 74, 0.35); }
.score-card-3 { background: #fdfbf0; border-color: rgba(201,160, 32, 0.35); }
.score-card-4 { background: #f2faf2; border-color: rgba( 78,168, 78, 0.35); }
.score-card-5 { background: #f0f8fb; border-color: rgba( 58,157,181, 0.35); }

/* 悬停强化边框 */
.score-card-1:hover { border-color: rgba(217, 88, 88, 0.60); }
.score-card-2:hover { border-color: rgba(224,132, 74, 0.60); }
.score-card-3:hover { border-color: rgba(201,160, 32, 0.60); }
.score-card-4:hover { border-color: rgba( 78,168, 78, 0.60); }
.score-card-5:hover { border-color: rgba( 58,157,181, 0.60); }

/* 活动标签配色 */
.score-card-1 .hi-act, .score-card-1 .done-act-tag { background: rgba(217, 88, 88, 0.12); color: #b83030; }
.score-card-2 .hi-act, .score-card-2 .done-act-tag { background: rgba(224,132, 74, 0.12); color: #aa5820; }
.score-card-3 .hi-act, .score-card-3 .done-act-tag { background: rgba(201,160, 32, 0.12); color: #806a00; }
.score-card-4 .hi-act, .score-card-4 .done-act-tag { background: rgba( 78,168, 78, 0.12); color: #286a28; }
.score-card-5 .hi-act, .score-card-5 .done-act-tag { background: rgba( 58,157,181, 0.12); color: #0e7090; }

/* done-card 分数大字颜色 */
.score-card-1 .done-mood { color: var(--score-1); }
.score-card-2 .done-mood { color: var(--score-2); }
.score-card-3 .done-mood { color: var(--score-3); }
.score-card-4 .done-mood { color: var(--score-4); }
.score-card-5 .done-mood { color: var(--score-5); }

/* 引用线颜色 */
.score-card-1 .done-highlight, .score-card-1 .hi-highlight, .score-card-1 .si-highlight { border-color: rgba(217, 88, 88, 0.40); }
.score-card-2 .done-highlight, .score-card-2 .hi-highlight, .score-card-2 .si-highlight { border-color: rgba(224,132, 74, 0.40); }
.score-card-3 .done-highlight, .score-card-3 .hi-highlight, .score-card-3 .si-highlight { border-color: rgba(201,160, 32, 0.40); }
.score-card-4 .done-highlight, .score-card-4 .hi-highlight, .score-card-4 .si-highlight { border-color: rgba( 78,168, 78, 0.40); }
.score-card-5 .done-highlight, .score-card-5 .hi-highlight, .score-card-5 .si-highlight { border-color: rgba( 58,157,181, 0.40); }

/* done-card 活动分组内部分隔线 */
.score-card-1 .done-act-group { border-color: rgba(217, 88, 88, 0.15); }
.score-card-2 .done-act-group { border-color: rgba(224,132, 74, 0.15); }
.score-card-3 .done-act-group { border-color: rgba(201,160, 32, 0.15); }
.score-card-4 .done-act-group { border-color: rgba( 78,168, 78, 0.15); }
.score-card-5 .done-act-group { border-color: rgba( 58,157,181, 0.15); }

/* ── 重要日期 ──────────────────────────────────────────────────── */
#imp-sidebar {
  background: #fffdf9;
  border: 1px solid #ddd3c8;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 14px rgba(90,52,18,0.07), 0 1px 3px rgba(90,52,18,0.04);
}

.imp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.imp-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .5px;
}

.imp-add-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
}
.imp-add-btn:hover { border-color: var(--accent); color: var(--accent); }

.imp-empty {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 10px 0;
  opacity: .6;
}

.imp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.imp-item:last-child { border-bottom: none; }

.imp-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.imp-item-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.imp-item-repeat {
  font-size: 10px;
  color: var(--muted);
  opacity: .7;
}

.imp-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.imp-countdown {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.imp-today  { color: var(--accent); }
.imp-future { color: var(--text); }
.imp-past   { color: var(--muted); opacity: .7; }

.imp-delete-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: .5;
  transition: opacity .15s, color .15s;
}
.imp-delete-btn:hover { opacity: 1; color: #d95858; }

/* 公历/农历切换 */
.imp-cal-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.imp-cal-btn {
  flex: 1;
  background: none;
  border: none;
  font-size: 11px;
  font-family: var(--font);
  color: var(--muted);
  padding: 5px 0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.imp-cal-btn.active {
  background: var(--accent);
  color: #fff;
}
.imp-cal-btn:not(.active):hover {
  background: var(--border);
  color: var(--text);
}

/* 年月日选择行 */
.imp-date-selects {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 7px;
}

.imp-date-selects span { display: contents; }

.imp-date-selects .imp-year-input,
.imp-date-selects .imp-select {
  height: 28px;
  padding: 0 6px;
  line-height: 28px;
  box-sizing: border-box;
  min-width: 0;
  margin-bottom: 0;
  vertical-align: middle;
}

.imp-year-input               { flex: 1.3; }
.imp-date-selects .imp-select { flex: 1; }

/* 表单 */
.imp-input, .imp-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  margin-bottom: 7px;
  outline: none;
  transition: border-color .15s;
}
.imp-input:focus, .imp-select:focus { border-color: var(--accent); }

.imp-form-row {
  display: flex;
  gap: 7px;
  margin-top: 4px;
}

.imp-btn-save, .imp-btn-cancel {
  flex: 1;
  font-size: 12px;
  font-family: var(--font);
  padding: 6px 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.imp-btn-save {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.imp-btn-save:hover { opacity: .88; }
.imp-btn-cancel {
  background: none;
  color: var(--muted);
}
.imp-btn-cancel:hover { border-color: var(--muted); color: var(--text); }
