:root {
    /* 明亮主题变量 */
    --bg-main: #f8fafc;
    --bg-panel: #ffffff;
    --bg-editor: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border-color: #e2e8f0;
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --header-height: 60px;
    --status-height: 32px;
}

/* 暗黑主题变量 */
[data-theme="dark"] {
    --bg-main: #1a202c;
    --bg-panel: #2d3748;
    --bg-editor: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* 离线提示 */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #f59e0b;
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    z-index: 3000;
    display: none;
}

.offline-banner.show {
    display: block;
}

/* 紧凑型头部 */
.header {
    height: var(--header-height);
    padding: 0 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 10;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.4rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    white-space: nowrap;
    display: none;
}

@media (min-width: 768px) {
    .header-subtitle {
        display: block;
    }
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.4rem 0.8rem;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.btn.active {
    background: rgba(255,255,255,0.4);
    border-color: rgba(255,255,255,0.6);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* 主容器 */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* 编辑器容器 */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-editor);
    border-right: 1px solid var(--border-color);
}

/* 预览容器 */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-panel);
}

/* 面板标题 */
.panel-header {
    padding: 0.8rem 1.2rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 编辑区 */
.editor {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
}

.editor textarea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    resize: none;
    font-family: "JetBrains Mono", "Monaco", monospace;
    font-size: 14px;
    line-height: 1.6;
    background: transparent;
    color: var(--text-primary);
}

/* 预览区 */
.preview {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    line-height: 1.7;
}

/* 预览区样式 */
.preview h1 {
    font-size: 2rem;
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.preview h2 {
    font-size: 1.6rem;
    margin: 1.3rem 0 0.8rem;
    color: var(--text-primary);
}

.preview h3 {
    font-size: 1.3rem;
    margin: 1.1rem 0 0.6rem;
    color: var(--text-secondary);
}

.preview p {
    margin: 0.8rem 0;
    color: var(--text-secondary);
}

.preview ul, .preview ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.preview li {
    margin: 0.3rem 0;
}

.preview blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    background: rgba(102, 126, 234, 0.05);
    padding: 0.8rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.preview code:not(pre code) {
    background: rgba(102, 126, 234, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9em;
    color: var(--primary-color);
}

/* 代码块容器 */
.code-block-container {
    position: relative;
    margin: 1rem 0;
}

.preview pre {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1.2rem;
    padding-top: 2.5rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0;
}

.preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* 复制按钮 - 优化版 */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a0aec0;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: rgba(72, 187, 120, 0.2);
    border-color: rgba(72, 187, 120, 0.4);
    color: #48bb78;
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* 文件信息栏 */
.file-info {
    padding: 0.5rem 1.2rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* 状态栏 */
.status-bar {
    height: var(--status-height);
    padding: 0 1.2rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* 侧边抽屉面板 */
.drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(450px, 90vw);
    height: 100vh;
    background: var(--bg-panel);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    right: 0;
}

.drawer-header {
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.drawer-header h3 {
    margin: 0;
    font-size: 1.2rem;
    white-space: nowrap;
}

.drawer-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.drawer-close:hover {
    background: rgba(255,255,255,0.2);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.drawer-footer {
    padding: 0.8rem 1rem;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* 搜索面板 */
.search-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    width: 320px;
    display: none;
}

.search-panel.show {
    display: block;
}

.search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.search-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-editor);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-btn {
    padding: 0.5rem 0.8rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.search-results {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.search-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

/* 历史记录项 */
.history-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.history-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-source {
    font-size: 0.75rem;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    color: var(--primary-color);
}

.history-preview {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.history-btn {
    padding: 0.3rem 0.6rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.history-btn:hover {
    background: var(--border-color);
}

.history-btn.restore {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.history-btn.restore:hover {
    background: var(--primary-dark);
}

.history-btn.delete {
    background: #f56565;
    color: white;
    border-color: #f56565;
}

.history-btn.delete:hover {
    background: #e53e3e;
}

.no-history {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.overlay.show {
    display: block;
}

/* 加载指示器 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--primary-color);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #48bb78;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 快捷键提示 */
.shortcuts-hint {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    z-index: 100;
    display: none;
}

.shortcuts-hint.show {
    display: block;
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .editor-container {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .header {
        flex-direction: column;
        height: auto;
        padding: 0.8rem 1rem;
        gap: 0.5rem;
    }
    
    .header-left {
        flex-direction: column;
        gap: 0.2rem;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    .drawer {
        width: 100%;
        right: -100%;
    }
    
    .search-panel {
        width: calc(100% - 20px);
        right: 10px;
    }
}

@media (max-width: 480px) {
    .header-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* 可关闭的离线提示 */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #f59e0b;
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.9rem;
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.offline-banner.show {
    display: flex;
}

.banner-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.banner-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 其余样式保持不变... */