/* ==================== 万年历 ==================== */
.cal-card { padding: 18px; }

/* 头部 */
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav h2 {
    margin: 0 6px;
    font-size: 1.35rem;
    font-weight: 700;
    min-width: 148px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.cal-nav-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text-dim);
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.cal-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.cal-views { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.cal-view-btn {
    padding: .28rem .85rem;
    border: 0;
    background: #fff;
    color: var(--text-dim);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
.cal-view-btn + .cal-view-btn { border-left: 1px solid var(--border-strong); }
.cal-view-btn.active { background: var(--accent); color: #fff; }

/* 主体 */
.cal-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 292px;
    gap: 16px;
    align-items: start;
}

/* 星期标题 */
.cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: #f7f8fa;
    overflow: hidden;
}
.cal-week span {
    padding: 7px 0;
    text-align: center;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-dim);
}
.cal-week span.wk { color: #d9534f; }

/* 日期网格 */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    background: var(--border);
    gap: 1px;
}
.cal-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 76px;
    padding: 6px 2px 5px;
    background: #fff;
    cursor: pointer;
    transition: background .12s ease, box-shadow .12s ease;
}
.cal-cell:hover { background: #fff8f5; }
.cal-cell.is-out { background: #fcfcfd; }
.cal-cell.is-out .cal-d { color: #c3c8d0; }
.cal-cell.is-out .cal-l { color: #ccd1d8; }
.cal-cell.is-weekend .cal-d { color: #d9534f; }
.cal-cell.is-out.is-weekend .cal-d { color: #e4b6b5; }
.cal-cell.is-today { background: #fff1ec; box-shadow: inset 0 0 0 1px #ffc4ae; }
.cal-cell.is-sel { background: #fff2ec; box-shadow: inset 0 0 0 2px var(--accent); }

.cal-d {
    font-size: 1.12rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.cal-l {
    font-size: .68rem;
    line-height: 1.2;
    color: var(--text-dim);
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cal-l.is-fest { color: var(--accent); font-weight: 600; }
.cal-l.is-term { color: #2f8f5b; font-weight: 600; }

.cal-badge {
    position: absolute;
    top: 3px;
    right: 4px;
    width: 15px;
    height: 15px;
    line-height: 15px;
    text-align: center;
    border-radius: 4px;
    font-size: .6rem;
    font-style: normal;
    font-weight: 700;
    color: #fff;
}
.cal-badge.is-rest { background: #e05252; }
.cal-badge.is-work { background: #8a929e; }

/* 右侧详情 */
.cal-side {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfbfc;
    padding: 14px;
}
.cal-today {
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-strong);
    margin-bottom: 12px;
}
.cal-today-num {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.cal-today-meta { font-size: .82rem; color: var(--text-dim); margin-top: 2px; }
.cal-today-lunar { font-size: .95rem; font-weight: 600; margin-top: 3px; }

.cal-detail { margin: 0; font-size: .82rem; }
.cal-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #f0f2f5;
}
.cal-row:last-child { border-bottom: 0; }
.cal-row dt { color: var(--text-dim); font-weight: 500; }
.cal-row dd { margin: 0; color: var(--text); }

.cal-next {
    margin-top: 10px;
    padding: 7px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .78rem;
    color: var(--text-dim);
    text-align: center;
}
.cal-next:empty { display: none; }

/* 年视图 */
.cal-year {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.cal-mini {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 10px 10px 8px;
}
.cal-mini-title {
    font-size: .88rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}
.cal-mini-week,
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-mini-week span {
    text-align: center;
    font-size: .62rem;
    color: var(--text-dim);
    padding-bottom: 3px;
}
.cal-mini-cell {
    text-align: center;
    font-size: .7rem;
    line-height: 20px;
    height: 20px;
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}
.cal-mini-cell.is-out { color: #d3d7dd; }
.cal-mini-cell.is-weekend { color: #d9534f; }
.cal-mini-cell.is-out.is-weekend { color: #e8c3c2; }
.cal-mini-cell:hover { background: #fff1ec; }
.cal-mini-cell.is-today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-mini-cell.is-rest { background: #fdeaea; color: #c93b3b; }
.cal-mini-cell.is-work { background: #eef0f3; color: #5c6470; }
.cal-mini-cell.is-fest { color: var(--accent); font-weight: 600; }
.cal-mini-cell.is-term { color: #2f8f5b; font-weight: 600; }

/* 图例 */
.cal-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: .74rem;
    color: var(--text-dim);
}
.cal-legend { display: inline-flex; align-items: center; gap: 4px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-today { background: #fff1ec; box-shadow: inset 0 0 0 1px #ffc4ae; }
.lg-rest { background: #e05252; }
.lg-work { background: #8a929e; }
.lg-term { background: #2f8f5b; }
.cal-note { flex: 1 1 320px; text-align: right; line-height: 1.5; }

/* 响应式 */
@media (max-width: 980px) {
    .cal-body { grid-template-columns: minmax(0, 1fr); }
    .cal-year { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cal-note { text-align: left; }
}
@media (max-width: 640px) {
    .cal-card { padding: 12px; }
    .cal-nav h2 { font-size: 1.1rem; min-width: 110px; margin: 0 2px; }
    .cal-nav-btn { width: 26px; height: 26px; }
    .cal-cell { min-height: 56px; padding: 4px 1px 3px; }
    .cal-d { font-size: .95rem; }
    .cal-l { font-size: .58rem; }
    .cal-badge { width: 12px; height: 12px; line-height: 12px; font-size: .52rem; top: 2px; right: 2px; }
    .cal-year { grid-template-columns: minmax(0, 1fr); }
    .cal-today-num { font-size: 2.1rem; }
}
