/* ==================== 计划任务徽章（标题栏） ==================== */
.sched-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    flex-shrink: 0;
    padding: 1px 8px;
    font-size:  var(--fs-xs);
    font-weight: 600;
    color: var(--sched-badge-fg);
    background: var(--sched-color);
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, transform .15s, box-shadow .15s;
    user-select: none;
    line-height: 1.6;
    vertical-align: middle;
    box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-color) 25%, transparent);
    position: relative;
    z-index: var(--z-badge);
}
.sched-badge:hover,
.sched-badge.is-pressed {
    background: var(--sched-hover);
    transform: scale(1.05);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--sched-color) 35%, transparent);
}
/* 徽标图标：统一 emoji 渲染尺寸，与 Todo 徽标保持一致 */
.sched-badge .badge-icon {
    display: inline-flex;
    align-items: center;
    font-size:  var(--fs-md);
    line-height: 1;
}
.sched-badge:active {
    transform: scale(0.95);
}
.sched-badge.active {
    background: var(--sched-hover);
}

/* ── 徽标状态颜色：active=绿（运行中） / paused=橙（暂停中） / done=灰（已结束） ──
   每组的 :hover / .is-pressed（触屏按下态） / .active（面板打开中）共用同一套配色。 */
.sched-badge[data-status="active"] {
    background: var(--sched-active);
    box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-active) 25%, transparent);
}
.sched-badge[data-status="active"]:hover,
.sched-badge[data-status="active"].is-pressed,
.sched-badge[data-status="active"].active {
    background: var(--sched-active-hover);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--sched-active) 35%, transparent);
}
.sched-badge[data-status="paused"] {
    background: var(--sched-color);
    box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-color) 25%, transparent);
}
.sched-badge[data-status="paused"]:hover,
.sched-badge[data-status="paused"].is-pressed,
.sched-badge[data-status="paused"].active {
    background: var(--sched-hover);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--sched-color) 35%, transparent);
}
.sched-badge[data-status="done"] {
    background: var(--sched-done);
    box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-done) 25%, transparent);
}
.sched-badge[data-status="done"]:hover,
.sched-badge[data-status="done"].is-pressed,
.sched-badge[data-status="done"].active {
    background: var(--sched-done-hover);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--sched-done) 35%, transparent);
}

/* idle=无计划任务：徽标仍显示（灰态）——它是面板与「新建」入口的唯一唤起点 */
.sched-badge[data-status="idle"] {
    background: var(--sched-done);
    box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-done) 25%, transparent);
}
.sched-badge[data-status="idle"]:hover,
.sched-badge[data-status="idle"].is-pressed,
.sched-badge[data-status="idle"].active {
    background: var(--sched-done-hover);
}

.sched-badge.has-pending {
    animation: schedBadgePulse 2s ease-in-out 3;
}
@keyframes schedBadgePulse {
    0%, 100% { box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-color) 25%, transparent); }
    50% { box-shadow: 0 0 12px color-mix(in srgb, var(--sched-color) 50%, transparent); }
}
/* 状态色脉冲（优先于默认橙色脉冲） */
.sched-badge[data-status="active"].has-pending {
    animation: schedBadgePulseGreen 2s ease-in-out 3;
}
@keyframes schedBadgePulseGreen {
    0%, 100% { box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-active) 25%, transparent); }
    50% { box-shadow: 0 0 12px color-mix(in srgb, var(--sched-active) 55%, transparent); }
}
.sched-badge[data-status="paused"].has-pending {
    animation: schedBadgePulseOrange 2s ease-in-out 3;
}
@keyframes schedBadgePulseOrange {
    0%, 100% { box-shadow: 0 1px 4px color-mix(in srgb, var(--sched-color) 25%, transparent); }
    50% { box-shadow: 0 0 12px color-mix(in srgb, var(--sched-color) 55%, transparent); }
}

/* ==================== 计划任务内嵌面板（AgentWindow 内部） ==================== */
.sched-panel {
    position: absolute;
    top: 12px;
    left: 8px;
    right: 20px;
    z-index: var(--z-float-btn);
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease, opacity .2s ease, border-color .25s ease;
    opacity: 0;
    border-bottom: 1px solid transparent;
}
.sched-panel.open {
    max-height: min(400px, var(--panel-max-h, 400px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    border-bottom-color: var(--border-strong);
    background: var(--bg-hover);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-panel);
}

/* 面板内层容器：flex 纵向布局，由列表区单独滚动，滚动条不再横跨标题栏 */
.sched-panel-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

/* 面板头部 */
.sched-panel-header {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    font-size:  var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-strong);
    flex-shrink: 0;
    background: var(--bg-active);
    border-left: 3px solid var(--sched-color);
    border-radius: 7px 0 0 0;
}
.sched-panel-header .sched-panel-title {
    flex: 1;
}
.sched-panel-header .sched-panel-count {
    font-size:  var(--fs-xs);
    font-weight: 400;
    color: var(--text-muted);
}

