/* ========== CDN配置生成器容器 ========== */
.cdn-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;
}

.cdn-container.fullscreen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

/* ========== 顶部工具栏 ========== */
.cdn-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
    flex-shrink: 0;
}

.cdn-toolbar .toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* 工具栏分组分隔线 */
.cdn-toolbar .toolbar-group + .toolbar-group {
    border-left: 1px solid rgba(255, 255, 255, 0.22);
    padding-left: 12px;
}

.cdn-toolbar .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: #1a56db;
    transition: all 0.2s;
    white-space: nowrap;
}

.cdn-toolbar .toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.cdn-toolbar .toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 主操作按钮 - AI优化（金色高亮） */
.cdn-toolbar .toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.cdn-toolbar .toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.55) !important;
    transform: translateY(-1px);
}

/* AI生成中流光闪光动画 */
@keyframes btnShimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.cdn-toolbar .toolbar-btn.btnShimmer {
    background: linear-gradient(90deg, #d97706 0%, #fde68a 40%, #f59e0b 60%, #d97706 100%) !important;
    background-size: 200% auto !important;
    animation: btnShimmer 1.2s linear infinite !important;
    color: #fff !important;
    pointer-events: none;
}

/* AI侧边栏按钮流光动画（独立于工具栏） */
.ai-btn.btnShimmer {
    background: linear-gradient(90deg, #0c4a6e 0%, #7dd3fc 40%, #1a56db 60%, #0c4a6e 100%) !important;
    background-size: 200% auto !important;
    animation: btnShimmer 1.2s linear infinite !important;
    color: #fff !important;
    pointer-events: none;
    opacity: 1 !important;
}

.cdn-toolbar .provider-select {
    padding: 5px 10px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.cdn-toolbar .provider-select option {
    background: #1e3a5f;
    color: #fff;
}

.cdn-toolbar .provider-select:hover {
    background: rgba(255,255,255,0.25);
}

/* ========== 主内容区 ========== */
.cdn-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f8fafc;
}

/* ========== 左侧历史面板 ========== */
.cdn-history-panel {
    width: 210px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.cdn-history-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.cdn-history-panel .panel-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.cdn-history-panel .clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: all 0.2s;
}

.cdn-history-panel .clear-btn:hover {
    background: #fde8e8;
}

.history-search-wrap {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-search-wrap 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-wrap input:focus {
    border-color: #1a56db;
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

.cdn-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.cdn-history-item {
    padding: 9px 10px;
    margin: 3px 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    animation: fadeInItem 0.2s ease;
}

@keyframes fadeInItem {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

.cdn-history-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateX(2px);
}

.cdn-history-item.active {
    background: #dbeafe;
    border-color: #3b82f6;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2);
}

.history-item-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 17px;
    height: 17px;
    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.2s;
    cursor: pointer;
    line-height: 1;
}

.cdn-history-item:hover .history-item-del {
    opacity: 1;
}

.history-item-del:hover {
    background: #ef4444;
    color: white;
}

.history-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
    margin-bottom: 3px;
}

.history-item-meta {
    font-size: 11px;
    color: #64748b;
    display: flex;
    gap: 6px;
}

.history-item-provider {
    background: #ede9fe;
    color: #6d28d9;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

/* 历史记录数量徽章 */
.history-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: #22c55e;
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    margin-left: 5px;
    line-height: 1;
    vertical-align: middle;
    transition: background 0.3s;
}

/* ========== 中间配置编辑区 ========== */
.cdn-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    min-width: 340px;
    border-right: 1px solid #e2e8f0;
}

/* 标签页 */
.cdn-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    flex-shrink: 0;
    overflow-x: auto;
}

.cdn-tab {
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

.cdn-tab:hover {
    color: #1a56db;
    background: rgba(26, 86, 219, 0.04);
}

.cdn-tab.active {
    color: #1a56db;
    border-bottom-color: #1a56db;
    background: white;
    font-weight: 600;
}

/* 配置表单内容 */
.cdn-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
}

