/* ========== AI任务拆解器 主容器 ========== */
.atd-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 620px;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.atd-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

/* ========== 顶部工具栏 ========== */
.atd-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.96);
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

.toolbar-btn {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #667eea;
    transition: all 0.2s;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ========== 主内容区（三栏） ========== */
.atd-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f8fafc;
}

/* ========== 左侧历史面板 ========== */
.atd-history-panel {
    width: 210px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.atd-history-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: transparent;
    transition: background 0.2s;
    z-index: 5;
}

.atd-history-panel:hover::after {
    background: rgba(102, 126, 234, 0.15);
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa, #f5f5f5);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.history-clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: all 0.2s;
}

.history-clear-btn:hover {
    background: #fde8e8;
}

.history-search {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.history-search input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.12);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.history-empty {
    text-align: center;
    padding: 24px 12px;
    color: #94a3b8;
    font-size: 12px;
}

.history-empty .empty-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.history-empty p {
    margin: 4px 0;
    line-height: 1.5;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    margin: 3px 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
    position: relative;
    animation: fadeInItem 0.2s ease;
}

@keyframes fadeInItem {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.history-item:hover {
    background: #f1f5ff;
    border-color: #c7d2fe;
    transform: translateX(2px);
}

.history-item.active {
    background: #ede9fe;
    border-color: #8b5cf6;
    box-shadow: 0 1px 4px rgba(139, 92, 246, 0.18);
}

.history-item-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: #fde8e8;
    color: #ef4444;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    opacity: 0;
    transition: all 0.18s;
    border: none;
    cursor: pointer;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: #ef4444;
    color: white;
}

.history-item-title {
    font-weight: 600;
    font-size: 12px;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
    margin-bottom: 3px;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-time {
    color: #94a3b8;
    font-size: 10px;
}

.history-item-depth {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f1f5f9;
    color: #64748b;
}

/* ========== 中间编辑面板 ========== */
.atd-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
    min-width: 300px;
    border-right: 1px solid #e2e8f0;
}

.editor-inner {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ========== 表单样式 ========== */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-row {
    display: flex;
    gap: 14px;
    margin-bottom: 0;
}

.form-half {
    flex: 1;
    min-width: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.label-required {
    color: #ef4444;
}

.label-optional {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1f2937;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #fafafa;
}

.form-input:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.form-textarea {
    width: 100%;
    min-height: 140px;
    max-height: 280px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.7;
    outline: none;
    resize: vertical;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #fafafa;
    font-family: inherit;
}

.form-textarea:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.form-textarea::placeholder, .form-input::placeholder {
    color: #9ca3af;
}

.form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #1f2937;
    outline: none;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
    background: #fff;
}

.char-count {
    text-align: right;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    transition: color 0.2s;
}

.char-count.char-warn {
    color: #f59e0b;
}

.char-count.char-danger {
    color: #ef4444;
    font-weight: 600;
}

/* ========== 拆解按钮 ========== */
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
    margin-bottom: 12px;
}

.decompose-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.decompose-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.45);
}

.decompose-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.decompose-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.decompose-icon {
    font-size: 18px;
}

.decompose-shortcut {
    font-size: 11px;
    opacity: 0.75;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
}

.cancel-btn {
    padding: 12px 18px;
    background: #f87171;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: #ef4444;
    transform: translateY(-1px);
}

.decompose-btn.is-processing {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
    cursor: not-allowed;
}

.decompose-btn.is-processing:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.decompose-btn.is-processing .decompose-icon {
    display: none;
}

.decompose-btn.is-processing .decompose-text::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpinner 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes btnSpinner {
    to { transform: rotate(360deg); }
}

/* 加载进度条 */
.loading-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 25%, #667eea 50%, #764ba2 75%, #667eea 100%);
    background-size: 300% 100%;
    border-radius: 4px;
    animation: loadingShimmer 1.8s ease-in-out infinite;
    width: 100%;
}

@keyframes loadingShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* 状态栏 */
.status-bar {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    animation: fadeIn 0.3s;
}

.status-bar.success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.status-bar.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.status-bar.info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.status-bar.loading {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    color: #6d28d9;
    border: 1px solid #c4b5fd;
    animation: fadeIn 0.3s, loadingPulse 2s ease-in-out 0.3s infinite;
    position: relative;
    width: 90%;
}

