/* task_window.css — 任务工具窗口样式（横向布局） */
.task-window {
    position: absolute;
    width: 435px;
    background: #fff;
    border-radius: 9px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    user-select: none;
}

.task-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: move;
    background: #f8f9fa;
    border-radius: 9px 9px 0 0;
}

.task-window-title-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    position: relative;
}

.task-window-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.task-window-fallback-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.task-window-fallback-toggle.disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.task-window-fallback-text {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
}

.task-window-fallback-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.task-window-fallback-slider {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.18s ease;
    flex-shrink: 0;
}

.task-window-fallback-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.18s ease;
}

.task-window-fallback-input:checked + .task-window-fallback-slider {
    background: #22c55e;
}

.task-window-fallback-input:disabled + .task-window-fallback-slider {
    cursor: not-allowed;
    opacity: 0.75;
}

.task-window-fallback-input:checked + .task-window-fallback-slider::before {
    transform: translateX(12px);
}

.task-window-fallback-popover {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
    padding: 10px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
    z-index: 10080;
    cursor: default;
    user-select: text;
    white-space: normal;
}

.task-window-fallback-popover[hidden] {
    display: none;
}

.task-window-fallback-popover::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-left: 1px solid #d8dee8;
    border-bottom: 1px solid #d8dee8;
    background: #fff;
    transform: translateY(-50%) rotate(45deg);
}

.task-window-fallback-popover-title {
    font-size: 12px;
    font-weight: 700;
    color: #172033;
    line-height: 1.3;
}

.task-window-fallback-popover-hint {
    margin-top: 3px;
    font-size: 11px;
    color: #667085;
    line-height: 1.35;
}

.task-window-fallback-model-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    margin-top: 9px;
    overflow: auto;
    overscroll-behavior: contain;
}

.task-window-fallback-model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding: 7px 8px;
    border: 1px solid #e5e9f0;
    border-radius: 7px;
    background: #f8fafc;
    cursor: pointer;
}

.task-window-fallback-model-row:hover {
    border-color: #cfd7e3;
    background: #f3f6fa;
}

.task-window-fallback-model-meta {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 7px;
}

.task-window-fallback-model-name {
    overflow: hidden;
    color: #1f2937;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-window-fallback-model-credit {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: #f59e0b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.task-window-fallback-credit-icon {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
}

.task-window-fallback-model-check {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    accent-color: #22c55e;
    cursor: pointer;
}

.task-window-fallback-empty {
    margin-top: 9px;
    padding: 8px;
    border-radius: 7px;
    background: #f8fafc;
    color: #667085;
    font-size: 11px;
    line-height: 1.35;
}

.task-window-fallback-popover-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 9px;
}

.task-window-fallback-confirm {
    height: 26px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: #172033;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.task-window-fallback-confirm:hover {
    background: #243047;
}

.task-window-close {
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    color: #888;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
}

.task-window-close:hover { background: #eee; color: #333; }
.task-window-close:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: none;
    color: #aaa;
}
.task-window-close:disabled:hover {
    background: none;
    color: #aaa;
}
.task-window-header.dragging { opacity: 0.8; cursor: grabbing; }