.cdn-tab-pane {
    display: none;
    animation: fadeInPane 0.15s ease;
}

.cdn-tab-pane.active {
    display: block;
}

@keyframes fadeInPane {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 表单组 */
.form-section {
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row.full {
    grid-template-columns: 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 13px;
    color: #1e293b;
    outline: none;
    transition: all 0.2s;
    background: #fff;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1a56db;
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
}

/* textarea 焦点左侧蓝色强调 */
.form-group textarea:focus {
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1), -3px 0 0 #1a56db !important;
}

.form-group input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #1a56db;
    cursor: pointer;
}

.form-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-check-row label {
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

/* 标签管理（路径规则） */
.rule-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    animation: fadeInItem 0.15s ease;
}

.rule-item input, .rule-item select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    background: white;
    min-width: 0;
}

.rule-item input:focus, .rule-item select:focus {
    border-color: #1a56db;
}

.rule-del-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.rule-del-btn:hover {
    color: #ef4444;
}

/* TTL人性化提示 */
.ttl-hint {
    font-size: 11px;
    color: #22c55e;
    font-weight: 500;
    min-height: 14px;
    line-height: 1.4;
    transition: color 0.2s;
}

.ttl-hint.zero {
    color: #f59e0b;
}

/* AI字数统计 */
.ai-char-count {
    text-align: right;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    line-height: 1;
}

.ai-char-count.warn {
    color: #ef4444;
    font-weight: 600;
}

.add-rule-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}

.add-rule-btn:hover {
    border-color: #1a56db;
    color: #1a56db;
    background: #eff6ff;
}

/* 徽标/状态 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.warning { background: #fef3c7; color: #92400e; }
.status-badge.info { background: #dbeafe; color: #1e40af; }

/* ========== 右侧预览面板 ========== */
.cdn-preview-panel {
    width: 42%;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    min-width: 280px;
}

.cdn-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    gap: 8px;
}

.cdn-preview-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cdn-preview-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.preview-action-btn {
    padding: 4px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.preview-action-btn:hover {
    border-color: #1a56db;
    color: #1a56db;
    background: #eff6ff;
}

.cdn-preview-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s;
}

.cdn-preview-body:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.cdn-config-output {
    flex: 1;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.7;
    color: #1e293b;
    background: #fafafa;
    overflow: auto;
    white-space: pre;
    word-break: break-all;
    word-wrap: break-word;
    border: none;
    outline: none;
    resize: none;
    tab-size: 4;
}

.cdn-config-output:empty::before {
    content: '请填写左侧配置项，配置将在此实时预览...';
    color: #94a3b8;
    font-family: inherit;
    white-space: normal;
}

/* 复制成功提示 */
.copy-toast {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

/* 配置统计栏 */
.config-stats-bar {
    padding: 5px 14px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    gap: 14px;
    flex-shrink: 0;
    user-select: none;
}

.config-stats-bar .stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.copy-toast.show {
    opacity: 1;
}

/* ========== 自定义细滚动条 ========== */
.cdn-config-output::-webkit-scrollbar,
.cdn-history-list::-webkit-scrollbar,
.cdn-tab-content::-webkit-scrollbar,
.cdn-ai-sidebar-body::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.cdn-config-output::-webkit-scrollbar-track,
.cdn-history-list::-webkit-scrollbar-track,
.cdn-tab-content::-webkit-scrollbar-track,
.cdn-ai-sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.cdn-config-output::-webkit-scrollbar-thumb,
.cdn-history-list::-webkit-scrollbar-thumb,
.cdn-tab-content::-webkit-scrollbar-thumb,
.cdn-ai-sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 3px;
}

.cdn-config-output::-webkit-scrollbar-thumb:hover,
.cdn-history-list::-webkit-scrollbar-thumb:hover,
.cdn-tab-content::-webkit-scrollbar-thumb:hover,
.cdn-ai-sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.8);
}

