/* ==========================================================================
   365Lab 计划表 - 日历工具专属样式（深度美化版）
   ========================================================================== */

/* ---------- 动画关键帧 ---------- */
@keyframes pulse-today {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--c-primary-rgb, 59,130,246), 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(var(--c-primary-rgb, 59,130,246), 0); }
}

@keyframes pulse-day-number {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes border-glow {
  0%, 100% { border-color: var(--c-primary); }
  50% { border-color: var(--c-primary-light); }
}

/* ---------- 工具主布局 ---------- */
.tool-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: var(--sp-5);
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-5);
  align-items: start;
  animation: tool-fade-in 0.25s ease-out forwards;
}

@keyframes tool-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 防止面板加载时宽度抖动 */
.control-panel,
.right-panel {
  min-width: 0;
  width: 100%;
}

/* 防止面板加载时宽度抖动 */
body {
  background-color: #f4f6fb;
}

/* ---------- 控制面板 ---------- */
.control-panel {
  background: #fafbfd;
  border: 1px solid #e2e5ef;
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  box-shadow: var(--sh-sm);
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-8));
  overflow: hidden;
}
.control-panel-inner {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  padding-right: 2px;
}

.control-panel-inner::-webkit-scrollbar {
  width: 5px;
}
.control-panel-inner::-webkit-scrollbar-track {
  background: transparent;
}
.control-panel-inner::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--r-full);
}
.control-panel-inner::-webkit-scrollbar-thumb:hover {
  background: var(--c-text-light);
}

/* 右侧面板 */
.right-panel {
  background: #fafbfd;
  border: 1px solid #e2e5ef;
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  box-shadow: var(--sh-sm);
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-8));
  overflow: hidden;
}
.right-panel-inner {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  padding-right: 2px;
}

.right-panel-inner::-webkit-scrollbar {
  width: 5px;
}
.right-panel-inner::-webkit-scrollbar-track {
  background: transparent;
}
.right-panel-inner::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--r-full);
}
.right-panel-inner::-webkit-scrollbar-thumb:hover {
  background: var(--c-text-light);
}

/* 面板分区 —— 卡片化 */
.panel-section {
  background: var(--c-surface);
  border: 1px solid #e7eaf2;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.panel-section:last-child {
  margin-bottom: 0;
}

/* 可折叠面板分区 */
.panel-section.collapsible {
  overflow: hidden;
}

.panel-section.collapsible .panel-title {
  cursor: pointer;
  user-select: none;
  padding: var(--sp-1) 0 var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-3);
  position: relative;
  transition: color var(--t-fast);
}

/* 折叠标题左侧强调条 */
.panel-section.collapsible .panel-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  opacity: 0.85;
  transition: opacity var(--t-fast);
}

.panel-section.collapsible .panel-title:hover::before {
  opacity: 1;
}

.panel-section.collapsible .panel-title:hover {
  color: var(--c-primary);
}

.panel-section.collapsible .panel-title::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--c-text-muted);
  border-bottom: 2px solid var(--c-text-muted);
  transform: rotate(-135deg);
  transition: transform var(--t-fast);
  flex-shrink: 0;
}

.panel-section.collapsible .panel-title:hover::after {
  border-color: var(--c-primary);
}

/* 折叠状态：JS 在 .panel-title 上切换 .panel-collapsed */
.panel-section.collapsible .panel-title.panel-collapsed::after {
  transform: rotate(45deg);
}

.panel-section.collapsible .panel-title.panel-collapsed {
  margin-bottom: calc(var(--sp-3) * -1);
}

/* 保留旧类名兼容（max-height 折叠方案，当前 JS 未使用） */
.panel-section.collapsible .panel-content {
  max-height: 600px;
  opacity: 1;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.panel-section.collapsible.collapsed .panel-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

.panel-section.collapsible.collapsed .panel-title::after {
  transform: rotate(45deg);
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--c-text);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  line-height: 1.4;
  transition: color var(--t-fast);
}

.panel-title svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  color: var(--c-primary);
  transition: opacity var(--t-fast);
}

.panel-title:hover svg {
  opacity: 1;
}

/* 搜索框 */
.search-box {
  position: relative;
  margin-bottom: var(--sp-3);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: 0.85rem;
  color: var(--c-text);
  transition: all var(--t-fast);
  outline: none;
}

.search-box input::placeholder {
  color: var(--c-text-light);
}

