/* ==================== Todo 徽章（标题栏） ==================== */
.todo-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: #fff;
    background: var(--accent);
    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(--accent) 25%, transparent);
    position: relative;
    z-index: var(--z-badge);
}
.todo-badge:hover,
.todo-badge.is-pressed {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.todo-badge .badge-icon {
    display: inline-flex;
    align-items: center;
    font-size:  var(--fs-md);
    line-height: 1;
}
.todo-badge:active {
    transform: scale(0.95);
}
.todo-badge.active {
    background: var(--accent-hover);
}

.todo-badge[data-status="done"] {
    color: var(--todo-done-fg);
    background: var(--todo-done-bg);
    box-shadow: inset 0 0 0 1px var(--todo-done-border);
}
.todo-badge[data-status="done"]:hover,
.todo-badge[data-status="done"].is-pressed,
.todo-badge[data-status="done"].active {
    color: var(--todo-done-fg);
    background: var(--todo-done-bg-hover);
    box-shadow: inset 0 0 0 1px var(--todo-done-border-hover);
}

.todo-badge.has-pending {
    animation: todoBadgePulse 2s ease-in-out 3;
}
@keyframes todoBadgePulse {
    0%, 100% { box-shadow: 0 1px 4px color-mix(in srgb, var(--accent) 25%, transparent); }
    50% { box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent); }
}



.todo-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;
}
.todo-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);
}


.todo-panel-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}


.todo-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(--accent);
    border-radius: 7px 0 0 0;
}
.todo-panel-header .todo-panel-title {
    flex: 1;
}
.todo-panel-header .todo-panel-count {
    font-size:  var(--fs-xs);
    font-weight: 400;
    color: var(--text-muted);
}

.todo-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) {
    .todo-panel-list {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) transparent;
    }
}
.todo-panel-list::-webkit-scrollbar {
    width: 6px;
    height: 6px; /* 横向条同粗：缺 height 时横向会回退 UA 默认厚度（详见 window.css .messages-container 注释） */
}
.todo-panel-list::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}
.todo-panel-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}
.todo-panel-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

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

.todo-panel-list .todo-item:hover {
    background: var(--bg-active);
}


.todo-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    color: var(--text-muted);
    font-size:  var(--fs-sm);
}
.todo-panel-empty-icon {
    font-size:  var(--fs-xl);
    margin-bottom: 4px;
    opacity: 0.4;
}



.todo-item {
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-light);
    transition: background .12s;
    gap: 1px;
}
.todo-item:last-child {
    border-bottom: none;
}
.todo-item:hover {
    background: var(--bg-active);
}
.todo-item.completed {
    opacity: 0.45;
}
.todo-item.completed .todo-desc {
    text-decoration: line-through;
    color: var(--text-muted);
}
.todo-item.in-progress {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft, color-mix(in srgb, var(--accent) 3%, transparent));
}
.todo-item.pending {
    border-left: 3px solid var(--text-muted);
}
.todo-item.blocked {
    border-left: 3px solid var(--warning);
    background: var(--warning-soft, color-mix(in srgb, var(--warning) 5%, transparent));
}
.todo-item.blocked .todo-status-icon {
    opacity: 0.5;
}


.todo-item-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}

.todo-status-icon {
    font-size:  var(--fs-sm);
    flex-shrink: 0;
    line-height: 1.4;
}

.todo-desc {
    flex: 1;
    font-size:  var(--fs-sm);
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    min-width: 0;
}


.todo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 5px;
    padding-left: 20px;
}
.todo-meta-empty {
    display: none;
}

.todo-meta-item {
    font-size:  var(--fs-2xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
    line-height: 1.3;
}

.todo-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.todo-tag {
    background: var(--accent-soft, color-mix(in srgb, var(--accent) 8%, transparent));
    color: var(--accent);
    padding: 0 3px;
    border-radius: 2px;
    font-size:  var(--fs-3xs);
}

.todo-deps {
    color: var(--warning);
}


.todo-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 6px;
    opacity: 0;
    transition: opacity .1s;
}
.todo-item:hover .todo-actions {
    opacity: 1;
}

.todo-action-btn {
    width: 20px;
    height: 20px;
    border: 0;
    background: none;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size:  var(--fs-xs);
    transition: background .12s, color .12s, transform .12s;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}
