/* ===== 日程 / 日历 pane ===== */

.cal-wrap { display: flex; flex-direction: column; gap: 14px; }

/* ---- gate (未验证提示) ---- */
.cal-gate {
    text-align: center;
    padding: 56px 24px;
    background: var(--color-surface-card);
    border: 1px solid var(--color-hairline);
    border-radius: var(--r-xl);
}
.cal-gate h3 { font-family: var(--font-display); font-size: 22px; margin-bottom: 8px; }
.cal-gate p { color: var(--color-muted); margin-bottom: 18px; }

/* ---- toolbar ---- */
.cal-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-period {
    font-family: var(--font-display); font-size: 22px; font-weight: 500;
    letter-spacing: -0.01em; min-width: 130px; text-align: center;
}
.cal-arrow {
    width: 34px; height: 34px; border-radius: var(--r-md);
    border: 1px solid var(--color-hairline); background: var(--color-surface-card);
    color: var(--color-body); font-size: 18px; line-height: 1; cursor: pointer;
}
.cal-arrow:hover { background: var(--color-surface-cream-strong); color: var(--color-ink); }
.cal-today, .cal-btn {
    height: 34px; padding: 0 14px; border-radius: var(--r-md);
    border: 1px solid var(--color-hairline); background: var(--color-surface-card);
    color: var(--color-body); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.cal-today:hover, .cal-btn:hover { background: var(--color-surface-cream-strong); color: var(--color-ink); }
.cal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-btn-primary { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.cal-btn-primary:hover { background: var(--color-primary-active); color: var(--color-on-primary); }

/* ---- 月/周视图切换 ---- */
.cal-viewtoggle {
    position: relative; display: inline-flex; align-items: center;
    height: 34px; padding: 3px; border-radius: var(--r-pill);
    background: var(--color-surface-soft); border: 1px solid var(--color-hairline);
}
.cal-vt-btn {
    position: relative; z-index: 1;
    height: 28px; min-width: 40px; padding: 0 14px;
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 500; color: var(--color-muted);
    border-radius: var(--r-pill); transition: color .22s ease;
}
.cal-vt-btn.is-active { color: var(--color-ink); }
/* 滑动的高亮丸子:跟随激活按钮位置(用 :has 选择当前激活态推导位移) */
.cal-vt-glow {
    position: absolute; top: 3px; left: 3px; z-index: 0;
    width: calc(50% - 3px); height: calc(100% - 6px);
    background: var(--color-canvas); border-radius: var(--r-pill);
    box-shadow: 0 1px 3px rgba(20,20,19,0.12);
    transition: transform .26s cubic-bezier(.34,1.4,.5,1);
}
.cal-viewtoggle:has(.cal-vt-btn[data-mode="week"].is-active) .cal-vt-glow {
    transform: translateX(100%);
}


/* ---- people popover ---- */
.cal-people-wrap { position: relative; }
.cal-people-pop {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    width: 240px; max-height: 340px; overflow: hidden;
    display: flex; flex-direction: column;
    background: var(--color-canvas); border: 1px solid var(--color-hairline);
    border-radius: var(--r-lg); box-shadow: 0 12px 32px rgba(20,20,19,0.14);
    padding: 8px;
}
.cal-people-pop[hidden] { display: none; }
.cal-people-search {
    width: 100%; padding: 7px 10px; margin-bottom: 6px; flex: none;
    border: 1px solid var(--color-hairline); border-radius: var(--r-sm);
    background: var(--color-surface-soft); font: inherit; font-size: 13px; color: var(--color-ink);
}
.cal-people-search:focus { outline: none; border-color: var(--color-primary); background: var(--color-canvas); }
.cal-people-list { overflow-y: auto; flex: 1 1 auto; }
.cal-people-empty { color: var(--color-muted); font-size: 13px; padding: 12px; text-align: center; }
.cal-people-row {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 14px;
}
.cal-people-row:hover { background: var(--color-surface-soft); }
.cal-people-row input { cursor: pointer; }

/* ---- weekday header + grid ---- */
.cal-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    font-size: 12px; color: var(--color-muted); font-weight: 500;
}
.cal-weekdays span { text-align: center; padding: 4px 0; }

.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 1px; background: var(--color-hairline);
    border: 1px solid var(--color-hairline); border-radius: var(--r-lg);
    overflow: hidden;
}
.cal-cell {
    background: var(--color-canvas);
    /* 移动端/窄屏(单列、自然流式滚动)下用固定高度;
       桌面端(下方 @media)改为按可视区平分行高,整月一屏放下、不滚动。 */
    min-height: 84px;
    padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 3px;
    cursor: pointer; transition: background .12s ease; overflow: hidden;
}
.cal-cell:hover { background: var(--color-surface-soft); }
.cal-cell.is-other { background: var(--color-surface-soft); }
.cal-cell.is-other .cal-date { color: var(--color-muted-soft); }
.cal-cell-head { display: flex; align-items: center; justify-content: space-between; }
.cal-date { font-size: 13px; font-weight: 500; color: var(--color-body); line-height: 1.4; }
.cal-cell.is-today .cal-date {
    background: var(--color-primary); color: var(--color-on-primary);
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.cal-fest { font-size: 11px; color: #c0392b; font-weight: 500; max-width: 50%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 阳历数字 + 紧挨着的农历小字 */
.cal-date-group { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.cal-lunar { font-size: 10px; color: var(--color-muted-soft); font-weight: 400; white-space: nowrap; }
.cal-cell.is-other .cal-lunar { color: var(--color-muted-soft); opacity: 0.7; }

.cal-event {
    font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: var(--r-xs);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    border-left: 3px solid transparent; cursor: pointer;
}
.cal-event.k-mine     { background: var(--color-primary-soft); border-left-color: var(--color-primary); color: var(--color-body-strong); }
.cal-event.k-official { background: rgba(93,184,166,0.16); border-left-color: var(--color-accent-teal); color: var(--color-body-strong); }
.cal-event.k-shared   { background: rgba(232,165,90,0.18); border-left-color: var(--color-accent-amber); color: var(--color-body-strong); }
.cal-event.k-group    { background: rgba(122,111,240,0.16); border-left-color: #7a6ff0; color: var(--color-body-strong); }
.cal-event .cal-event-time { color: var(--color-muted); margin-right: 3px; }
.cal-more { font-size: 11px; color: var(--color-muted); padding: 1px 6px; cursor: pointer; }
.cal-more:hover { color: var(--color-primary); }
/* 重复日程标记 ↻ */
.cal-repeat-badge { margin-left: 3px; font-size: 10px; opacity: 0.7; }
.cal-di-tag-rep { color: var(--color-primary); }

/* ---- 视图舞台 + 月/周切换过渡 ---- */
.cal-stage { position: relative; }
.cal-view {
    transition: opacity .26s ease, transform .26s cubic-bezier(.22,.8,.3,1);
}
.cal-view[hidden] { display: none; }
.cal-view.cal-view-month { transform-origin: top center; }
.cal-view.cal-view-week  { transform-origin: top center; }
/* 入场前(刚取消 hidden、尚未加 is-active)的起始态 */
.cal-view-month:not(.is-active) { opacity: 0; transform: scale(.985) translateY(6px); }
.cal-view-week:not(.is-active)  { opacity: 0; transform: scale(.985) translateY(6px); }
.cal-view.is-active { opacity: 1; transform: none; }
.cal-view.is-leaving { opacity: 0; transform: scale(.985) translateY(-6px); }

/* ---- 周视图 ---- */
.cal-view-week { display: flex; flex-direction: column; min-height: 0; }
.cal-week-head {
    display: grid; grid-template-columns: 52px repeat(7, 1fr);
    border: 1px solid var(--color-hairline); border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0; overflow: hidden;
    background: var(--color-canvas);
}
.cal-week-corner { border-right: 1px solid var(--color-hairline); }
.cal-wh-cell {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 6px 2px; border-right: 1px solid var(--color-hairline);
    cursor: pointer; transition: background .12s ease; min-width: 0;
}
.cal-wh-cell:last-child { border-right: 0; }
.cal-wh-cell:hover { background: var(--color-surface-soft); }
.cal-wh-dow { font-size: 11px; color: var(--color-muted); font-weight: 500; }
.cal-wh-date { font-size: 16px; font-weight: 600; color: var(--color-body-strong); line-height: 1.3; }
.cal-wh-cell.is-today .cal-wh-date {
    background: var(--color-primary); color: var(--color-on-primary);
    width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.cal-wh-sub { font-size: 10px; color: var(--color-muted-soft); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-wh-sub.is-fest { color: #c0392b; }

/* 全天横幅区 */
.cal-week-allday {
    display: grid; grid-template-columns: 52px repeat(7, 1fr);
    border-left: 1px solid var(--color-hairline); border-right: 1px solid var(--color-hairline);
    border-bottom: 1px solid var(--color-hairline);
    background: var(--color-surface-soft);
    /* 高度由 JS 通过内联 --cal-allday-h 控制(可拖动调节);此处给默认与上下限 */
    height: var(--cal-allday-h, 64px);
    min-height: 34px; max-height: 320px; overflow-y: auto;
}
.cal-week-allday[hidden] { display: none; }
/* 拖动手柄:位于全天区与时间轴之间 */
.cal-week-allday-resize {
    height: 8px; margin-top: -1px; cursor: ns-resize; position: relative;
    background: var(--color-surface-soft);
    border-left: 1px solid var(--color-hairline); border-right: 1px solid var(--color-hairline);
    transition: background .12s ease;
}
.cal-week-allday-resize[hidden] { display: none; }
.cal-week-allday-resize::before {
    content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 36px; height: 3px; border-radius: 3px; background: var(--color-hairline);
    transition: background .12s ease, width .12s ease;
}
.cal-week-allday-resize:hover::before { background: var(--color-muted); width: 48px; }
.cal-week-allday-resize.is-dragging { background: var(--color-surface-cream-strong); }
.cal-week-allday-resize.is-dragging::before { background: var(--color-primary); width: 48px; }
.cal-wa-corner {
    font-size: 10px; color: var(--color-muted); display: flex;
    align-items: center; justify-content: center; padding: 4px 0;
}
.cal-wa-col {
    border-right: 1px solid var(--color-hairline); padding: 5px 4px;
    display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 34px;
}
.cal-wa-col:last-child { border-right: 0; }
.cal-wa-item {
    font-size: 11px; line-height: 1.4; padding: 4px 6px; border-radius: var(--r-xs);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    border-left: 3px solid transparent; cursor: pointer;
}
.cal-wa-item.k-mine     { background: var(--color-primary-soft); border-left-color: var(--color-primary); color: var(--color-body-strong); }
.cal-wa-item.k-official { background: rgba(93,184,166,0.16); border-left-color: var(--color-accent-teal); color: var(--color-body-strong); }
.cal-wa-item.k-shared   { background: rgba(232,165,90,0.18); border-left-color: var(--color-accent-amber); color: var(--color-body-strong); }
.cal-wa-item.k-group    { background: rgba(122,111,240,0.16); border-left-color: #7a6ff0; color: var(--color-body-strong); }

/* 主时间轴(可滚动) */
.cal-week-scroll {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    border: 1px solid var(--color-hairline); border-top: 0;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    background: var(--color-canvas);
}
.cal-week-body { display: grid; grid-template-columns: 52px repeat(7, 1fr); position: relative; }
.cal-week-axis { border-right: 1px solid var(--color-hairline); }
.cal-wax-row {
    position: relative; box-sizing: border-box;
    border-bottom: 1px solid var(--color-hairline-soft, rgba(0,0,0,0.04));
}
.cal-wax-row span {
    position: absolute; top: -7px; right: 6px;
    font-size: 10px; color: var(--color-muted-soft); background: var(--color-canvas); padding: 0 2px;
}
.cal-week-cols { display: contents; }
.cal-wk-col {
    position: relative; border-right: 1px solid var(--color-hairline);
    box-sizing: border-box;
}
.cal-wk-col:last-child { border-right: 0; }
.cal-wk-col.is-today { background: rgba(204,120,92,0.04); }
.cal-wk-hline {
    position: absolute; left: 0; right: 0; height: 0;
    border-top: 1px solid var(--color-hairline-soft, rgba(0,0,0,0.045));
}
.cal-wk-event {
    position: absolute; box-sizing: border-box;
    padding: 2px 5px; border-radius: var(--r-xs); overflow: hidden;
    border-left: 3px solid transparent; cursor: pointer; z-index: 1;
    display: flex; flex-direction: column; gap: 1px;
    box-shadow: 0 1px 2px rgba(20,20,19,0.07);
    transition: box-shadow .12s ease, transform .12s ease;
}
.cal-wk-event:hover { box-shadow: 0 3px 10px rgba(20,20,19,0.16); z-index: 2; transform: translateY(-1px); }
.cal-wk-event.k-mine     { background: var(--color-primary-soft); border-left-color: var(--color-primary); }
.cal-wk-event.k-official { background: rgba(93,184,166,0.18); border-left-color: var(--color-accent-teal); }
.cal-wk-event.k-shared   { background: rgba(232,165,90,0.2); border-left-color: var(--color-accent-amber); }
.cal-wk-event.k-group    { background: rgba(122,111,240,0.18); border-left-color: #7a6ff0; }
.cal-wk-ev-time { font-size: 10px; color: var(--color-muted); line-height: 1.2; white-space: nowrap; }
.cal-wk-ev-title {
    font-size: 11px; font-weight: 500; color: var(--color-body-strong); line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis;
}
/* 拖动改时:被拖动的块 + 时间提示气泡 */
.cal-wk-event { touch-action: pan-y; }
.cal-wk-event.is-dragging {
    z-index: 20; cursor: grabbing; opacity: 0.96;
    box-shadow: 0 8px 22px rgba(20,20,19,0.28);
    transform: scale(1.02); transition: box-shadow .12s ease, transform .12s ease;
    outline: 2px solid var(--color-primary); outline-offset: -1px;
}
.cal-wk-drag-hint {
    position: absolute; left: 50%; top: -10px; transform: translate(-50%, -100%);
    background: var(--color-ink); color: #fff; font-size: 11px; font-weight: 500;
    padding: 3px 8px; border-radius: var(--r-pill); white-space: nowrap;
    pointer-events: none; box-shadow: 0 3px 10px rgba(20,20,19,0.3); z-index: 30;
}
.cal-wk-drag-hint::after {
    content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--color-ink);
}


/* ---- legend(可点击筛选) ---- */
.cal-legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--color-muted); }
.cal-legend-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--r-pill);
    border: 1px solid transparent; background: transparent;
    color: var(--color-muted); font: inherit; font-size: 12px; cursor: pointer;
    transition: background .12s ease, opacity .12s ease;
}
.cal-legend-item:hover { background: var(--color-surface-card); color: var(--color-ink); }
.cal-legend-item.is-active {
    background: var(--color-surface-cream-strong); color: var(--color-ink);
    border-color: var(--color-hairline); font-weight: 500;
}
.cal-legend-item.is-dim { opacity: 0.45; }
.cal-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.cal-dot.k-mine { background: var(--color-primary); }
.cal-dot.k-official { background: var(--color-accent-teal); }
.cal-dot.k-shared { background: var(--color-accent-amber); }
.cal-dot.k-holiday { background: #c0392b; }

/* ---- day-detail modal list ---- */
.cal-day-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.cal-day-empty { color: var(--color-muted); font-size: 14px; padding: 12px 0; text-align: center; }
.cal-day-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 12px; border-radius: var(--r-md);
    background: var(--color-surface-soft); border-left: 3px solid var(--color-hairline);
}
.cal-day-item.k-mine { border-left-color: var(--color-primary); cursor: pointer; }
.cal-day-item.k-official { border-left-color: var(--color-accent-teal); }
.cal-day-item.k-shared { border-left-color: var(--color-accent-amber); }
.cal-day-item.k-group { border-left-color: #7a6ff0; cursor: pointer; }
.cal-day-item.k-holiday { border-left-color: #c0392b; }
.cal-day-item .cal-di-title { font-weight: 500; color: var(--color-body-strong); font-size: 14px; }
.cal-day-item .cal-di-meta { font-size: 12px; color: var(--color-muted); }
.cal-day-item .cal-di-desc { font-size: 13px; color: var(--color-body); white-space: pre-wrap; }
.cal-di-tag {
    font-size: 10px; padding: 1px 6px; border-radius: var(--r-pill);
    background: var(--color-surface-card); color: var(--color-muted); margin-left: 6px;
}

/* date/time/select inputs inside the event modal —— 对齐 design.md 的 text-input:
   canvas 底、hairline 边、8px 圆角、聚焦 coral 边 + 3px coral 15% 光环 */
.submit-field input[type="date"],
.submit-field input[type="time"],
#calEventForm select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--color-hairline);
    border-radius: var(--r-md); font: 14px var(--font-body); color: var(--color-ink);
    background: var(--color-canvas); outline: 0;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.submit-field input[type="date"]:focus,
.submit-field input[type="time"]:focus,
#calEventForm select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}
/* select:去掉原生外观,补一个与调性一致的 ink-muted 下拉箭头 */
#calEventForm select {
    height: 40px; padding-right: 38px; cursor: pointer;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c6a64' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
#calEventForm .form-grid { display: grid; }
#calEventForm .submit-field label input[type="checkbox"] { margin-right: 6px; }
.submit-msg.is-err { color: #c64545; }
.submit-msg.is-ok { color: #2c6e3f; }

/* ---- 小组管理弹窗 ---- */
.cg-members {
    max-height: 180px; overflow-y: auto; margin-top: 6px;
    border: 1px solid var(--color-hairline); border-radius: var(--r-md); padding: 4px;
}
.cg-divider {
    margin: 18px 0 10px; font-size: 13px; font-weight: 500; color: var(--color-muted);
    border-top: 1px solid var(--color-hairline); padding-top: 14px;
}
.cg-list { display: flex; flex-direction: column; gap: 8px; max-height: 30vh; overflow-y: auto; }
.cg-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-radius: var(--r-md); background: var(--color-surface-soft);
}
.cg-item-main { min-width: 0; }
.cg-item-name { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--color-body-strong); }
.cg-item-members {
    font-size: 12px; color: var(--color-muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}
.cg-item-ops { display: flex; gap: 6px; flex: none; }
.cg-item-ops .btn { height: 30px; padding: 0 10px; font-size: 13px; }

@media (max-width: 560px) {
    .cal-cell { min-height: 72px; }
    .cal-event { font-size: 10px; }
}

/* 桌面端(三列布局,中间列为固定高度)— 让整月日历填满可视区且不滚动:
   日程面板撑满滚动区高度,日历网格 flex 占据剩余空间,6 行平分高度。 */
@media (min-width: 981px) {
    .pane[data-pane="schedule"].is-active {
        display: flex; flex-direction: column; height: 100%;
    }
    .cal-wrap { flex: 1 1 auto; min-height: 0; }
    /* 舞台占满剩余空间;月/周视图都撑满它 */
    .cal-stage { flex: 1 1 auto; min-height: 0; }
    .cal-view.is-active { height: 100%; }
    .cal-view-month.is-active { display: flex; flex-direction: column; }
    .cal-grid {
        flex: 1 1 auto; min-height: 0;
        grid-auto-rows: 1fr;          /* 6 行均分网格高度 */
    }
    .cal-cell { min-height: 0; }       /* 取消固定下限,交给 1fr 行高 */
    /* 周视图:表头/全天固定,时间轴占剩余高度并内部滚动 */
    .cal-view-week.is-active { display: flex; flex-direction: column; }
    .cal-week-scroll { flex: 1 1 auto; }
}

/* 窄屏下周视图给一个合理的固定高度,自然随页面滚动 */
@media (max-width: 980px) {
    .cal-week-scroll { max-height: 60vh; }
}

