* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-dark: #1d4ed8;
    --border-color: #2a2a2a;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 头部 */
header {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 50px;
}

h1 {
    font-size: 1rem;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.header-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.editable-title {
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all var(--transition);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    -webkit-text-fill-color: var(--text-primary);
}

.editable-title:hover {
    background: rgba(59, 130, 246, 0.1);
}

.editable-title:focus {
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.save-status {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0.8;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.4rem;
    background: rgba(36, 36, 36, 0.5);
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.1);
}

.toolbar-group button {
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    min-width: unset;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 主布局 */
.main-layout {
    display: flex;
    height: calc(100vh - 50px);
    overflow: hidden;
}

/* 左侧历史记录 */
.sidebar-left {
    width: 260px;
    min-width: 200px;
    max-width: 400px;
    background: rgba(26, 26, 26, 0.7);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(36, 36, 36, 0.4);
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.3rem;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.7rem;
    margin: 0.2rem 0.4rem;
    background: rgba(36, 36, 36, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border-left: 2px solid transparent;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-delete-btn {
    opacity: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
    border-radius: 3px;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: var(--accent-color);
}

.history-item.active {
    background: rgba(59, 130, 246, 0.12);
    border-left-color: var(--accent-color);
}

.history-item-title {
    font-weight: 500;
    margin-bottom: 0.1rem;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* 历史记录预览提示 */
.history-tooltip {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 0.5rem;
    padding: 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    white-space: pre-wrap;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    max-width: 300px;
    z-index: 1000;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(-10px);
    transition: all var(--transition);
    pointer-events: none;
}

.history-tooltip.show {
    opacity: 1;
    transform: translateX(0);
}

/* 编辑区 */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(20px);
    position: relative;
}

.editor-content {
    flex: 1;
    padding: 0.8rem;
    overflow-y: auto;
}

/* 预览区 */
.preview-area {
    width: 35%;
    min-width: 300px;
    max-width: 700px;
    background: rgba(26, 26, 26, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.preview-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(36, 36, 36, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-content {
    flex: 1;
    padding: 0.6rem;
    overflow-y: auto;
}

/* 分隔条 */
.resizer {
    width: 2px;
    background: linear-gradient(180deg, transparent, var(--border-color), transparent);
    cursor: col-resize;
    transition: all var(--transition);
    position: relative;
    user-select: none;
}

.resizer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -3px;
    transform: translateY(-50%);
    width: 8px;
    height: 50px;
    background: transparent;
    border-radius: 4px;
}

.resizer:hover, .resizer.resizing {
    background: linear-gradient(180deg, transparent, var(--accent-color), transparent);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.7);
}

.resizer:hover::before, .resizer.resizing::before {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 3px;
}

/* 按钮 */
button {
    padding: 0.5rem 1rem;
    background: rgba(36, 36, 36, 0.6);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

button:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

button:active {
    background: rgba(59, 130, 246, 0.2);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-success {
    background: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background: #dc2626;
}

/* 输入框 */
textarea, input[type="text"] {
    width: 100%;
    background: rgba(36, 36, 36, 0.6);
    color: var(--text-primary);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.65rem;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.9rem;
    transition: all var(--transition);
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    background: rgba(36, 36, 36, 0.85);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18), 0 4px 16px rgba(59, 130, 246, 0.25);
}

#textInput {
    height: 100%;
    resize: none;
    border: none;
    font-size: 0.95rem;
    line-height: 1.6;
    background: transparent;
}

#textInput:focus {
    outline: none;
    border: none;
    box-shadow: none;
    background: transparent;
}

/* 树节点 */
#treeView {
    height: 100%;
    padding: 0.2rem;
}

.tree-node {
    margin: 0.02rem 0;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.tree-node.selected {
    background: rgba(59, 130, 246, 0.12);
}

.tree-node.search-highlight {
    background: rgba(245, 158, 11, 0.1);
}

/* 节点快捷添加按钮 */
.node-add-btn {
    display: none;
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-primary);
    position: relative;
}

.tree-toggle {
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    font-size: 0.5rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.tree-children {
    margin-left: 1rem;
    padding-left: 0;
    position: relative;
}

.tree-children.collapsed {
    display: none;
}

/* 竖线 - 在父节点图标正下方 */
.tree-children::before {
    content: '';
    position: absolute;
    left: calc(0.725rem - 1rem);
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* 横线 - 从竖线连接到子节点图标中心 */
.tree-children > .tree-node::before {
    content: '';
    position: absolute;
    left: calc(0.725rem - 1rem);
    top: calc(0.15rem + 0.375rem);
    width: 1rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* 最后一个子节点 - 遮挡竖线下半部分 */
.tree-children > .tree-node.last-child > .tree-node-content::after,
.tree-children > .tree-node:last-child > .tree-node-content::after {
    content: '';
    position: absolute;
    left: calc(-1rem + 0.725rem - 0.35rem - 1px);
    top: 50%;
    bottom: -0.15rem;
    width: 3px;
    background: var(--bg-primary);
}

/* 右键菜单 */
.context-menu {
    position: fixed;
    background: rgba(26, 26, 26, 0.97);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 0.4rem;
    min-width: 160px;
    z-index: 1000;
    display: none;
}

.context-menu-item {
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    transition: background 0.12s;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* 返回顶部 */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: background 0.15s, opacity 0.15s;
    font-size: 1.2rem;
    z-index: 999;
}

.back-to-top:hover {
    background: var(--accent-hover);
}

/* 模态框 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

/* 新手指南 */
.guide-modal {
    max-width: 480px;
}

.guide-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.guide-section {
    background: rgba(36, 36, 36, 0.5);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.guide-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
    color: var(--accent-color);
}

.guide-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.guide-section ul li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding-left: 1rem;
    position: relative;
}

.guide-section ul li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent-color);
}

.guide-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.guide-features span {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    color: var(--text-primary);
}

.guide-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem 1rem;
}

.guide-shortcuts div {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-shortcuts kbd {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    color: var(--accent-color);
}

/* 快捷键 */
.shortcut-list {
    display: grid;
    gap: 0.6rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.1rem;
    background: rgba(36, 36, 36, 0.6);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.shortcut-item:hover {
    border-left-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.12);
    transform: translateX(5px);
}

.shortcut-key {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(59, 130, 246, 0.15));
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    color: var(--accent-color);
    letter-spacing: 0.5px;
}

/* Toast提示增强 */
.toast {
    position: fixed;
    top: 4.5rem;
    right: 1.5rem;
    background: rgba(26, 26, 26, 0.97);
    backdrop-filter: blur(25px) saturate(180%);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.7rem;
    z-index: 3000;
    border-left: 4px solid;
    opacity: 0;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 200px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success { 
    border-left-color: var(--success-color);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.toast.warning { 
    border-left-color: var(--warning-color);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.toast.error { 
    border-left-color: var(--danger-color);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

/* 批量模式 */
.batch-mode-indicator {
    position: fixed;
    top: 4rem;
    left: 1.5rem;
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius);
    display: none;
    align-items: center;
    gap: 0.6rem;
    z-index: 3000;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    backdrop-filter: blur(20px);
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tree-node.batch-selected {
    background: rgba(245, 158, 11, 0.2);
    border-left-color: var(--warning-color);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* 确认对话框 */
.confirm-dialog {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.3s ease-out;
}

.confirm-dialog h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.confirm-dialog p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1rem;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 0.7rem;
    justify-content: flex-end;
}

/* AI面板 */
.ai-panel {
    position: fixed;
    right: -370px;
    top: 0;
    width: 370px;
    height: 100vh;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-panel.open {
    right: 0;
}

.ai-panel-header {
    padding: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(36, 36, 36, 0.5);
    position: relative;
}

.ai-panel-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    opacity: 0.3;
}

.ai-panel-header h3 {
    background: linear-gradient(135deg, var(--accent-color), var(--success-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-panel-content {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
}

.ai-input-area {
    padding: 1.2rem;
    border-top: 1px solid var(--border-color);
    background: rgba(36, 36, 36, 0.5);
}

.ai-input-area textarea {
    min-height: 90px;
    margin-bottom: 0.7rem;
}

/* 主题选择器 */
.theme-picker {
    position: relative;
}

.theme-trigger {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: rgba(36, 36, 36, 0.6);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-trigger:hover {
    background: rgba(60, 60, 60, 0.8);
    transform: none;
    box-shadow: none;
}

.theme-panel {
    position: fixed;
    top: 56px;
    right: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.8rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
    z-index: 2000;
}

.theme-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.theme-opt {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    border: none;
    background: rgba(128, 128, 128, 0.12);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-primary);
    opacity: 0.8;
    transition: all 0.15s;
    white-space: nowrap;
}

.theme-opt span {
    font-size: 0.9rem;
}

.theme-opt:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.25);
    transform: none;
    box-shadow: none;
}

.theme-opt.active {
    opacity: 1;
    background: var(--accent-color);
    color: white;
}

/* 明亮主题 */
body.light-theme {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* 深蓝主题 */
body.blue-theme {
    --bg-primary: #0a1628;
    --bg-secondary: #0f1e36;
    --bg-tertiary: #162a4a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-color: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-dark: #2563eb;
    --border-color: #1e3a5f;
    --success-color: #34d399;
    background: linear-gradient(135deg, #0a1628 0%, #0f1e36 100%);
}

body.blue-theme::before {
    background: 
        radial-gradient(circle at 20% 30%, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(52, 211, 153, 0.05) 0%, transparent 50%);
}

/* 森绿主题 */
body.green-theme {
    --bg-primary: #0a1510;
    --bg-secondary: #0f1f18;
    --bg-tertiary: #162920;
    --text-primary: #e2f0e8;
    --text-secondary: #94b8a3;
    --accent-color: #34d399;
    --accent-hover: #10b981;
    --accent-dark: #059669;
    --border-color: #1e4a3a;
    --success-color: #34d399;
    background: linear-gradient(135deg, #0a1510 0%, #0f1f18 100%);
}

body.green-theme::before {
    background: 
        radial-gradient(circle at 20% 30%, rgba(52, 211, 153, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

/* 葡萄紫主题 */
body.purple-theme {
    --bg-primary: #1a0f28;
    --bg-secondary: #241536;
    --bg-tertiary: #2e1a4a;
    --text-primary: #f0e8f5;
    --text-secondary: #b8a3c8;
    --accent-color: #a855f7;
    --accent-hover: #9333ea;
    --accent-dark: #7e22ce;
    --border-color: #4a1e6f;
    --success-color: #a855f7;
    background: linear-gradient(135deg, #1a0f28 0%, #241536 100%);
}

body.purple-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(168, 85, 247, 0.08) 0%, transparent 50%);
}

/* 晚霞橙主题 */
body.orange-theme {
    --bg-primary: #1c1210;
    --bg-secondary: #2a1a15;
    --bg-tertiary: #3a251c;
    --text-primary: #f5ebe8;
    --text-secondary: #c8a898;
    --accent-color: #f97316;
    --accent-hover: #ea580c;
    --accent-dark: #c2410c;
    --border-color: #5a3020;
    --success-color: #f97316;
    background: linear-gradient(135deg, #1c1210 0%, #2a1a15 100%);
}

body.orange-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(249, 115, 22, 0.08) 0%, transparent 50%);
}

/* 玫瑰粉主题 */
body.rose-theme {
    --bg-primary: #1c1015;
    --bg-secondary: #2a151e;
    --bg-tertiary: #3a1c28;
    --text-primary: #f5e8ed;
    --text-secondary: #c8a0b0;
    --accent-color: #f43f5e;
    --accent-hover: #e11d48;
    --accent-dark: #be123c;
    --border-color: #5a2035;
    --success-color: #f43f5e;
    background: linear-gradient(135deg, #1c1015 0%, #2a151e 100%);
}

body.rose-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(244, 63, 94, 0.08) 0%, transparent 50%);
}

/* 青绿主题 */
body.cyan-theme {
    --bg-primary: #0c1820;
    --bg-secondary: #10222e;
    --bg-tertiary: #162e3e;
    --text-primary: #e8f4f5;
    --text-secondary: #8cc8d0;
    --accent-color: #06b6d4;
    --accent-hover: #0891b2;
    --accent-dark: #0e7490;
    --border-color: #155e75;
    --success-color: #06b6d4;
    background: linear-gradient(135deg, #0c1820 0%, #10222e 100%);
}

body.cyan-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
}

/* 石板灰主题 */
body.slate-theme {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-color: #64748b;
    --accent-hover: #475569;
    --accent-dark: #334155;
    --border-color: #475569;
    --success-color: #64748b;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

body.slate-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(100, 116, 139, 0.08) 0%, transparent 50%);
}

/* 琥珀金主题 */
body.amber-theme {
    --bg-primary: #1c1808;
    --bg-secondary: #2a2410;
    --bg-tertiary: #3a3218;
    --text-primary: #fef3c7;
    --text-secondary: #d4a854;
    --accent-color: #f59e0b;
    --accent-hover: #d97706;
    --accent-dark: #b45309;
    --border-color: #78350f;
    --success-color: #f59e0b;
    background: linear-gradient(135deg, #1c1808 0%, #2a2410 100%);
}

body.amber-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
}

/* 靖蓝主题 */
body.indigo-theme {
    --bg-primary: #0f0f28;
    --bg-secondary: #181840;
    --bg-tertiary: #222255;
    --text-primary: #e8e8f5;
    --text-secondary: #a0a0d0;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-dark: #4338ca;
    --border-color: #3730a3;
    --success-color: #6366f1;
    background: linear-gradient(135deg, #0f0f28 0%, #181840 100%);
}

body.indigo-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
}

/* 湖水绿主题 */
body.teal-theme {
    --bg-primary: #0a1515;
    --bg-secondary: #102020;
    --bg-tertiary: #182a2a;
    --text-primary: #e8f5f5;
    --text-secondary: #80c0c0;
    --accent-color: #14b8a6;
    --accent-hover: #0d9488;
    --accent-dark: #0f766e;
    --border-color: #115e59;
    --success-color: #14b8a6;
    background: linear-gradient(135deg, #0a1515 0%, #102020 100%);
}

body.teal-theme::before {
    background: radial-gradient(circle at 20% 30%, rgba(20, 184, 166, 0.08) 0%, transparent 50%);
}

body.light-theme::before {
    background: 
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

/* 天空蓝主题 - 浅色 */
body.sky-theme {
    --bg-primary: #f0f7ff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8f2ff;
    --text-primary: #1e3a5f;
    --text-secondary: #5a7a9a;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-dark: #1d4ed8;
    --border-color: #c7ddf5;
    --success-color: #10b981;
    background: linear-gradient(135deg, #f0f7ff 0%, #e0efff 100%);
}

/* 薄荷绿主题 - 浅色 */
body.mint-theme {
    --bg-primary: #f0fdf4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8faf0;
    --text-primary: #14532d;
    --text-secondary: #4d7c5a;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --accent-dark: #047857;
    --border-color: #a7f3d0;
    --success-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

/* 淡紫主题 - 浅色 */
body.lavender-theme {
    --bg-primary: #faf5ff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3e8ff;
    --text-primary: #3b0764;
    --text-secondary: #7c3aad;
    --accent-color: #a855f7;
    --accent-hover: #9333ea;
    --accent-dark: #7e22ce;
    --border-color: #e9d5ff;
    --success-color: #a855f7;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

/* 桃粉主题 - 浅色 */
body.peach-theme {
    --bg-primary: #fff5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ffe8e8;
    --text-primary: #7f1d1d;
    --text-secondary: #b45454;
    --accent-color: #f43f5e;
    --accent-hover: #e11d48;
    --accent-dark: #be123c;
    --border-color: #fecdd3;
    --success-color: #f43f5e;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe4e6 100%);
}

/* 沙滩主题 - 浅色 */
body.sand-theme {
    --bg-primary: #fefce8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fef9c3;
    --text-primary: #713f12;
    --text-secondary: #a16207;
    --accent-color: #eab308;
    --accent-hover: #ca8a04;
    --accent-dark: #a16207;
    --border-color: #fde68a;
    --success-color: #eab308;
    background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%);
}

/* 浅色主题通用样式 */
body.light-theme,
body.sky-theme,
body.mint-theme,
body.lavender-theme,
body.peach-theme,
body.sand-theme {
    color-scheme: light;
}

/* 浅色主题 - 头部 */
body.light-theme header,
body.sky-theme header,
body.mint-theme header,
body.lavender-theme header,
body.peach-theme header,
body.sand-theme header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

body.light-theme .toolbar-group,
body.sky-theme .toolbar-group,
body.mint-theme .toolbar-group,
body.lavender-theme .toolbar-group,
body.peach-theme .toolbar-group,
body.sand-theme .toolbar-group {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* 浅色主题 - 侧边栏 */
body.light-theme .sidebar-left,
body.sky-theme .sidebar-left,
body.mint-theme .sidebar-left,
body.lavender-theme .sidebar-left,
body.peach-theme .sidebar-left,
body.sand-theme .sidebar-left {
    background: var(--bg-secondary);
}

body.light-theme .sidebar-header,
body.sky-theme .sidebar-header,
body.mint-theme .sidebar-header,
body.lavender-theme .sidebar-header,
body.peach-theme .sidebar-header,
body.sand-theme .sidebar-header {
    background: var(--bg-tertiary);
}

body.light-theme .history-item,
body.sky-theme .history-item,
body.mint-theme .history-item,
body.lavender-theme .history-item,
body.peach-theme .history-item,
body.sand-theme .history-item {
    background: var(--bg-tertiary);
}

body.light-theme .history-item:hover,
body.sky-theme .history-item:hover,
body.mint-theme .history-item:hover,
body.lavender-theme .history-item:hover,
body.peach-theme .history-item:hover,
body.sand-theme .history-item:hover {
    background: var(--bg-primary);
}

body.light-theme .history-item.active,
body.sky-theme .history-item.active,
body.mint-theme .history-item.active,
body.lavender-theme .history-item.active,
body.peach-theme .history-item.active,
body.sand-theme .history-item.active {
    background: rgba(var(--accent-color), 0.15);
}

/* 浅色主题 - 编辑区 */
body.light-theme .editor-area,
body.sky-theme .editor-area,
body.mint-theme .editor-area,
body.lavender-theme .editor-area,
body.peach-theme .editor-area,
body.sand-theme .editor-area {
    background: var(--bg-secondary);
}

body.light-theme textarea,
body.sky-theme textarea,
body.mint-theme textarea,
body.lavender-theme textarea,
body.peach-theme textarea,
body.sand-theme textarea {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* 浅色主题 - 预览区 */
body.light-theme .preview-area,
body.sky-theme .preview-area,
body.mint-theme .preview-area,
body.lavender-theme .preview-area,
body.peach-theme .preview-area,
body.sand-theme .preview-area {
    background: var(--bg-secondary);
}

body.light-theme .preview-header,
body.sky-theme .preview-header,
body.mint-theme .preview-header,
body.lavender-theme .preview-header,
body.peach-theme .preview-header,
body.sand-theme .preview-header {
    background: var(--bg-tertiary);
}

/* 浅色主题 - 按钮 */
body.light-theme button,
body.sky-theme button,
body.mint-theme button,
body.lavender-theme button,
body.peach-theme button,
body.sand-theme button {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.light-theme button:hover,
body.sky-theme button:hover,
body.mint-theme button:hover,
body.lavender-theme button:hover,
body.peach-theme button:hover,
body.sand-theme button:hover {
    background: var(--bg-primary);
}

/* 浅色主题 - 弹窗 */
body.light-theme .modal-content,
body.sky-theme .modal-content,
body.mint-theme .modal-content,
body.lavender-theme .modal-content,
body.peach-theme .modal-content,
body.sand-theme .modal-content {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

body.light-theme .guide-section,
body.sky-theme .guide-section,
body.mint-theme .guide-section,
body.lavender-theme .guide-section,
body.peach-theme .guide-section,
body.sand-theme .guide-section {
    background: var(--bg-tertiary);
}

body.light-theme .toast,
body.sky-theme .toast,
body.mint-theme .toast,
body.lavender-theme .toast,
body.peach-theme .toast,
body.sand-theme .toast {
    background: var(--bg-secondary);
}

body.light-theme .context-menu,
body.sky-theme .context-menu,
body.mint-theme .context-menu,
body.lavender-theme .context-menu,
body.peach-theme .context-menu,
body.sand-theme .context-menu {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

body.light-theme .theme-panel,
body.sky-theme .theme-panel,
body.mint-theme .theme-panel,
body.lavender-theme .theme-panel,
body.peach-theme .theme-panel,
body.sand-theme .theme-panel {
    background: var(--bg-secondary);
}

body.light-theme .theme-trigger,
body.sky-theme .theme-trigger,
body.mint-theme .theme-trigger,
body.lavender-theme .theme-trigger,
body.peach-theme .theme-trigger,
body.sand-theme .theme-trigger {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

body.light-theme .ai-panel-header {
    background: rgba(248, 250, 252, 0.8);
}

body.light-theme .ai-input-area {
    background: rgba(248, 250, 252, 0.8);
}

/* 明亮主题 - 主题选择器 */
body.light-theme .theme-trigger {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .theme-trigger:hover {
    background: rgba(226, 232, 240, 0.95);
}

body.light-theme .theme-panel {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body.light-theme .theme-opt:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* 明亮主题 - 批量模式 */
body.light-theme .tree-node.batch-selected {
    background: rgba(245, 158, 11, 0.12);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* 明亮主题 - 滚动条 */
body.light-theme ::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.8);
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.4), rgba(59, 130, 246, 0.6));
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.6), rgba(59, 130, 246, 0.8));
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* 浅色主题 - 树形连接线 */
body.light-theme .tree-children::before,
body.light-theme .tree-children > .tree-node::before,
body.sky-theme .tree-children::before,
body.sky-theme .tree-children > .tree-node::before,
body.mint-theme .tree-children::before,
body.mint-theme .tree-children > .tree-node::before,
body.lavender-theme .tree-children::before,
body.lavender-theme .tree-children > .tree-node::before,
body.peach-theme .tree-children::before,
body.peach-theme .tree-children > .tree-node::before,
body.sand-theme .tree-children::before,
body.sand-theme .tree-children > .tree-node::before {
    background: rgba(0, 0, 0, 0.12);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.5);
}

/* 编辑区滚动条 */
#textInput::-webkit-scrollbar {
    width: 5px;
}

#textInput::-webkit-scrollbar-track {
    background: rgba(36, 36, 36, 0.3);
    border-radius: 3px;
    margin: 4px 0;
}

#textInput::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.25);
    border-radius: 3px;
}

#textInput::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.45);
}

/* 选中文本样式 */
::selection {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

/* 响应式设计优化 */
@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar-left, .preview-area {
        width: 100% !important;
        min-width: unset;
        max-width: unset;
        height: 300px;
        border: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .resizer {
        display: none;
    }
    
    .editor-area {
        min-height: 400px;
    }
    
    .editor-toolbar {
        gap: 0.3rem;
    }
    
    button {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.6rem 1rem;
        flex-wrap: wrap;
    }
    
    h1 {
        font-size: 1.1rem;
    }
    
    .header-actions {
        width: 100%;
        margin-top: 0.5rem;
        justify-content: space-between;
    }
    
    button {
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
    }
    
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}