/* 自动清理开关（面板头部） */
.sched-cleanup-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-right: 8px;
    font-size:  var(--fs-2xs);
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sched-cleanup-toggle:hover {
    color: var(--text-secondary);
}
.sched-cleanup-toggle input {
    margin: 0;
    accent-color: var(--sched-active);
    cursor: pointer;
}

.sched-panel-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 0;
}

/* 面板列表自定义滚动条：内容超长时始终可见（移动端 overlay 滚动条默认不显示，仅滚动时闪现）。
   标准属性仅在【不支持 ::-webkit-scrollbar 的引擎】（Firefox 等）生效：
   Chromium 121+ 一旦读到非 auto 的 scrollbar-width / scrollbar-color，会整体忽略下方
   ::-webkit-scrollbar 精调（几何、圆角、hover 全失效，回退系统 thin 厚度），故做引擎分流。 */
@supports (not selector(::-webkit-scrollbar)) or (-moz-appearance: none) {
    .sched-panel-list {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) transparent;
    }
}
.sched-panel-list::-webkit-scrollbar {
    width: 6px;
    height: 6px; /* 横向条同粗：缺 height 时横向会回退 UA 默认厚度（详见 window.css .messages-container 注释） */
}
.sched-panel-list::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}
.sched-panel-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}
.sched-panel-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* 移动端：隐藏原生 overlay 滚动条（拖动时闪现、停止后消失），改由 JS 滚动条指示器常驻显示 */
@media (max-width: 768px) {
    .sched-panel-list {
        scrollbar-width: none;
    }
    .sched-panel-list::-webkit-scrollbar {
        display: none;
    }
}
.sched-panel-list .sched-item:hover {
    background: var(--bg-active);
}

/* 空状态 */
.sched-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    color: var(--text-muted);
    font-size:  var(--fs-sm);
}
.sched-panel-empty-icon {
    font-size:  var(--fs-xl);
    margin-bottom: 4px;
    opacity: 0.4;
}
.sched-panel-empty-hint {
    margin-top: 4px;
    font-size: var(--fs-xs);
    opacity: 0.75;
    text-align: center;
    line-height: 1.4;
}

/* ==================== 计划任务条目（面板内） ==================== */
.sched-item {
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-light);
    transition: background .12s;
    gap: 1px;
}
.sched-item:last-child {
    border-bottom: none;
}
.sched-item:hover {
    background: var(--bg-active);
}
.sched-item.completed {
    opacity: 0.5;
}
.sched-item.completed .sched-name {
    text-decoration: line-through;
    color: var(--text-muted);
}
.sched-item.active {
    border-left: 3px solid var(--sched-active);
    background: color-mix(in srgb, var(--sched-active) 3%, transparent);
}
.sched-item.paused {
    border-left: 3px solid var(--sched-color);
    background: color-mix(in srgb, var(--sched-color) 3%, transparent);
}
.sched-item.failed {
    border-left: 3px solid var(--danger);
    background: color-mix(in srgb, var(--danger) 4%, transparent);
}

/* 主行 */
.sched-item-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}
.sched-status-icon {
    font-size:  var(--fs-sm);
    flex-shrink: 0;
    line-height: 1.4;
}
.sched-name {
    flex: 1;
    font-size:  var(--fs-sm);
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    min-width: 0;
}

/* 元信息行 */
.sched-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 5px;
    padding-left: 20px;
}
.sched-meta-item {
    font-size:  var(--fs-2xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
    line-height: 1.3;
}
.sched-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.sched-tag {
    background: color-mix(in srgb, var(--sched-color) 8%, transparent);
    color: var(--sched-color);
    padding: 0 3px;
    border-radius: 2px;
    font-size:  var(--fs-3xs);
}

/* ==================== 操作按钮 ==================== */
.sched-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    margin-left: auto;
}
.sched-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 3px;
    font-size:  var(--fs-xs);
    cursor: pointer;
    background: transparent;
    opacity: 0.5;
    transition: opacity .12s, background .12s;
    line-height: 1;
}
.sched-item:hover .sched-action-btn,
.sched-item:focus-within .sched-action-btn {
    opacity: 0.8;
}
.sched-item .sched-action-btn:hover {
    opacity: 1;
    background: var(--bg-active);
}
.sched-action-btn:active {
    transform: scale(0.9);
}
