/*!
 * ARK VISION · 总台样式
 * 只放 Tailwind 不擅长的部分：锁高度、面板状态、拖拽、任务条目、提示条、确认框。
 * 约定：导航栏 64px 不许动；面板宽度由 JS 写入行内 style。
 */

/* ---------- 1. 结构锁死 ---------- */
html,
body {
    height: 100%;
}

body {
    height: 100vh;
}

.navbar {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
}

.btn-label {
    white-space: nowrap;
}

/* ---------- 2. 工作区网格 ---------- */
.ws-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.ws-card {
    min-height: 190px;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ---------- 3. 驾驶舱面板 ---------- */
#ai-panel {
    overflow: hidden;
}

@media (min-width: 1024px) {
    #ai-panel {
        width: 400px;
        transition: width 0.28s ease, opacity 0.28s ease;
    }

    #ai-panel.collapsed {
        opacity: 0;
        border-left-width: 0;
    }

    body.is-dragging #ai-panel {
        transition: none;
    }
}

.panel-close {
    display: none;
}

@media (max-width: 1023px) {
    #ai-panel {
        position: fixed;
        top: 64px;
        bottom: 0;
        right: 0;
        width: min(92vw, 400px);
        border-left: 1px solid #e5e7eb;
        transform: translateX(102%);
        transition: transform 0.25s ease;
        box-shadow: -12px 0 32px rgba(17, 24, 39, 0.14);
    }

    #ai-panel.open {
        transform: none;
    }

    #drag-handle {
        display: none !important;
    }

    .panel-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* 移动端遮罩 */
#backdrop {
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(17, 24, 39, 0.35);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1024px) {
    #backdrop {
        display: none;
    }
}

/* ---------- 4. 拖拽手柄 ---------- */
#drag-handle {
    width: 6px;
    flex: 0 0 6px;
    cursor: col-resize;
    position: relative;
    z-index: 40;
    background: transparent;
    touch-action: none;
}

#drag-handle::after {
    content: "";
    position: absolute;
    inset: 0 2px;
    border-radius: 999px;
    background: transparent;
    transition: background-color 0.15s ease;
}

#drag-handle:hover::after,
#drag-handle.active::after {
    background: #10b981;
}

#drag-handle:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: -2px;
}

body.is-dragging,
body.is-dragging * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* ---------- 5. 滚动条 ---------- */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ---------- 5b. 卡片拖拽排序 ---------- */
.ws-drag-handle {
    flex: 0 0 auto;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

.ws-drag-handle:hover {
    color: #475569;
}

.ws-drag-handle:active {
    cursor: grabbing;
}

.ws-card-ghost {
    opacity: 0.35;
}

.ws-card-chosen {
    box-shadow: 0 18px 40px rgba(17, 24, 39, 0.18);
}

/* ---------- 5c. 模板库 ---------- */
.template-grid {
    display: grid;
    gap: 0.45rem;
}

.template-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #ffffff;
    text-align: left;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.template-btn:hover {
    border-color: #10b981;
    background: #f0fdf4;
}

.template-btn strong {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
}

.template-btn span {
    font-size: 0.65rem;
    color: #9ca3af;
    line-height: 1.4;
}

.template-modal {
    width: min(680px, 100%);
}

.template-modal textarea {
    width: 100%;
    height: min(48vh, 360px);
    margin-top: 0.75rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
    color: #374151;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Microsoft YaHei", monospace;
    font-size: 0.75rem;
    line-height: 1.55;
    resize: vertical;
}

.template-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

/* ---------- 6. 任务条目 ---------- */.task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #ffffff;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.task-item:hover {
    background: #f9fafb;
}

.task-check {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.1rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #d1d5db;
    border-radius: 0.3rem;
    background: #ffffff;
    color: #ffffff;
    font-size: 0.7rem;
    line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.task-check.is-checked {
    background: #10b981;
    border-color: #10b981;
}

.task-priority {
    flex: 0 0 auto;
    margin-top: 0.1rem;
    padding: 0.08rem 0.35rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.4;
}

.task-priority.prio-high {
    background: #fef2f2;
    border-color: #fee2e2;
    color: #dc2626;
}

.task-priority.prio-mid {
    background: #fefce8;
    border-color: #fef9c3;
    color: #ca8a04;
}

.task-priority.prio-low {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #6b7280;
}

.task-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #374151;
    word-break: break-word;
}

.task-item.is-done .task-text {
    color: #9ca3af;
    text-decoration: line-through;
}

.task-meta {
    margin-top: 0.15rem;
    font-size: 0.65rem;
    color: #9ca3af;
}

.task-del {
    flex: 0 0 auto;
    padding: 0.05rem 0.25rem;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.task-del:hover {
    color: #ef4444;
}

@media (hover: hover) {
    .task-del {
        opacity: 0;
    }

    .task-item:hover .task-del,
    .task-del:focus-visible {
        opacity: 1;
    }
}

/* ---------- 7. 操作记录 ---------- */
.audit-item {
    display: flex;
    gap: 0.4rem;
    font-size: 0.7rem;
    line-height: 1.45;
    color: #6b7280;
}

.audit-time {
    flex: 0 0 auto;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

/* ---------- 8. 复制按钮 ---------- */
.copy-btn.copied {
    background: #dcfce7;
    color: #15803d;
}

/* ---------- 9. 提示条 ---------- */
#toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: max-content;
    max-width: 100%;
    padding: 0.55rem 0.8rem;
    border-radius: 0.55rem;
    background: #111827;
    color: #f9fafb;
    font-size: 0.78rem;
    line-height: 1.35;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: none;
}

.toast button {
    color: #6ee7b7;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- 9b. 驾驶舱重新打开 ---------- */
.panel-reopen {
    position: fixed;
    right: 0;
    top: 50%;
    z-index: 25;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    padding: 0.7rem 0.4rem;
    border: 0;
    border-radius: 0.5rem 0 0 0.5rem;
    background: #10b981;
    color: #ffffff;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    box-shadow: -4px 0 14px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.panel-reopen:hover {
    background: #059669;
}

/* ---------- 10. 确认框 ---------- */.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.45);
}

.modal-card {
    width: min(420px, 100%);
    padding: 1.25rem;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.modal-card p {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #6b7280;
}

/* ---------- 11. 杂项 ---------- */
details > summary::-webkit-details-marker {
    display: none;
}

@media (max-width: 430px) {
    .btn-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