/* 预览头部配置名标签 */
.preview-config-name {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    margin-left: 4px;
    border: 1px solid #e2e8f0;
}

/* ========== AI侧边栏 ========== */
.cdn-ai-sidebar {
    position: fixed;
    top: 0;
    right: -440px;
    width: 420px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 100002;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.cdn-ai-sidebar.show {
    right: 0;
}

.cdn-ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
    color: white;
}

.cdn-ai-sidebar-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.cdn-ai-close-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 15px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cdn-ai-close-btn:hover {
    background: rgba(255,255,255,0.35);
}

.cdn-ai-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cdn-ai-result {
    margin-top: 16px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.cdn-ai-result.show {
    display: block;
    animation: fadeInPane 0.2s ease;
}

.cdn-ai-result code, .cdn-ai-result pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

.cdn-ai-result pre {
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}

.cdn-ai-result code {
    padding: 1px 5px;
}

/* AI遮罩 */
.cdn-ai-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.28);
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(2px);
}

.cdn-ai-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* AI输入组 */
.ai-input-group {
    margin-bottom: 16px;
}

.ai-input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
}

.ai-input-group textarea,
.ai-input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.ai-input-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.ai-input-group textarea:focus,
.ai-input-group select:focus {
    border-color: #1a56db;
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

.ai-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.ai-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-btn-primary {
    background: linear-gradient(135deg, #1a56db 0%, #0e9f6e 100%);
    color: white;
}

.ai-btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.ai-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-btn-cancel {
    background: #f44336;
    color: white;
    flex: 0 0 auto;
    padding: 10px 14px;
}

.ai-btn-cancel:hover {
    background: #d32f2f;
}

.ai-apply-btn {
    width: 100%;
    padding: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1a56db;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    display: none;
}

.ai-apply-btn.show {
    display: block;
}

.ai-apply-btn:hover {
    background: #dbeafe;
}

.ai-tips {
    padding: 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 5px;
    font-size: 12px;
    color: #166534;
    line-height: 1.6;
}

.ai-tips p {
    margin: 0 0 6px 0;
    font-weight: 600;
}

.ai-tips ul {
    margin: 0;
    padding-left: 18px;
}

.ai-tips li {
    margin-bottom: 3px;
}

/* ========== 暗黑模式 ========== */
body.theme-dark .cdn-container {
    background: #1e293b;
}

body.theme-dark .cdn-history-panel,
body.theme-dark .cdn-editor-panel,
body.theme-dark .cdn-preview-panel {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .cdn-history-panel .panel-header {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .cdn-history-panel .panel-header h3 {
    color: #e2e8f0;
}

body.theme-dark .history-search-wrap input {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .history-search-wrap input::placeholder {
    color: #64748b;
}

body.theme-dark .cdn-history-item {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

body.theme-dark .cdn-history-item:hover {
    background: #1e3a5f;
    border-color: #3b82f6;
}

body.theme-dark .cdn-history-item.active {
    background: #1e3a5f;
    border-color: #3b82f6;
}

body.theme-dark .history-item-name {
    color: #e2e8f0;
}

body.theme-dark .history-item-meta {
    color: #94a3b8;
}

body.theme-dark .cdn-tabs {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .cdn-tab {
    color: #94a3b8;
}

body.theme-dark .cdn-tab:hover {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.05);
}

body.theme-dark .cdn-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: #0f172a;
}

body.theme-dark .cdn-tab-content {
    background: #0f172a;
}

body.theme-dark .form-section-title {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.15);
}

body.theme-dark .form-group label {
    color: #94a3b8;
}

body.theme-dark .form-group input,
body.theme-dark .form-group select,
body.theme-dark .form-group textarea {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .form-group input:focus,
body.theme-dark .form-group select:focus,
body.theme-dark .form-group textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.15);
}

body.theme-dark .form-check-row label {
    color: #cbd5e1;
}

body.theme-dark .rule-item {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .rule-item input,
body.theme-dark .rule-item select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .add-rule-btn {
    border-color: #334155;
    color: #64748b;
}

body.theme-dark .add-rule-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
}

body.theme-dark .cdn-preview-header {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .cdn-preview-header h3 {
    color: #e2e8f0;
}

body.theme-dark .preview-action-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.theme-dark .preview-action-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
}

body.theme-dark .cdn-config-output {
    background: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .cdn-ai-sidebar {
    background: #1e293b;
}

body.theme-dark .cdn-ai-sidebar-body {
    background: #1e293b;
}

body.theme-dark .ai-input-group label {
    color: #94a3b8;
}

body.theme-dark .ai-input-group textarea,
body.theme-dark .ai-input-group select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .cdn-ai-result {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .ai-tips {
    background: #0f172a;
    border-color: #134e4a;
    color: #6ee7b7;
}

body.theme-dark .ai-tips p {
    color: #a7f3d0;
}

body.theme-dark .cdn-preview-body {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

body.theme-dark .cdn-preview-body:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body.theme-dark .config-stats-bar {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
    color: #64748b;
}

body.theme-dark .ttl-hint {
    color: #4ade80;
}

body.theme-dark .ttl-hint.zero {
    color: #fbbf24;
}

body.theme-dark .ai-char-count {
    color: #475569;
}

body.theme-dark .ai-char-count.warn {
    color: #ef4444;
}

body.theme-dark .history-count-badge {
    background: #16a34a;
}

body.theme-dark .form-group textarea:focus {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.15), -3px 0 0 #60a5fa !important;
}

/* 暗色模式 AI侧边栏 */
body.theme-dark .ai-input-group select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .cdn-config-output::-webkit-scrollbar-thumb,
body.theme-dark .cdn-history-list::-webkit-scrollbar-thumb,
body.theme-dark .cdn-tab-content::-webkit-scrollbar-thumb,
body.theme-dark .cdn-ai-sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(51, 65, 85, 0.9);
}

body.theme-dark .cdn-config-output::-webkit-scrollbar-thumb:hover,
body.theme-dark .cdn-history-list::-webkit-scrollbar-thumb:hover,
body.theme-dark .cdn-tab-content::-webkit-scrollbar-thumb:hover,
body.theme-dark .cdn-ai-sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 1);
}

body.theme-dark .preview-config-name {
    background: #0f172a;
    border-color: #334155;
    color: #64748b;
}

/* ========== 周末/工作日语义动态背景 ========== */
body.weekend .cdn-toolbar {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

body.weekend .cdn-container {
    background: #fef9f0;
}

body.weekend .cdn-main-content {
    background: #fef9f0;
}

body.weekend .cdn-toolbar .toolbar-btn-primary {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

body.weekend .cdn-toolbar .toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.5) !important;
}

body.weekend .cdn-ai-sidebar-header {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

/* 周末 + 暗色模式组合：暗化暖色调 */
body.weekend.theme-dark .cdn-toolbar {
    background: linear-gradient(135deg, #92400e 0%, #991b1b 100%);
    box-shadow: 0 2px 8px rgba(146, 64, 14, 0.45);
}

body.weekend.theme-dark .cdn-ai-sidebar-header {
    background: linear-gradient(135deg, #92400e 0%, #991b1b 100%);
}

body.weekend.theme-dark .cdn-container,
body.weekend.theme-dark .cdn-main-content {
    background: #1e293b;
}

body.weekend.theme-dark .cdn-toolbar .toolbar-btn-primary {
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%) !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.5);
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .cdn-history-panel {
        display: none;
    }
    .cdn-preview-panel {
        width: 45%;
    }
}

@media (max-width: 650px) {
    .cdn-preview-panel {
        display: none;
    }
    .cdn-editor-panel {
        min-width: 100%;
    }
}