.search-box input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(var(--c-primary-rgb, 59,130,246), 0.12);
  background: var(--c-surface);
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-light);
  font-size: 0.85rem;
  pointer-events: none;
  transition: color var(--t-fast);
}

.search-box input:focus ~ .search-icon,
.search-box input:focus + .search-icon {
  color: var(--c-primary);
}

/* 月份/年份选择 */
.month-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.nav-arrow {
  width: 32px;
  min-height: 44px;
  padding: 6px 0;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--c-text);
  transition: all var(--t-fast);
  flex-shrink: 0;
}

.nav-arrow:hover {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}

.nav-arrow:active {
  transform: scale(0.95);
}

/* 月份弹窗触发按钮 */
.month-picker-trigger {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  border-radius: 0;
  cursor: pointer;
  transition: all var(--t-fast);
  min-height: 32px;
}

.month-picker-trigger:hover {
  border-color: var(--c-primary);
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.04);
}

.month-picker-text {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--c-text);
}

.month-picker-icon {
  opacity: 0.5;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.month-picker-trigger:hover .month-picker-icon {
  opacity: 0.8;
}

/* 月份弹窗选择器 */
.month-picker-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  animation: fade-in 0.15s ease-out;
}

.month-picker-popup-inner {
  background: white;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  padding: 20px;
  min-width: 300px;
  animation: fade-in 0.2s ease-out;
}

.month-picker-year-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.month-picker-year-nav .year-nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--c-text);
  transition: all var(--t-fast);
}

.month-picker-year-nav .year-nav-btn:hover {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}

.month-picker-year-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
}

.month-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.month-picker-month {
  padding: 10px 4px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-align: center;
  transition: all var(--t-fast);
}

.month-picker-month:hover {
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.08);
  border-color: var(--c-primary-light);
  color: var(--c-primary);
}

.month-picker-month.active {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}

.month-picker-month.current {
  position: relative;
}

.month-picker-month.current::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-primary);
}

.month-picker-month.active.current::after {
  background: white;
}

/* 模板选择按钮组 */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.template-btn {
  padding: var(--sp-3) var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.template-btn .tpl-icon {
  font-size: 1.4rem;
  transition: transform var(--t-fast);
}

.template-btn:hover {
  border-color: var(--c-primary-light);
  color: var(--c-primary);
  background: var(--c-primary-50);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--c-primary-rgb, 59,130,246), 0.1);
}

.template-btn:hover .tpl-icon {
  transform: scale(1.1);
}

.template-btn.active {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
  color: var(--c-primary-dark);
  box-shadow: 0 0 0 1px var(--c-primary), 0 2px 8px rgba(var(--c-primary-rgb, 59,130,246), 0.15);
}

/* 主题选择 */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}

.theme-btn {
  aspect-ratio: 1;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--t-fast);
}

.theme-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-btn.active {
  border-color: var(--c-text);
  box-shadow: 0 0 0 2px white inset, var(--sh-md);
}

.theme-btn .theme-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  opacity: 0;
  transition: opacity var(--t-fast);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-btn.active .theme-check { opacity: 1; }

/* 开关 */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  font-size: 0.9rem;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--c-border-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--t-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.switch input:checked + .switch-slider {
  background: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(var(--c-primary-rgb, 59,130,246), 0.2);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

/* 颜色选择行 */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: 0.9rem;
}

.color-mini {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  cursor: pointer;
  padding: 0;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.color-mini:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 操作按钮组 */
.action-buttons {
  display: grid;
  gap: var(--sp-2);
}

.action-buttons .btn {
  width: 100%;
}

/* 事件列表 */
.event-list {
  max-height: 240px;
  overflow-y: auto;
  margin-top: var(--sp-2);
}

.event-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--c-bg-alt);
  margin-bottom: var(--sp-2);
  font-size: 0.85rem;
  transition: all var(--t-fast);
  border: 1px solid transparent;
}

.event-item:hover {
  background: var(--c-primary-50);
  border-color: rgba(var(--c-primary-rgb, 59,130,246), 0.15);
  transform: translateX(2px);
}

/* 可点击事件项（跳转到编辑器） */
.event-item.clickable {
  cursor: pointer;
}

.event-arrow {
  color: var(--c-text-light);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: color var(--t-fast), transform var(--t-fast);
}