.todo-action-btn:active {
    transform: scale(0.9);
}
.todo-action-btn:hover,
.todo-action-btn:focus-visible {
    background: var(--bg-active);
    color: var(--text-secondary);
}
.todo-action-done:hover,
.todo-action-done:focus-visible {
    color: var(--success);
}
.todo-action-start:hover,
.todo-action-start:focus-visible {
    color: var(--accent);
}
.todo-action-delete:hover,
.todo-action-delete:focus-visible {
    color: var(--danger);
}
/* 删除请求在途（等后端回执）：禁用并降低存在感，表示「已受理、不必再点」 */
.todo-action-btn:disabled {
    opacity: .35;
    cursor: progress;
}
.todo-action-btn:disabled:hover,
.todo-action-btn:disabled:focus-visible {
    background: none;
    color: var(--text-muted);
}

/* ==================== 移动端：按钮常驻 + 极致紧凑 ==================== */

@media (max-width: 768px) {
    .todo-panel .todo-actions{
        opacity: 1;
    }
    
    .todo-panel .todo-item {
        padding: 5px 10px;
    }
    .todo-panel .todo-actions {
        position: static;
        right: auto;
        top: auto;
        margin-left: auto;
        padding-left: 6px;
        gap: 3px;
    }
    .todo-panel .todo-desc {
        padding-right: 0;
    }
    .todo-panel .todo-item-main {
        min-height: 22px;
        gap: 6px;
        line-height: 1.4;
    }
    .todo-panel .todo-desc {
        font-size:  var(--fs-sm);
        line-height: 1.4;
    }
    .todo-panel .todo-status-icon {
        font-size:  var(--fs-sm);
    }
    .todo-panel .todo-meta {
        padding-left: 20px;
        gap: 2px 5px;
    }
    .todo-panel .todo-meta-item {
        font-size:  var(--fs-2xs);
    }
    .todo-panel .todo-action-btn {
        width: 20px;
        height: 20px;
        font-size:  var(--fs-xs);
        border-radius: 4px;
    }
    .todo-panel-header {
        padding: 4px 8px;
        font-size:  var(--fs-xs);
        border-left-width: 2px;
    }
    .todo-panel.open { max-height: min(50vh, var(--panel-max-h, 50vh)); border-width: 1px; }
    
    
    .todo-panel-list .todo-item:hover {
        background: var(--bg-hover);
    }
    .todo-panel .todo-item.in-progress {
        border-left-width: 2px;
    }
    .todo-panel .todo-item.pending {
        border-left-width: 2px;
    }
    .todo-panel .todo-item.blocked {
        border-left-width: 2px;
    }
}

@media (max-width: 480px) {
    
    .todo-panel .todo-item {
        padding: 5px 10px;
    }
    .todo-panel .todo-desc {
        padding-right: 0;
    }
    .todo-panel .todo-item-main {
        line-height: 1.4;
        gap: 6px;
    }
    .todo-panel .todo-desc {
        font-size:  var(--fs-sm);
        line-height: 1.4;
    }
    .todo-panel .todo-status-icon {
        font-size:  var(--fs-sm);
        line-height: 1.4;
    }
    .todo-panel .todo-meta {
        padding-left: 20px;
        gap: 2px 5px;
    }
    .todo-panel .todo-meta-item {
        font-size:  var(--fs-2xs);
        line-height: 1.3;
    }
    .todo-panel.open { max-height: min(45vh, var(--panel-max-h, 45vh)); }
    .todo-panel-header {
        padding: 5px 10px;
        font-size:  var(--fs-xs);
    }
    .todo-panel .todo-action-btn {
        width: 20px;
        height: 20px;
        font-size:  var(--fs-xs);
        border-radius: 3px;
    }
}

@media (max-width: 375px) {
    .todo-panel .todo-item {
        padding: 5px 10px;
    }
    .todo-panel .todo-desc {
        padding-right: 0;
    }
    .todo-panel .todo-item-main {
        line-height: 1.4;
        gap: 6px;
    }
    .todo-panel .todo-desc {
        font-size:  var(--fs-sm);
        line-height: 1.4;
    }
    .todo-panel .todo-status-icon {
        font-size:  var(--fs-sm);
    }
    .todo-panel .todo-meta {
        padding-left: 20px;
    }
    .todo-panel.open { max-height: min(40vh, var(--panel-max-h, 40vh)); }
    .todo-panel .todo-action-btn {
        width: 20px;
        height: 20px;
        font-size:  var(--fs-xs);
        border-radius: 3px;
    }
    .todo-panel-header {
        padding: 5px 10px;
        font-size:  var(--fs-xs);
    }
}
.todo-status-filter {
    flex-shrink: 0;
}
