/* ============================================================
 * 日历页样式（macOS 日历风格：浅色、圆角、彩色事件条）
 * ============================================================ */
:root {
  --ev-blue: #3b82f6;   --ev-blue-bg: #eff6ff;
  --ev-green: #10b981;  --ev-green-bg: #ecfdf5;
  --ev-orange: #f59e0b; --ev-orange-bg: #fffbeb;
  --ev-red: #ef4444;    --ev-red-bg: #fef2f2;
  --ev-purple: #8b5cf6; --ev-purple-bg: #f5f3ff;
  --ev-pink: #ec4899;   --ev-pink-bg: #fdf2f8;
  --ev-gray: #64748b;   --ev-gray-bg: #f8fafc;
  --cal-border: #e6e8ee;
}

body { background: #f3f4f7; }

.cal-layout {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
}

/* ---------------- 左侧栏 ---------------- */
.cal-side {
  width: 252px; flex: none; padding: 16px 14px;
  border-right: 1px solid var(--cal-border);
  background: rgba(251, 251, 253, .86);
  overflow-y: auto;
}
.cal-new { width: 100%; margin-bottom: 16px; }
.cal-side-card {
  background: #fff; border: 1px solid var(--cal-border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.cal-today-date { font-size: 14px; font-weight: 600; margin-top: 2px; }
.cal-today-lunar { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.cal-side-sec { margin-bottom: 20px; }
.cal-side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px;
}
.cal-side-sub { font-weight: 400; }
.cal-side-empty { font-size: 12.5px; color: #9ca3af; padding: 4px 2px; }
.cal-up {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.cal-up:hover { background: rgba(37, 99, 235, .06); }
.cal-up-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.cal-up-main { min-width: 0; }
.cal-up-title {
  font-size: 13px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 190px;
}
.cal-up-time { font-size: 11.5px; color: var(--text-light); }
.cal-colors { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.cal-color-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-light); }
.cal-color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-color-dot.pick { width: 20px; height: 20px; cursor: pointer; border: 2px solid transparent; }
.cal-color-dot.pick.active { border-color: #0f172a; box-shadow: 0 0 0 2px #fff inset; }
.dot-blue { background: var(--ev-blue); }
.dot-green { background: var(--ev-green); }
.dot-orange { background: var(--ev-orange); }
.dot-red { background: var(--ev-red); }
.dot-purple { background: var(--ev-purple); }
.dot-pink { background: var(--ev-pink); }
.dot-gray { background: var(--ev-gray); }

/* ---------------- 主区域 ---------------- */
.cal-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding: 14px 18px 18px; overflow: hidden;
}
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 12px; flex-wrap: wrap;
}
.cal-head-left, .cal-head-right { display: flex; align-items: center; gap: 8px; }
.cal-nav-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--cal-border);
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-light); transition: all .15s;
}
.cal-nav-btn:hover { background: #f1f5f9; color: var(--primary); }
.cal-today-btn { width: auto; padding: 0 12px; font-size: 13px; color: var(--text); }
.cal-title { font-size: 20px; font-weight: 650; margin-left: 6px; letter-spacing: -.01em; }
.cal-loading { font-size: 12px; color: var(--text-light); }
.cal-switch { font-size: 13px; color: var(--text-light); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.cal-switch input { accent-color: var(--primary); }
.cal-view-tabs { display: inline-flex; background: #e9edf3; border-radius: 9px; padding: 2px; }
.cal-view-tabs button {
  border: none; background: transparent; padding: 5px 16px; font-size: 13px;
  border-radius: 7px; cursor: pointer; color: var(--text-light);
}
.cal-view-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* ---------------- 月视图 ---------------- */
.month-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--cal-border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.month-weekhead {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: #fbfbfd; border-bottom: 1px solid var(--cal-border);
}
.month-weekhead span {
  padding: 8px 10px; font-size: 12px; color: var(--text-light);
  font-weight: 600; text-align: right;
}
.month-grid {
  flex: 1; display: grid; grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, minmax(0, 1fr));
}
.month-cell {
  border-right: 1px solid #eef0f4; border-bottom: 1px solid #eef0f4;
  padding: 5px 6px 4px; min-height: 0; overflow: hidden;
  cursor: default; position: relative; transition: background .12s;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: #fafbfe; }
.month-cell.out { background: #fafafa; }
.month-cell.selected { box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .45); }
.cell-top { display: flex; align-items: center; gap: 6px; height: 22px; }
.cell-day {
  font-size: 12.5px; font-weight: 600; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.cell-day-other { color: #b6bcc8; }
.month-cell.today .cell-day { background: var(--primary); color: #fff; }
.cell-lunar {
  font-size: 11px; color: #9aa1b1; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cell-lunar.festival { color: #d97706; }
.cell-add {
  margin-left: auto; opacity: 0; color: var(--primary); font-size: 15px;
  font-weight: 600; cursor: pointer; line-height: 1;
}
.month-cell:hover .cell-add { opacity: 1; }
.cell-events { margin-top: 2px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-ev {
  display: flex; align-items: center; gap: 4px; min-height: 18px;
  border-left: 3px solid var(--ev-blue); background: var(--ev-blue-bg);
  border-radius: 4px; padding: 1px 5px; font-size: 11.5px;
  cursor: pointer; white-space: nowrap; overflow: hidden; color: #1f2937;
}
.cal-ev:hover { filter: brightness(.96); }
.cal-ev .ev-time { color: #64748b; font-size: 10.5px; flex: none; }
.cal-ev .ev-title { overflow: hidden; text-overflow: ellipsis; }
.ev-blue { border-left-color: var(--ev-blue); background: var(--ev-blue-bg); }
.ev-green { border-left-color: var(--ev-green); background: var(--ev-green-bg); }
.ev-orange { border-left-color: var(--ev-orange); background: var(--ev-orange-bg); }
.ev-red { border-left-color: var(--ev-red); background: var(--ev-red-bg); }
.ev-purple { border-left-color: var(--ev-purple); background: var(--ev-purple-bg); }
.ev-pink { border-left-color: var(--ev-pink); background: var(--ev-pink-bg); }
.ev-gray { border-left-color: var(--ev-gray); background: var(--ev-gray-bg); }
.cell-more { font-size: 11px; color: var(--primary); cursor: pointer; padding-left: 3px; }

/* ---------------- 周 / 日视图 ---------------- */
.timegrid-outer {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--cal-border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.tg-head { display: flex; border-bottom: 1px solid var(--cal-border); background: #fbfbfd; }
.tg-gutter { width: 58px; flex: none; }
.tg-head-day {
  flex: 1; min-width: 0; text-align: center; padding: 7px 2px 6px;
  border-left: 1px solid #eef0f4; cursor: pointer;
}
.tg-head-day.today { background: rgba(37, 99, 235, .05); }
.tg-dow { font-size: 11.5px; color: var(--text-light); }
.tg-daynum { font-size: 16px; font-weight: 600; line-height: 1.35; }
.tg-head-day.today .tg-daynum { color: var(--primary); }
.tg-lunar { font-size: 10.5px; color: #9aa1b1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-allday { display: flex; border-bottom: 1px solid var(--cal-border); min-height: 30px; }
.tg-allday-label { font-size: 11px; color: var(--text-light); padding: 7px 6px 0; text-align: right; }
.tg-allday-day {
  flex: 1; min-width: 0; border-left: 1px solid #eef0f4;
  padding: 3px 3px; display: flex; flex-direction: column; gap: 2px;
}
.allday-ev { font-size: 11px; }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.tg-body { display: flex; position: relative; }
.tg-hours { padding-top: 0; }
.tg-hour-label {
  height: 48px; font-size: 11px; color: #9aa1b1; text-align: right;
  padding: 0 8px; transform: translateY(-6px);
}
.tg-day-col {
  flex: 1; min-width: 0; position: relative;
  border-left: 1px solid #eef0f4; cursor: crosshair;
}
.tg-day-col.today { background: rgba(37, 99, 235, .025); }
.tg-slot { height: 48px; border-bottom: 1px solid #f1f3f7; }
.tg-slot:first-child { border-top: 1px solid #f1f3f7; }
.tg-event {
  position: absolute; left: 3px; right: 3px;
  border-left: 3px solid var(--ev-blue); background: var(--ev-blue-bg);
  border-radius: 6px; padding: 2px 6px; font-size: 11.5px;
  overflow: hidden; cursor: pointer; z-index: 2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.tg-event:hover { z-index: 3; box-shadow: 0 2px 8px rgba(15, 23, 42, .14); }
.tg-event-time { font-size: 10px; color: #64748b; white-space: nowrap; }
.tg-event-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event-loc { font-size: 10px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 30~45 分钟的短事件：时间与标题同排，避免两行内容被卡片高度裁掉 */
.tg-event.tg-event-compact {
  display: flex; align-items: baseline; gap: 4px;
  padding: 2px 5px;
}
.tg-event.tg-event-compact .tg-event-time {
  flex: none; font-size: 9.5px; line-height: 1.2;
}
.tg-event.tg-event-compact .tg-event-title {
  flex: 1; min-width: 0; font-size: 11px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-event.tg-event-compact .tg-event-loc { display: none; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 4; pointer-events: none; }
.tg-now::before {
  content: ''; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
}

/* ---------------- 弹窗表单 ---------------- */
.cal-modal { max-width: 620px; }
.cal-confirm { max-width: 420px; }
.cal-modal-foot { align-items: center; }
.cal-modal-foot .spacer { flex: 1; }
.cal-del { margin-right: auto; }
.cal-title-input { font-size: 16px; font-weight: 600; padding: 11px 13px; }
.cal-form-row { display: flex; gap: 10px; }
.cal-form-row .field { flex: 1; min-width: 0; }
.cal-time-field { flex: 0 0 120px !important; }
.cal-color-field { flex: 0 0 190px !important; }
.cal-color-pick { display: flex; gap: 7px; padding-top: 7px; }
.cal-desc { resize: vertical; min-height: 66px; }
.cal-lunar-line {
  display: flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: #7c8495; margin: -4px 0 12px;
}
.cal-lunar-line .icon { width: 14px; height: 14px; }
.cal-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cal-chip {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 5px 12px; border-radius: 16px; font-size: 12.5px;
  cursor: pointer; transition: all .15s;
}
.cal-chip:hover { border-color: #bfdbfe; background: #f8fbff; }
.cal-chip.active { background: rgba(37, 99, 235, .1); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.cal-leap { font-size: 12.5px; padding-top: 8px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 960px) {
  .cal-side { display: none; }
  .cal-main { padding: 10px; }
  .cal-title { font-size: 17px; }
}
@media (max-width: 640px) {
  .cal-layout { height: auto; }
  .cal-main { overflow: visible; }
  .month-wrap, .timegrid-outer { min-height: 70vh; }
  .cell-lunar { display: none; }
  .cal-head-right { width: 100%; justify-content: space-between; }
  .cal-form-row { flex-direction: column; gap: 0; }
  .cal-time-field, .cal-color-field { flex: 1 1 auto !important; }
  .cal-color-pick { padding-bottom: 6px; }
}

/* 日历内提醒：新建入口 / 完成勾选 */
.cal-new-reminder {
  width: 100%; margin: -8px 0 16px;
  border: 1px solid #dbeafe; color: #2563eb; background: #eff6ff;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.cal-new-reminder:hover { background: #dbeafe; }
.cal-ev { position: relative; }
.cal-ev-check {
  width: 13px; height: 13px; flex: none; border: 1.5px solid currentColor;
  border-radius: 50%; background: transparent; color: #64748b;
  display: grid; place-items: center; padding: 0; cursor: pointer;
}
.cal-ev-check.done { background: #10b981; border-color: #10b981; color: #fff; }
.cal-ev-check .icon { width: 8px; height: 8px; }
.cal-ev.is-done { opacity: .62; }
.cal-ev.is-done .ev-title { text-decoration: line-through; }
.cal-ev.is-done .ev-time { text-decoration: line-through; }
.tg-rem-check {
  position: absolute; right: 4px; top: 4px; z-index: 2;
  width: 14px; height: 14px; padding: 0; border: 1.5px solid currentColor;
  border-radius: 50%; background: rgba(255,255,255,.7); color: #64748b;
  display: grid; place-items: center; cursor: pointer;
}
.tg-rem-check.done { background: #10b981; border-color: #10b981; color: #fff; }
.tg-rem-check .icon { width: 8px; height: 8px; }
.tg-event.is-done { opacity: .62; }
.tg-event.is-done .tg-event-title { text-decoration: line-through; }
.tg-event:has(.tg-rem-check) { padding-right: 22px; }
.cal-rem-modal { max-width: 640px; }