.status-bar.loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border: 2px solid rgba(109, 40, 217, 0.2);
    border-top-color: #6d28d9;
    border-radius: 50%;
    animation: statusSpinner 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes statusSpinner {
    to { transform: rotate(360deg); }
}

@keyframes loadingPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.85; }
}

/* ========== 右侧预览面板 ========== */
.atd-preview-panel {
    width: 46%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
    min-width: 300px;
}

.preview-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(to bottom, #fafafa, #f5f5f5);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.preview-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.preview-header-actions {
    display: flex;
    gap: 6px;
}

.preview-action-btn {
    padding: 4px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-action-btn:hover {
    background: #e8ecff;
    border-color: #a5b4fc;
    color: #4f46e5;
}

.preview-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* 空状态 */
.preview-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    height: 100%;
    padding: 40px 32px;
    color: #94a3b8;
    text-align: center;
}

.empty-illustration {
    font-size: 52px;
    margin-bottom: 16px;
    animation: floatBounce 3s ease-in-out infinite;
}

@keyframes floatBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.preview-empty-state h4 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: #64748b;
}

.empty-steps {
    text-align: left;
    margin: 0 0 14px;
    padding-left: 20px;
    font-size: 13px;
    line-height: 2;
}

.empty-hint {
    font-size: 12px;
    color: #b0bec5;
    margin: 0;
}

/* 原始 Markdown 视图 */
.preview-raw {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.raw-textarea {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: 16px;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.7;
    color: #424242;
    background: #fafafa;
    box-sizing: border-box;
}

/* ========== Markdown 渲染样式 ========== */
.preview-rendered {
    padding: 20px 24px;
    line-height: 1.7;
    font-size: 13px;
    color: #1e293b;
}

.preview-rendered .md-h1 {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 18px;
    padding: 10px 16px 10px 14px;
    background: linear-gradient(135deg, #c4b5fd 0%, #a5b4fc 100%);
    border-left: 5px solid #7c3aed;
    border-radius: 0 8px 8px 0;
}

.preview-rendered .md-h1:first-child {
    margin-top: 0;
}

.preview-rendered .md-h2 {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 22px 0 10px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
    border-left: 4px solid #7c3aed;
    border-radius: 0 6px 6px 0;
}

.preview-rendered .md-h2:first-child {
    margin-top: 0;
}

.preview-rendered .md-h3 {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin: 18px 0 8px;
    padding: 7px 12px;
    background: linear-gradient(to right, #f8faff 0%, #ffffff 100%);
    border-left: 3px solid #667eea;
    border-radius: 0 4px 4px 0;
    border-bottom: 1px solid #e8ecff;
}

.preview-rendered .md-p {
    margin: 6px 0;
    color: #374151;
    line-height: 1.7;
}

.preview-rendered .md-hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 16px 0;
}

/* 任务列表 */
.preview-rendered .md-task-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 10px;
}

.preview-rendered .md-task-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    margin: 5px 0;
    background: #fafcff;
    border: 1px solid #e8ecff;
    border-radius: 7px;
    transition: all 0.15s;
}

.preview-rendered .md-task-item:hover {
    background: #f3f4ff;
    border-color: #c7d2fe;
}

.preview-rendered .md-task-item.done {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.task-main-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.md-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid #a5b4fc;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.md-checkbox.checked {
    background: #22c55e;
    border-color: #22c55e;
}

.md-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.task-text {
    flex: 1;
    font-size: 13px;
    color: #1e293b;
}