.event-item.clickable:hover .event-arrow {
  color: var(--c-primary);
  transform: translateX(2px);
}

.event-color-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.event-date {
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.event-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-delete {
  border: none;
  background: transparent;
  color: var(--c-text-light);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  line-height: 1;
  transition: all var(--t-fast);
}
.event-delete:hover {
  color: var(--c-danger);
  background: rgba(239, 68, 68, 0.08);
}

.event-edit {
  border: none;
  background: transparent;
  color: var(--c-text-light);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  line-height: 1;
  transition: all var(--t-fast);
}
.event-edit:hover {
  color: var(--c-primary);
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.08);
}

.event-item.editing {
  border-color: var(--c-primary);
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.08);
  box-shadow: 0 0 0 2px rgba(var(--c-primary-rgb, 59,130,246), 0.15);
}

.empty-state {
  text-align: center;
  padding: var(--sp-5) var(--sp-3);
  color: var(--c-text-light);
  font-size: 0.9rem;
}

.empty-state-icon {
  font-size: 2rem;
  opacity: 0.4;
  margin-bottom: var(--sp-2);
}

/* ---------- 日历预览区 ---------- */
.calendar-area {
  min-width: 0;
}

.calendar-wrapper {
  background: var(--c-surface);
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.calendar-wrapper:hover {
  box-shadow: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4mm;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.calendar-title {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  flex: 1;
  background: linear-gradient(135deg, var(--c-text) 0%, var(--c-text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.calendar-title .cal-year {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.calendar-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* 打印画布 - 居中显示，自适应纸张大小，模拟纸张效果 */
.print-canvas {
  background: white;
  padding: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: visible;
  position: relative;
  margin: 0 auto;
  max-width: 100%;
  box-sizing: border-box;
}

/* 提示栏 - 与预览区连接 */
.editor-subtitle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--c-text-muted);
  padding: 8px 10mm 6px;
  border-bottom: 1px solid var(--c-border);
  background: linear-gradient(to bottom, rgba(var(--c-primary-rgb, 59,130,246), 0.03), transparent);
}

.editor-subtitle-bar .subtitle-text {
  flex-shrink: 0;
}

.editor-subtitle-bar .subtitle-ads {
  display: flex;
  gap: 12px;
  margin-left: 16px;
  flex-shrink: 0;
}

.editor-subtitle-bar .ad-link {
  font-size: 0.75rem;
  color: var(--c-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast);
}

.editor-subtitle-bar .ad-link:hover {
  color: var(--c-primary-dark);
  text-decoration: underline;
}

/* 左侧图片广告位 */
.ad-image-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px !important;
}

.ad-image-link {
  display: block;
  border-radius: var(--r-md);
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.ad-image-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.ad-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
}

.print-canvas .calendar-wrapper {
  width: 100%;
  max-width: 100%;
  padding: 8mm 6mm 6mm;
}

/* ---------- 纸张尺寸预览：由 JS 动态设置 aspect-ratio ---------- */

/* ---------- 预览优化：使预览效果与打印效果一致 ---------- */
/* 标题使用纯色（与打印一致），避免渐变在打印时不可见 */
.calendar-wrapper .calendar-title {
  background: none;
  -webkit-text-fill-color: var(--c-text);
  color: var(--c-text);
}
.calendar-wrapper .calendar-title .cal-year {
  background: none;
  -webkit-text-fill-color: var(--c-primary);
  color: var(--c-primary);
}

/* 移除预览中的 hover 缩放变换（打印时不存在），保留背景反馈以便交互 */
.print-canvas .cal-table td:hover {
  transform: none;
  box-shadow: inset 0 0 0 2px rgba(var(--c-primary-rgb, 59,130,246), 0.15);
}
.print-canvas .cal-table td:hover .day-number {
  transform: none;
}
.print-canvas .cal-table td.other-month {
  opacity: 1;
}
.print-canvas .cal-table td.other-month:hover {
  opacity: 1;
}

/* 事件标签：预览中减弱阴影，更接近打印效果 */
.print-canvas .day-event {
  box-shadow: none;
}
.print-canvas .week-event-bar {
  box-shadow: none;
}

/* 备注区域：预览与打印一致 */
.print-canvas .calendar-notes {
  border-top: none;
  margin-top: 8mm;
  padding: 0;
  text-align: left;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 日历表格 ---------- */
/* 使用 border-collapse: separate + 仅右/下边框策略，
   确保内部边框和四周边框粗细完全一致（均为1px，无重叠） */
.cal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: white;
  border-radius: 0;
  overflow: hidden;
  border-top: 1px solid var(--c-border);
  border-left: 1px solid var(--c-border);
  border-right: none;
  border-bottom: none;
}

.cal-table th {
  padding: var(--sp-3) 4px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  text-align: center;
  border-top: none;
  border-left: none;
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  background: rgba(var(--c-surface-rgb, 255,255,255), 0.8);
  position: relative;
}

.cal-table th.weekend {
  color: var(--c-danger);
}

/* 周数列 */
.cal-table th.weeknum-col {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.cal-table td.weeknum-cell {
  text-align: center;
  vertical-align: top;
  padding: 6px 3px;
  color: var(--c-text-light);
  font-size: 0.72rem;
  font-weight: 500;
  background: rgba(var(--c-surface-rgb, 255,255,255), 0.6);
  cursor: pointer;
  border-top: none;
  border-left: none;
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  transition: background var(--t-fast);
  height: 110px;
}

.cal-table td.weeknum-cell:hover {
  background: var(--c-primary-50);
}

.cal-table td.weeknum-cell.has-events {
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.04);
}

/* 隐藏周数格的事件小圆点（使用条状指示器代替） */
.cal-table td.weeknum-cell.has-events::after {
  display: none;
}

.weeknum-label {
  display: block;
  font-size: 0.72rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.week-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-event-bar {
  padding: 1px 3px;
  border-radius: 0;
  font-size: 0.6rem;
  line-height: 1.3;
  color: white;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.week-event-more {
  font-size: 0.6rem;
  color: var(--c-text-muted);
  text-align: center;
}

.cal-table td {
  height: 110px;
  vertical-align: top;
  padding: 6px;
  border-top: none;
  border-left: none;
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.cal-table td:hover {
  background: var(--c-primary-50);
  transform: scale(1.01);
  z-index: 1;
  box-shadow: 0 2px 12px rgba(var(--c-primary-rgb, 59,130,246), 0.1);
}

/* 周末列：仅文字颜色，不调整背景 */

.cal-table td.other-month {
  background: transparent;
  color: var(--c-text-light);
}

.cal-table td.other-month:hover {
  background: transparent;
}

/* 今天日期 - 脉冲动画 */
.cal-table td.today {
  background: var(--c-primary-soft);
  animation: pulse-today 2.5s ease-in-out infinite;
}

.cal-table td.today .day-number {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  color: white;
  animation: pulse-day-number 2.5s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(var(--c-primary-rgb, 59,130,246), 0.35);
}

/* 选中日期 - 更明显视觉反馈 */
.cal-table td.selected-day {
  box-shadow: inset 0 0 0 2px var(--c-primary);
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.06);
  animation: border-glow 1.5s ease-in-out infinite;
}

.cal-table td.selected-day .day-number {
  background: var(--c-primary);
  color: white;
}

/* 定位高亮 - 从计划列表点击定位时显示 */
@keyframes locate-flash {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--c-primary), 0 0 12px rgba(var(--c-primary-rgb, 59,130,246), 0.4); }
  50% { box-shadow: inset 0 0 0 3px var(--c-primary-light), 0 0 20px rgba(var(--c-primary-rgb, 59,130,246), 0.6); }
}

.cal-table td.located-day {
  animation: locate-flash 0.6s ease-in-out 4;
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.12) !important;
  position: relative;
  z-index: 2;
}

/* 红点已移除（用户要求不显示） */

/* 日期数字 - 更精致 */
.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--c-text);
  transition: all var(--t-fast);
}