/* 横向排列区域 */
.task-window-body {
    padding: 9px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* 提示词区域 */
.task-window-prompt-section {
    flex: 1;
    position: relative;
}

.task-window-prompt-textarea {
    width: 100%;
    padding: 7px 36px 24px 9px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    resize: none;
    min-height: 58px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}

.task-window-prompt-textarea:focus { border-color: #4a90e2; }

.task-prompt-optimize-btn {
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #374151;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.task-prompt-optimize-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

.task-prompt-optimize-btn:hover {
    background: #fff;
    color: #4a90e2;
    transform: translateY(-1px);
}

.task-prompt-optimize-btn:disabled {
    opacity: 0.46;
    cursor: not-allowed;
    transform: none;
}

.task-prompt-optimize-btn::before {
    content: "优化提示词";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 3px 9px;
    border-radius: 5px;
    background: #1a1a1a;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 4;
}

.task-prompt-optimize-btn:hover::before,
.task-prompt-optimize-btn:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

.task-prompt-optimize-popover {
    position: absolute;
    z-index: 10020;
    width: auto;
    max-width: min(420px, calc(100vw - 32px));
    min-width: 300px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
    color: #111827;
    overflow: hidden;
    transform-origin: top left;
}

.task-prompt-optimize-popover::before {
    content: "";
    position: absolute;
    left: -6px;
    right: auto;
    bottom: -7px;
    width: 12px;
    height: 12px;
    border-right: 1px solid rgba(15, 23, 42, 0.12);
    border-bottom: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.98);
    transform: rotate(45deg);
}

.task-prompt-optimize-popover.below::before {
    top: -7px;
    bottom: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 1px solid rgba(15, 23, 42, 0.12);
    border-top: 1px solid rgba(15, 23, 42, 0.12);
}

.task-prompt-optimize-body {
    position: relative;
    max-height: min(460px, 62vh);
    padding: 12px;
    overflow: auto;
    overscroll-behavior: contain;
}

.task-prompt-optimize-section + .task-prompt-optimize-section {
    margin-top: 10px;
}

.task-prompt-optimize-label {
    margin-bottom: 5px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
}

.task-prompt-optimize-text {
    padding: 8px 9px;
    border-radius: 8px;
    background: #f5f6f8;
    color: #1f2937;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.task-prompt-optimize-result {
    background: #eef6ff;
}

.task-prompt-optimize-status {
    display: flex;
    align-items: center;
    min-height: 42px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 700;
}

.task-prompt-optimize-status.error {
    color: #dc2626;
}

.task-prompt-optimize-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.task-prompt-optimize-actions button {
    min-width: 58px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.task-prompt-optimize-actions button:hover {
    background: #f3f4f6;
}

.task-prompt-optimize-actions button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.task-prompt-optimize-actions .task-prompt-optimize-replace {
    border-color: #111827;
    background: #111827;
    color: #fff;
}

.task-prompt-optimize-actions .task-prompt-optimize-replace:hover {
    background: #374151;
}

/* 底部控件栏：模型 + 比例 + 生成按钮 */
.task-window-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.task-window-model-section,
.task-window-ratio-section {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.task-window-model-section {
    flex: 1 1 0;
    margin-right: 4px;
}

.task-window-model-section .task-window-control-label,
.task-window-ratio-section .task-window-control-label {
    flex: 0 0 auto;
}

.task-window-ratio-section {
    flex: 0 0 auto;
}

.task-window-control-label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.task-window-model-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    color: #333;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: none;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.task-window-model-select::-ms-expand {
    display: none;
}

.task-window-model-select:focus { border-color: #4a90e2; }

.task-model-picker {
    position: relative;
    flex: 1 1 auto;
    width: 146px;
    min-width: 0;
    max-width: 146px;
}

.task-model-picker .task-window-model-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.task-model-trigger {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 28px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    box-sizing: border-box;
}

.task-model-options {
    position: absolute;
    left: 0;
    bottom: calc(100% + 5px);
    z-index: 10050;
    width: max-content;
    min-width: 172px;
    max-width: 260px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .16);
}

.task-model-option {
    width: 100%;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #333;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.task-model-option:hover,
.task-model-option.selected {
    background: #f3f4f6;
}

.task-model-option-name {
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-model-option .model-credit-inline {
    margin-left: auto;
}

.task-model-trigger-name {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-model-menu-badge {
    height: 17px;
    padding: 0 5px;
    font-size: 10px;
}

.task-window-model-section.disabled .task-window-control-label,
.task-window-ratio-section.disabled .task-window-control-label {
    color: #9ca3af;
}

.task-window-model-select:disabled,
.task-model-trigger[aria-disabled="true"],
.task-ratio-trigger:disabled,
.task-ratio-option:disabled,
.task-resolution-option:disabled,
.task-ratio-dropdown .resolution-option:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.task-model-trigger[aria-disabled="true"]:hover {
    background: #fff;
    color: #333;
}

.task-ratio-trigger:disabled:hover {
    background: #e5e7eb;
    color: #1e293b;
}

.task-ratio-option:disabled:not(.selected):hover {
    background: transparent;
    color: inherit;
}

.task-resolution-option:disabled:not(.selected):hover,
.task-ratio-dropdown .resolution-option:disabled:not(.selected):hover {
    background: white;
    color: #64748b;
}

/* 比例选择器区域 */
.task-window-ratio-section {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* 比例触发按钮（对齐 style.css .ratio-trigger） */
.task-ratio-trigger {
    padding: 5px 10px;
    border: none;
    border-radius: 15px;
    background: #e5e7eb;
    color: #1e293b;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-ratio-trigger::after {
    content: '▼';
    font-size: 0.55rem;
    margin-left: 3px;
}

.task-ratio-trigger:hover {
    background: #9ca3af;
    color: white;
}

/* 比例下拉气泡（对齐 style.css .ratio-dropdown） */
.task-ratio-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 6px;
    background: white;
    border-radius: 9px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 10px;
    display: none;
    z-index: 10000;
    min-width: 280px;
    color: inherit; /* 让 currentColor 能正确传递给子元素的 .res-box */
}

.task-ratio-dropdown.show {
    display: block;
}

/* 比例网格（对齐 style.css .ratio-grid，4列） */
.task-ratio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}

/* 比例选项（对齐 style.css .ratio-dropdown .ratio-option） */
.task-ratio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 7px 5px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.task-ratio-option:hover {
    background: #f3f4f6;
}

.task-ratio-option.selected {
    background: #6366f1;
    color: white;
}

.task-ratio-option .ratio-box {
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 3px;
}

.task-ratio-option.selected .ratio-box {
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
}

.task-ratio-option .ratio-name {
    font-size: 0.65rem;
    color: #64748b;
}

.task-ratio-option.selected .ratio-name {
    color: rgba(255,255,255,0.8);
}

.task-ratio-option.task-nano-auto-option,
.task-resolution-option.task-nano-auto-option {
    border: 1px solid #d7e3f5;
    background: #f5f9ff;
    color: #2563eb;
}

.task-ratio-option.task-nano-auto-option.selected,
.task-resolution-option.task-nano-auto-option.selected {
    border-color: #6366f1;
    background: #6366f1;
    color: #fff;
}

.task-ratio-option.task-nano-auto-option .ratio-name {
    color: inherit;
}

.task-nano-auto-popover {
    margin-top: 8px;
    padding: 9px;
    border: 1px solid #d8eaff;
    border-radius: 8px;
    background: #f8fbff;
}

.task-nano-auto-title {
    color: #334155;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 7px;
}

.task-nano-auto-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.task-nano-auto-fields label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    padding: 5px 7px;
    border: 1px solid #dbe5f2;
    border-radius: 7px;
    background: #fff;
    color: #475569;
    font-size: 0.68rem;
}

.task-nano-auto-fields input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #0f172a;
    font: inherit;
}

.task-nano-auto-fields em {
    color: #94a3b8;
    font-style: normal;
}

.task-nano-auto-result {
    min-height: 17px;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.66rem;
    line-height: 1.35;
}

.task-nano-auto-result.error {
    color: #dc2626;
}

/* 分辨率选择器（复用 style.css .resolution-selector 系列） */
/* 无需重复定义，直接复用 style.css 中的：
   .resolution-selector / .resolution-label / .background-grid / .background-option
   .resolution-grid / .resolution-option / .res-box / .resolution-toapis-grid
   这里只需少量微调 */

/* 分辨率选择器面板（对齐 .resolution-selector） */
.task-resolution-selector {
    padding: 6px 9px;
    border-top: 1px solid #e5e7eb;
}

.task-resolution-label {
    font-size: 0.65rem;
    color: #64748b;
    margin-bottom: 5px;
    text-align: center;
    font-weight: 500;
}

/* 背景选项网格（对齐 .resolution-selector .background-grid） */
.task-background-grid {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 7px;
}

.task-background-option {
    padding: 3px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: white;
    color: #64748b;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.task-background-option:hover {
    border-color: #6366f1;
    color: #6366f1;
}

.task-background-option.selected {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

/* 分辨率选项网格（对齐 .resolution-selector .resolution-grid） */
.task-resolution-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-bottom: 7px;
}

/* 分辨率选项按钮（对齐 .resolution-selector .resolution-grid .resolution-option） */
.task-resolution-option {
    padding: 5px 7px;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: white;
    color: #64748b;
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.task-resolution-option:hover {
    border-color: #6366f1;
    color: #6366f1;
}

.task-resolution-option.selected {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

.task-resolution-option .res-box {
    display: inline-block;
    border: 1px solid currentColor;
    border-radius: 1px;
    background: transparent;
    flex-shrink: 0;
}

.task-resolution-option.selected .res-box {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.2);
}

/* ToAPIs 分辨率网格（对齐 .resolution-selector .resolution-toapis-grid，3列） */
.task-resolution-toapis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    margin-bottom: 6px;
}

/* ToAPIs 分辨率选项按钮（对齐 .resolution-selector .resolution-toapis-grid .resolution-option） */
.task-resolution-toapis-grid .task-resolution-option {
    padding: 3px 4px;
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
    min-width: 0;
    flex-shrink: 1;
}

.task-resolution-toapis-grid .task-resolution-option .res-box {
    flex-shrink: 0;
}

/* 文字不超出按钮边缘：文字 span 自动截断 */
.task-resolution-toapis-grid .task-resolution-option span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* nano-banana 1K/2K/4K 分辨率选择器（复用 style.css .resolution-selector 系列样式） */
.task-ratio-dropdown .resolution-selector {
    padding: 6px 9px;
    border-bottom: 1px solid #e5e7eb;
    display: block;
}
.task-ratio-dropdown .resolution-selector .resolution-label {
    font-size: 0.65rem;
    color: #64748b;
    margin-bottom: 5px;
}
.task-ratio-dropdown .resolution-selector .resolution-options {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.task-ratio-dropdown .resolution-selector .resolution-option {
    padding: 3px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: white;
    color: #1e293b;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}
.task-ratio-dropdown .resolution-selector .resolution-option:hover {
    border-color: #6366f1;
    color: #6366f1;
}
.task-ratio-dropdown .resolution-selector .resolution-option.selected {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

.task-window-action-section {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
}

.task-window-prompts-btn {
    width: 30px;
    height: 30px;
    padding: 5px;
    border: none;
    border-radius: 15px;
    background: #e5e7eb;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.task-window-prompts-btn:hover {
    background: #d1d5db;
    color: #1e293b;
}

.task-window-prompts-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.task-window-action-section .task-window-generate-btn {
    margin-left: 0;
}

.task-window-generate-btn {
    min-width: 58px;
    max-width: 112px;
    padding: 6px 12px;
    border: none;
    border-radius: 15px;
    background: #1a1a1a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.task-window-generate-btn:hover { opacity: 0.85; }
.task-window-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.task-window-generate-btn.loading {
    background: #1a1a1a;
    cursor: wait;
}

/* ============================================================
   以下为卡牌状态样式（保持不变）
   ============================================================ */

/* 空白卡牌 - 初始空状态（未发送生成指令） */
.left-canvas-card.canvas-card-empty {
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 8px;
}

.left-canvas-card.canvas-card-size-input {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
    cursor: default;
}

.task-size-card-form {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.task-size-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1;
    flex-shrink: 0;
}

.task-size-card-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: nowrap;
}

.task-size-force-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #374151;
    white-space: nowrap;
    cursor: pointer;
    min-width: 0;
}

.task-size-force-checkbox {
    width: 13px;
    height: 13px;
    margin: 0;
}

.task-size-force-tip {
    display: none;
    color: #dc2626;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
}

.task-size-unit-select {
    height: 26px;
    flex: 0 0 82px;
    min-width: 82px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    font-size: 12px;
    padding: 0 6px;
    outline: none;
    cursor: pointer;
}

.task-size-unit-select:focus {
    border-color: #4a90e2;
}

.task-size-force-slider-row {
    display: none;
    grid-template-columns: 1fr 72px;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.task-size-force-slider {
    width: 100%;
    height: 18px;
    margin: 0;
    accent-color: #111827;
}

.task-size-force-px {
    font-size: 11px;
    line-height: 1;
    color: #374151;
    text-align: right;
    white-space: nowrap;
}

.task-size-card-row {
    display: grid;
    grid-template-columns: 22px 1fr 28px;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
}

.task-size-unit-label {
    color: #6b7280;
    line-height: 1;
    white-space: nowrap;
}

.task-size-card-input {
    width: 100%;
    height: 28px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0 8px;
    font-size: 12px;
    outline: none;
}

.task-size-card-input::-webkit-outer-spin-button,
.task-size-card-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.task-size-card-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.task-size-card-input:focus {
    border-color: #4a90e2;
}

.task-size-card-confirm {
    height: 30px;
    border: none;
    border-radius: 6px;
    background: #111827;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

.task-size-card-confirm:hover {
    background: #374151;
}

/* 空白卡牌 - 生成中状态 */
.left-canvas-card.canvas-card-generating {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 8px;
}

.left-canvas-card.canvas-card-generating::after {
    content: "正在生成...";
    font-size: 14px;
    color: #888;
    animation: task-pulse 1.5s ease-in-out infinite;
}

@keyframes task-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* 空白卡牌 - 生成失败状态 */
.left-canvas-card.canvas-card-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff5f5;
    border: 1px solid #ffcccc;
    border-radius: 8px;
    padding: 12px;
}

.canvas-card-error-text {
    font-size: 12px;
    color: #e53e3e;
    text-align: center;
    line-height: 1.4;
}

.canvas-card-retry-btn {
    padding: 4px 12px;
    border: 1px solid #e53e3e;
    border-radius: 6px;
    background: #fff;
    color: #e53e3e;
    font-size: 12px;
    cursor: pointer;
}

.canvas-card-retry-btn:hover { background: #fff0f0; }

/* 空白卡牌 - 生成成功闪烁动画 */
.left-canvas-card.canvas-card-success {
    animation: task-success-flash 0.6s ease-out;
}

@keyframes task-success-flash {
    0% { box-shadow: 0 0 0 0 rgba(72, 199, 116, 0.6); }
    50% { box-shadow: 0 0 0 8px rgba(72, 199, 116, 0.2); }
    100% { box-shadow: none; }
}

/* ============================================================
   连线系统样式
   ============================================================ */

/* 连线节点 - 接收点（任务卡牌左侧，只能接收） */
.node-in {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #10b981;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    box-sizing: border-box;
    z-index: 10;
    left: -7px;
    top: 50%;
    margin-top: -7px;
}

.node-in:hover {
    transform: scale(1.3);
    background-color: #059669;
}

.node-in.generating {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.node-in.generating:hover {
    transform: scale(1);
    background-color: #9ca3af;
}

.node-in.snap-ready {
    background-color: #fbbf24;
    transform: scale(1.5);
}

.node-in.snap-invalid {
    background-color: #ef4444;
    transform: scale(1.5);
}

/* 连线节点 - 发出点（有图片的画布卡牌右侧，只能发出） */
.node-out {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #3b82f6;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    box-sizing: border-box;
    z-index: 10;
    right: -7px;
    top: 50%;
    margin-top: -7px;
    /* 默认隐藏，有任务窗口时才显示 */
    display: none;
    pointer-events: none;
}

.node-out:hover {
    transform: scale(1.3);
    background-color: #2563eb;
}

/* 连线删除按钮 */
.line-delete-btn {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 90;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    transition: transform 0.1s, background-color 0.2s;
    user-select: none;
    pointer-events: all;
}

.line-delete-btn:hover {
    transform: scale(1.2);
    background-color: #dc2626;
}

/* ============================================================
   任务窗口参考图样式
   ============================================================ */

.task-references-section {
    padding: 6px 9px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.task-references-section.disabled {
    background: #f4f6f8;
}

.task-references-section.disabled .task-references-header {
    color: #a0a8b3;
}

.task-references-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}

.task-ref-count {
    font-size: 10px;
    color: #999;
}

.task-references-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 0;
}

.task-ref-item {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #fff;
    cursor: grab;
    touch-action: manipulation;
    user-select: none;
}

.task-ref-item.disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.task-ref-item.disabled img {
    filter: grayscale(0.2);
}

.task-ref-item.disabled .task-ref-remove {
    cursor: not-allowed;
    opacity: 0.35;
}

.task-ref-item.is-dragging {
    opacity: 0.55;
    cursor: grabbing;
}

body.task-reference-reordering,
body.task-reference-reordering * {
    cursor: grabbing !important;
}

.task-ref-item.drag-over {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.task-ref-add-slot {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px dashed #b9c2d0;
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    transition: border-color 0.16s, color 0.16s, background 0.16s;
}

.task-ref-add-slot:hover {
    border-color: #4a90e2;
    color: #2563eb;
    background: #f8fbff;
}

.task-ref-add-slot:disabled {
    cursor: not-allowed;
    color: #cbd5e1;
    border-color: #dbe3ee;
    background: #f8fafc;
}

.task-ref-add-icon {
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
    transform: translateY(-1px);
}

.task-reference-add-menu {
    position: fixed;
    z-index: 10080;
    display: none;
    min-width: 138px;
    padding: 5px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.task-reference-add-menu.show {
    display: block;
}

.task-reference-add-menu-btn {
    width: 100%;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 12px;
    text-align: left;
    padding: 0 10px;
    cursor: pointer;
}

.task-reference-add-menu-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

body.task-reference-slot-picking #leftCanvasContainer,
body.task-reference-slot-picking #leftCanvasArea,
body.task-reference-slot-picking .left-canvas-card,
body.task-reference-slot-picking .left-canvas-card * {
    cursor: var(--reference-image-pick-cursor, crosshair) !important;
}

.task-ref-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    user-select: none;
}

.task-ref-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.task-ref-item:hover .task-ref-remove {
    opacity: 1;
}

.task-ref-remove:hover {
    background: #ef4444;
}

/* 生成中任务卡牌等待效果，复制自 cart.html 并自包含，cart.html 删除后不受影响 */
.left-canvas-card.canvas-card-generating {
    display: block;
    background: transparent;
    border: 0;
    border-radius: 24px;
    box-shadow: none;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.left-canvas-card.canvas-card-generating::after {
    content: none;
}

.task-generating-tilt-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.1s ease-out;
    transform-style: preserve-3d;
    z-index: 1;
    container-type: size;
}

.left-canvas-card.canvas-card-generating .node-in {
    z-index: 5;
    transform: translateZ(36px);
}

.left-canvas-card.canvas-card-generating .node-in.generating:hover {
    transform: translateZ(36px) scale(1);
}

.task-generating-card-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    pointer-events: none;
    z-index: 1;
}

.task-generating-loading-card {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: inherit;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.04),
        0 1px 3px rgba(0, 0, 0, 0.02),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(12px, 10cqh, 40px) clamp(12px, 8cqw, 30px);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.task-generating-visual-stage {
    width: min(44cqw, 38cqh, 160px);
    aspect-ratio: 1;
    position: relative;
    margin-bottom: clamp(6px, 8cqh, 40px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 0 1 auto;
}

.task-generating-blob {
    position: absolute;
    filter: blur(12px);
    opacity: 0.8;
    mix-blend-mode: multiply;
    animation: task-generating-move-blob 8s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.task-generating-blob-1 {
    width: 62.5%;
    height: 62.5%;
    background: #ffb1c1;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    top: 6.25%;
    left: 6.25%;
    animation-delay: 0s;
}

.task-generating-blob-2 {
    width: 68.75%;
    height: 68.75%;
    background: #a1c4fd;
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    right: 6.25%;
    bottom: 6.25%;
    animation-delay: -2s;
}

.task-generating-blob-3 {
    width: 56.25%;
    height: 56.25%;
    background: #e2c2ff;
    border-radius: 50% 50% 60% 40% / 50% 60% 40% 50%;
    bottom: 12.5%;
    left: 18.75%;
    animation-delay: -4s;
}

.task-generating-glass-ring {
    position: absolute;
    width: 75%;
    height: 75%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.task-generating-glass-ring svg {
    width: 33.33%;
    height: 33.33%;
    color: #555;
    animation: task-generating-pulse-icon 2s infinite ease-in-out;
}

.task-generating-text-group {
    text-align: center;
    z-index: 2;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.task-generating-main-title {
    font-size: clamp(13px, 6.2cqh, 20px);
    font-weight: 600;
    margin: 0 0 clamp(4px, 3cqh, 12px) 0;
    letter-spacing: 0.5px;
    line-height: 1.2;
    background: linear-gradient(90deg, #1d1d1f 0%, #86868b 50%, #1d1d1f 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: task-generating-shimmer-text 3s linear infinite;
    white-space: nowrap;
}

.task-generating-sub-title {
    font-size: clamp(10px, 4.3cqh, 14px);
    color: #86868b;
    margin: 0;
    min-height: 20px;
    line-height: 1.4;
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
}

.task-generating-progress-wrapper {
    width: 100%;
    height: 6px;
    background: #f0f0f2;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    margin-top: auto;
    flex: 0 0 6px;
}

.task-generating-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #a1c4fd 0%, #e2c2ff 50%, #ffb1c1 100%);
    border-radius: 6px;
    animation: task-generating-loading-bar 1.5s infinite ease-in-out;
}

@keyframes task-generating-move-blob {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    33% { transform: translate(15px, -15px) scale(1.1) rotate(15deg); }
    66% { transform: translate(-10px, 10px) scale(0.9) rotate(-10deg); }
    100% { transform: translate(0, 0) scale(1) rotate(0deg); }
}

@keyframes task-generating-pulse-icon {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

@keyframes task-generating-shimmer-text {
    to { background-position: 200% center; }
}

@keyframes task-generating-loading-bar {
    0% { left: -40%; width: 30%; }
    50% { width: 50%; }
    100% { left: 110%; width: 30%; }
}