.md-task-item .md-sub-ul {
    list-style: none;
    padding: 4px 0 0 24px;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.md-sub-priority,
.md-sub-time,
.md-sub-note,
.md-sub-item {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.md-sub-priority {
    background: #f5f3ff;
    color: #6d28d9;
}

.md-sub-time {
    background: #eff6ff;
    color: #1d4ed8;
}

.md-sub-note {
    background: #f9fafb;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.md-sub-item {
    background: #f8fafc;
    color: #475569;
}

.preview-rendered .md-h4 {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    margin: 12px 0 6px;
    padding: 4px 10px;
    background: #f9fafb;
    border-left: 2px solid #a5b4fc;
    border-radius: 0 3px 3px 0;
}

/* 有序列表 */
.preview-rendered .md-ol {
    padding-left: 22px;
    margin: 6px 0;
}

.preview-rendered .md-oli {
    margin: 4px 0;
    color: #374151;
    line-height: 1.6;
    font-size: 13px;
}

/* 普通列表 */
.preview-rendered .md-ul {
    padding-left: 18px;
    margin: 6px 0;
}

.preview-rendered .md-li {
    margin: 4px 0;
    color: #374151;
    line-height: 1.6;
    font-size: 13px;
}

/* 优先级徽章 */
.priority-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.priority-badge.high {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.priority-badge.medium {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fed7aa;
}

.priority-badge.low {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* 行内代码 */
.preview-rendered .md-code {
    background: #f3f4f6;
    color: #374151;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    border: 1px solid #e5e7eb;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    animation: modalIn 0.22s ease-out;
    width: 100%;
}

.modal-wide {
    max-width: 700px;
}

.modal-small {
    max-width: 400px;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}

/* 模板网格 */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.template-item {
    padding: 14px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
}

.template-item:hover {
    background: #f3f4ff;
    border-color: #a5b4fc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.12);
}

.template-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.template-desc {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}

/* 快捷键表格 */
.shortcut-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.shortcut-table tr {
    border-bottom: 1px solid #f1f5f9;
}

.shortcut-table td {
    padding: 9px 12px;
    vertical-align: middle;
}

.shortcut-table td:first-child {
    width: 140px;
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ========== 自定义细滚动条 ========== */
.history-list::-webkit-scrollbar,
.preview-body::-webkit-scrollbar,
.editor-inner::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.history-list::-webkit-scrollbar-track,
.preview-body::-webkit-scrollbar-track,
.editor-inner::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb,
.preview-body::-webkit-scrollbar-thumb,
.editor-inner::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.55);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover,
.preview-body::-webkit-scrollbar-thumb:hover,
.editor-inner::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.8);
}

/* ========== 暗黑模式 ========== */
body.theme-dark .atd-container {
    background: #1e293b;
}

body.theme-dark .atd-toolbar {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

body.theme-dark .atd-main {
    background: #0f172a;
}

body.theme-dark .toolbar-btn {
    background: #3d4a5c;
    color: #e0e0e0;
}

body.theme-dark .toolbar-btn:hover:not(:disabled) {
    background: #4a5a6e;
}

body.theme-dark .atd-history-panel,
body.theme-dark .atd-editor-panel,
body.theme-dark .atd-preview-panel {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .history-panel-header {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.15);
}

body.theme-dark .history-search {
    border-bottom-color: rgba(148, 163, 184, 0.15);
}

body.theme-dark .history-clear-btn {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

body.theme-dark .cancel-btn {
    background: #7f1d1d;
    color: #fca5a5;
}

body.theme-dark .cancel-btn:hover {
    background: #991b1b;
}

body.theme-dark .history-panel-header h3,
body.theme-dark .preview-panel-header h3 {
    color: #e2e8f0;
}

body.theme-dark .history-search input {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .history-item {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .history-item:hover {
    background: rgba(100, 116, 139, 0.2);
}

body.theme-dark .history-item.active {
    background: #312e81;
    border-color: #818cf8;
}

body.theme-dark .history-item-title {
    color: #e2e8f0;
}

body.theme-dark .history-empty {
    color: #64748b;
}

body.theme-dark .form-label {
    color: #cbd5e1;
}

body.theme-dark .form-input,
body.theme-dark .form-textarea,
body.theme-dark .form-select {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .form-input:focus,
body.theme-dark .form-textarea:focus,
body.theme-dark .form-select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
    background: #263348;
}

body.theme-dark .preview-panel-header {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .preview-action-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.theme-dark .preview-action-btn:hover {
    background: #293a52;
    border-color: #818cf8;
    color: #a5b4fc;
}

body.theme-dark .preview-rendered {
    color: #cbd5e1;
}

body.theme-dark .preview-rendered .md-h1 {
    background: linear-gradient(135deg, #312e81, #1e1b4b);
    color: #e2e8f0;
    border-color: #818cf8;
}

body.theme-dark .preview-rendered .md-h2 {
    background: linear-gradient(135deg, #312e81, #1e1b4b);
    color: #e2e8f0;
}

body.theme-dark .preview-rendered .md-h3 {
    background: #1a2035;
    color: #cbd5e1;
    border-color: #818cf8;
    border-bottom-color: #1e2a48;
}

body.theme-dark .preview-rendered .md-h4 {
    background: #1a2035;
    color: #94a3b8;
    border-color: #6366f1;
}

body.theme-dark .preview-rendered .md-p,
body.theme-dark .preview-rendered .md-li {
    color: #94a3b8;
}

body.theme-dark .preview-rendered .md-task-item {
    background: #1e2a3a;
    border-color: #2d3f55;
}

body.theme-dark .preview-rendered .md-task-item:hover {
    background: #1e3058;
}

body.theme-dark .task-text {
    color: #e2e8f0;
}

body.theme-dark .preview-rendered .md-oli {
    color: #94a3b8;
}

body.theme-dark .raw-textarea {
    background: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .history-item-depth {
    background: #1e293b;
    color: #64748b;
}

body.theme-dark .char-count {
    color: #475569;
}

body.theme-dark .loading-bar {
    background: #1e293b;
}

body.theme-dark .status-bar.success {
    background: #052e16;
    color: #4ade80;
    border-color: #166534;
}

body.theme-dark .status-bar.error {
    background: #450a0a;
    color: #f87171;
    border-color: #7f1d1d;
}

body.theme-dark .status-bar.info {
    background: #0c1a33;
    color: #93c5fd;
    border-color: #1e3a5f;
}

body.theme-dark .status-bar.loading {
    background: #1e1b4b;
    color: #c4b5fd;
    border-color: #3730a3;
}

body.theme-dark .status-bar.loading::before {
    border-color: rgba(196, 181, 253, 0.2);
    border-top-color: #c4b5fd;
}

/* 暗黑模式滚动条 */
body.theme-dark .history-list::-webkit-scrollbar-thumb,
body.theme-dark .preview-body::-webkit-scrollbar-thumb,
body.theme-dark .editor-inner::-webkit-scrollbar-thumb,
body.theme-dark .modal-body::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.45);
}

body.theme-dark .history-list::-webkit-scrollbar-thumb:hover,
body.theme-dark .preview-body::-webkit-scrollbar-thumb:hover,
body.theme-dark .editor-inner::-webkit-scrollbar-thumb:hover,
body.theme-dark .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 140, 248, 0.75);
}

body.theme-dark .modal-content {
    background: #1e293b;
}

body.theme-dark .modal-body {
    background: #1e293b;
    color: #cbd5e1;
}

body.theme-dark .template-item {
    background: #263348;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .template-name {
    color: #e2e8f0;
}

body.theme-dark .template-item:hover {
    background: #2e3f66;
    border-color: #818cf8;
}

body.theme-dark .shortcut-table tr {
    border-color: #334155;
}

body.theme-dark kbd {
    background: #263348;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .preview-empty-state h4 {
    color: #94a3b8;
}

body.theme-dark .preview-empty-state {
    color: #64748b;
}

/* ========== 响应式（移动端） ========== */
@media (max-width: 900px) {
    .atd-container {
        height: auto;
        min-height: auto;
    }
    .atd-main {
        flex-direction: column;
    }
    .atd-history-panel {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .atd-preview-panel {
        width: 100%;
        min-height: 300px;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .decompose-shortcut {
        display: none;
    }
}

/* ========== 周末/工作日语义动态背景 ========== */
body.weekend .atd-toolbar {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

body.weekend .atd-container {
    background: #fef9f0;
}

body.weekend .atd-main {
    background: #fef9f0;
}

body.weekend .toolbar-btn {
    color: #ea580c;
}

body.weekend .toolbar-btn:hover:not(:disabled) {
    color: #c2410c;
}

body.weekend .decompose-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

body.weekend .decompose-btn:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
}

body.weekend .history-item.active {
    background: #fef3c7;
    border-color: #f59e0b;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.25);
}

body.weekend .form-input:focus,
body.weekend .form-textarea:focus,
body.weekend .form-select:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* 周末 + 暗黑模式组合：暗化暖色调 */
body.weekend.theme-dark .atd-toolbar {
    background: linear-gradient(135deg, #92400e 0%, #991b1b 100%);
    box-shadow: 0 2px 8px rgba(146, 64, 14, 0.45);
}

body.weekend.theme-dark .atd-container,
body.weekend.theme-dark .atd-main {
    background: #1e293b;
}

body.weekend.theme-dark .decompose-btn {
    background: linear-gradient(135deg, #b45309 0%, #dc2626 100%);
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.35);
}