/* 日期和农历水平排列 */
.day-header {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: flex-start;
  gap: 4px;
  line-height: 1.3;
  overflow: visible;
}
.day-header .lunar-day {
  flex: 0 1 auto;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  font-size: 0.65rem;
  line-height: 1.4;
}

/* 事件内容居左显示 */
.day-events {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.35;
  overflow: visible;
  text-align: left;
}

.cal-table td:hover .day-number {
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.08);
}

.cal-table td.weekend .day-number {
  color: var(--c-danger);
}

.day-event {
  padding: 2px 6px;
  border-radius: 0;
  margin-bottom: 2px;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
  color: white;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.day-event:hover {
  transform: translateX(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* 透明无颜色事件：无边框无背景 */
.day-event-transparent {
  background: transparent !important;
  color: var(--c-text, #1e293b) !important;
  border: none;
}
.day-event-transparent:hover {
  background: rgba(var(--c-text-rgb, 30,41,59), 0.04) !important;
  box-shadow: none;
}
.week-event-transparent {
  background: transparent !important;
  color: var(--c-text, #1e293b) !important;
  border: none;
}

.lunar-day {
  font-size: 0.65rem;
  color: var(--c-text-light);
  margin-top: 1px;
  line-height: 1.3;
}

/* ---------- 主题变体 ---------- */

/* 经典主题 */
.theme-classic .cal-table {
  border-top-color: #94a3b8;
  border-left-color: #94a3b8;
}
.theme-classic .cal-table td {
  border-right-color: #cbd5e1;
  border-bottom-color: #cbd5e1;
}
.theme-classic .cal-table th {
  border-right-color: #94a3b8;
  border-bottom-color: #94a3b8;
  color: #1e293b;
}
.theme-classic .cal-table td.today .day-number {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* 极简主题 */
.theme-minimal .cal-table {
  border-top-color: #d1d5db;
  border-left-color: #d1d5db;
}
.theme-minimal .cal-table td,
.theme-minimal .cal-table th {
  border-right-color: #d1d5db;
  border-bottom-color: #d1d5db;
}
.theme-minimal .cal-table td {
  height: 100px;
}
.theme-minimal .cal-table td:hover {
  background: rgba(59, 130, 246, 0.04);
}
.theme-minimal .cal-table td.today .day-number {
  background: linear-gradient(135deg, #64748b, #475569);
}

/* 暖色主题 */
.theme-warm .cal-table {
  border-top-color: #fdba74;
  border-left-color: #fdba74;
}
.theme-warm .cal-table td {
  border-right-color: #fed7aa;
  border-bottom-color: #fed7aa;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}
.theme-warm .cal-table th {
  color: #c2410c;
  border-right-color: #fdba74;
  border-bottom-color: #fdba74;
}
.theme-warm .cal-table td:hover {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
}
.theme-warm .cal-table td.today {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
}
.theme-warm .cal-table td.today .day-number {
  background: linear-gradient(135deg, #ea580c, #f97316);
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.35);
}
.theme-warm .cal-table td.weekend {
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
}

/* 雅致主题 */
.theme-elegant .cal-table {
  border-top-color: #c4b5fd;
  border-left-color: #c4b5fd;
}
.theme-elegant .cal-table td {
  border-right-color: #ddd6fe;
  border-bottom-color: #ddd6fe;
  background: linear-gradient(180deg, #faf5ff 0%, #f3e8ff 100%);
}
.theme-elegant .cal-table th {
  color: #6b21a8;
  border-right-color: #c4b5fd;
  border-bottom-color: #c4b5fd;
}
.theme-elegant .cal-table td:hover {
  background: linear-gradient(180deg, #f3e8ff 0%, #e9d5ff 100%);
}
.theme-elegant .cal-table td.today .day-number {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.theme-elegant .cal-table td.weekend {
  background: linear-gradient(180deg, #faf5ff 0%, #ede9fe 100%);
}

/* 森林主题 */
.theme-forest .cal-table {
  border-top-color: #86efac;
  border-left-color: #86efac;
}
.theme-forest .cal-table td {
  border-right-color: #bbf7d0;
  border-bottom-color: #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
}
.theme-forest .cal-table th {
  color: #166534;
  border-right-color: #86efac;
  border-bottom-color: #86efac;
}
.theme-forest .cal-table td:hover {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
}
.theme-forest .cal-table td.today .day-number {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
}
.theme-forest .cal-table td.weekend {
  background: linear-gradient(180deg, #f0fdf4 0%, #d1fae5 100%);
}

/* 海洋主题 */
.theme-ocean .cal-table {
  border-top-color: #7dd3fc;
  border-left-color: #7dd3fc;
}
.theme-ocean .cal-table td {
  border-right-color: #bae6fd;
  border-bottom-color: #bae6fd;
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
}
.theme-ocean .cal-table th {
  color: #075985;
  border-right-color: #7dd3fc;
  border-bottom-color: #7dd3fc;
}
.theme-ocean .cal-table td:hover {
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
}
.theme-ocean .cal-table td.today .day-number {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}
.theme-ocean .cal-table td.weekend {
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
}

/* 玫瑰主题 */
.theme-rose .cal-table {
  border-top-color: #fda4af;
  border-left-color: #fda4af;
}
.theme-rose .cal-table td {
  border-right-color: #fecdd3;
  border-bottom-color: #fecdd3;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
}
.theme-rose .cal-table th {
  color: #9f1239;
  border-right-color: #fda4af;
  border-bottom-color: #fda4af;
}
.theme-rose .cal-table td:hover {
  background: linear-gradient(180deg, #ffe4e6 0%, #fecdd3 100%);
}
.theme-rose .cal-table td.today {
  background: linear-gradient(180deg, #ffe4e6 0%, #fecdd3 100%);
}
.theme-rose .cal-table td.today .day-number {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.35);
}
.theme-rose .cal-table td.weekend {
  background: linear-gradient(180deg, #fff1f2 0%, #fecdd3 100%);
}
.theme-rose .cal-table td.other-month {
  background: #fef2f2;
  color: #fca5a5;
}
.theme-rose .day-number {
  color: #881337;
}
.theme-rose .cal-table td.weekend .day-number {
  color: #e11d48;
}
.theme-rose .lunar-day {
  color: #f9a8d4;
}

/* 深色主题 */
.theme-dark .cal-table {
  background: #1e293b;
  color: #e2e8f0;
  border-top-color: #475569;
  border-left-color: #475569;
}
.theme-dark .cal-table td {
  border-right-color: #334155;
  border-bottom-color: #334155;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1;
}
.theme-dark .cal-table th {
  color: #94a3b8;
  border-right-color: #475569;
  border-bottom-color: #475569;
  background: rgba(30, 41, 59, 0.8);
}
.theme-dark .cal-table td.other-month {
  background: #020617;
  color: #475569;
}
.theme-dark .cal-table td:hover {
  background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
}
.theme-dark .cal-table td.today {
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
}
.theme-dark .cal-table td.today .day-number {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}
.theme-dark .cal-table td.selected-day {
  box-shadow: inset 0 0 0 2px #60a5fa;
  background: rgba(59, 130, 246, 0.1);
}
.theme-dark .cal-table td.weekend {
  background: linear-gradient(180deg, #0c1222 0%, #162032 100%);
}
.theme-dark .day-number {
  color: #e2e8f0;
}
.theme-dark .day-event {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.theme-dark .week-event-bar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.theme-dark .cal-table td.weeknum-cell {
  background: rgba(15, 23, 42, 0.5);
  border-right-color: #334155;
  border-bottom-color: #334155;
}
.theme-dark .cal-table td.weeknum-cell.has-events {
  background: rgba(59, 130, 246, 0.08);
}
.theme-dark .cal-table td.weeknum-cell:hover {
  background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
}
.theme-dark .lunar-day {
  color: #64748b;
}

/* 周起始日 */
.cal-table.start-monday th:first-child,
.cal-table.start-monday td:first-child .day-number,
.cal-table.start-sunday th:last-child,
.cal-table.start-sunday td:last-child .day-number {
  /* 颜色由 weekend class 控制 */
}

/* ---------- 顶部工具栏 ---------- */
.calendar-toolbar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: var(--sp-5);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--c-bg-alt);
}

.calendar-toolbar .toolbar-tip {
  width: 100%;
  text-align: left;
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-top: 2px;
  padding-left: var(--sp-1);
}

.calendar-toolbar .btn {
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  border: 1px solid var(--c-border-strong);
}

.calendar-toolbar .btn + .btn {
  margin-left: 2px;
  padding-left: calc(var(--sp-3) + 2px);
}

.calendar-toolbar .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--c-primary-rgb, 59,130,246), 0.15);
  border-color: var(--c-primary);
}

.calendar-toolbar .btn:active {
  transform: translateY(0);
}

.paper-info {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  padding: 6px 12px;
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.06);
  border-radius: var(--r-full);
  border: 1px solid rgba(var(--c-border-rgb, 226,232,240), 0.6);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* ---------- 移动端布局 ---------- */
@media (max-width: 1200px) {
  .tool-layout {
    grid-template-columns: 280px 1fr;
  }
  .right-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    order: 3;
  }
}

@media (max-width: 960px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .control-panel {
    position: static;
    max-height: none;
    order: 2;
  }
  .calendar-area {
    order: 1;
  }
  .right-panel {
    grid-column: auto;
    position: static;
    max-height: none;
    order: 3;
  }
}

@media (max-width: 768px) {
  .cal-table td {
    height: 85px;
    padding: 4px;
  }
  .day-events {
    font-size: 0.65rem;
  }
  .day-number {
    min-width: 24px;
    height: 24px;
    font-size: 0.82rem;
  }
  .template-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .theme-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 640px) {
  .tool-layout {
    padding: var(--sp-3) var(--sp-2);
    gap: var(--sp-3);
  }
  .control-panel {
    padding: var(--sp-3);
  }
  .cal-table td {
    height: 70px;
    padding: 3px;
  }
  .day-events {
    font-size: 0.62rem;
  }
  .day-number {
    min-width: 22px;
    height: 22px;
    font-size: 0.78rem;
  }
  .lunar-day { display: none; }
  .print-canvas { padding: 6mm; }
  .template-grid {
    grid-template-columns: 1fr 1fr;
  }
  .calendar-title {
    font-size: 1.15rem;
  }
  .cal-table th {
    font-size: 0.68rem;
    padding: var(--sp-2) 2px;
  }
  .day-event {
    padding: 1px 4px;
    font-size: 0.6rem;
  }
  .nav-arrow {
    width: 32px;
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .cal-table td {
    height: 56px;
    padding: 2px;
  }
  .day-number {
    min-width: 20px;
    height: 20px;
    font-size: 0.72rem;
  }
  .day-events {
    font-size: 0.55rem;
  }
  .day-event {
    padding: 0 3px;
    margin-bottom: 1px;
  }
}

/* ==========================================================================
   用户体验增强样式
   ========================================================================== */

/* ---------- 操作按钮分组 ---------- */
.action-group {
  display: flex;
  gap: var(--sp-2);
}
.action-group .btn {
  flex: 1;
}
.action-group + .action-group {
  margin-top: var(--sp-1);
}
.action-group-danger {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--c-border);
}

/* ---------- 回到今天按钮 ---------- */
.today-btn {
  color: var(--c-primary);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--r-md) !important;
  border: 1px dashed var(--c-primary-light);
  transition: all var(--t-fast);
}
.today-btn:hover {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
}

/* ---------- 日历单元格增强交互 ---------- */
.cal-table td:hover {
  background: var(--c-primary-50) !important;
  box-shadow: inset 0 0 0 2px rgba(var(--c-primary-rgb, 59,130,246), 0.15);
  z-index: 1;
  position: relative;
}
.cal-table td.today {
  box-shadow: inset 0 0 0 2px var(--c-primary);
}
.cal-table td.other-month {
  opacity: 0.5;
}
.cal-table td.other-month:hover {
  opacity: 0.85;
}

/* ---------- 日期数字 hover 指示 ---------- */
.cal-table td:hover .day-number {
  transform: scale(1.12);
  font-weight: 700;
}

/* ---------- 快捷键提示（底部浮动条） ---------- */
.shortcut-bar {
  position: fixed;
  bottom: var(--sp-3);
  right: var(--sp-3);
  display: flex;
  gap: var(--sp-2);
  z-index: 100;
  opacity: 0.5;
  transition: opacity var(--t-fast);
  pointer-events: none;
}
.shortcut-bar:hover {
  opacity: 1;
}
.shortcut-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--c-text-light);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 3px 8px;
  border-radius: var(--r-full);
  box-shadow: var(--sh-sm);
}
.shortcut-tag kbd {
  display: inline-block;
  padding: 0 4px;
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  line-height: 1.6;
}

/* ---------- 事件列表搜索高亮 ---------- */
.event-text-highlight {
  background: rgba(var(--c-primary-rgb, 59,130,246), 0.12);
  color: var(--c-primary-dark);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* ---------- 日期编辑器模态框增强 ---------- */
.modal-body .empty-state {
  color: var(--c-text-light);
  font-size: 0.88rem;
  padding: var(--sp-4) 0;
  text-align: center;
}

/* ---------- 响应式适配 ---------- */
@media (max-width: 960px) {
  .shortcut-bar {
    display: none;
  }
  .action-group {
    flex-direction: column;
    gap: var(--sp-2);
  }
}

/* ---------- 备注区域 ---------- */
.calendar-notes {
  margin-top: 8mm;
  padding: 0;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
