* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f7fb;
    height: 100vh;
    overflow: hidden;
    color: #1e293b;
}

/* 整体容器 */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.02);
}

/* 工具栏 */
.toolbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(2px);
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    position: relative;
}

/* 返回首页按钮 */
.back-home-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    margin-right: 8px;
}

.back-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.back-home-btn i {
    font-size: 0.9rem;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 12px;
    margin-right: 4px;
}

/* 操作按钮组（右侧） */
.toolbar-actions {
    margin-left: auto;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
}

.toolbar-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: #334155;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn i {
    font-size: 1rem;
}

.toolbar-btn:hover {
    background: #eef2ff;
    color: #3b82f6;
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(1px);
}

/* 示例模版按钮特殊样式 */
.toolbar-btn[data-action="sample"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    padding: 0 14px !important;
    width: auto !important;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

.toolbar-btn[data-action="sample"] i {
    margin-right: 6px;
    font-size: 0.95rem;
}

.toolbar-btn[data-action="sample"] span {
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.toolbar-btn[data-action="sample"]:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: #ffffff;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.toolbar-btn[data-action="sample"]:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 2px 16px rgba(102, 126, 234, 0.6);
    }
}

/* 下载按钮特殊样式 */
.toolbar-btn-save {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    padding: 0 16px !important;
    width: auto !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

.toolbar-btn-save i {
    margin-right: 6px;
    font-size: 0.95rem;
}

.toolbar-btn-save span {
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}

.toolbar-btn-save:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
}

.toolbar-btn-save:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 6px;
}

.sync-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 0 8px;
    border-radius: 20px;
    height: 32px;
    color: #475569;
}

.sync-check input {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* 主编辑区容器 (flex + 可拖拽分隔条) */
.editor-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

/* 左侧编辑区 */
.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fefefe;
    border-right: 1px solid #eef2f6;
    min-width: 200px;
    transition: box-shadow 0.1s;
}

.pane-header {
    padding: 12px 16px;
    background: #fafcff;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    letter-spacing: 0.3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-header span i {
    margin-right: 6px;
    color: #3b82f6;
}

.count-badge {
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: 30px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #2563eb;
}

textarea {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 20px 22px;
    background: #ffffff;
    color: #0f172a;
    tab-size: 2;
}

textarea:focus {
    background-color: #ffffff;
}

/* 右侧预览区 */
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow-y: auto;
    min-width: 200px;
}

.preview-content {
    padding: 24px 28px;
    flex: 1;
    overflow-y: auto;
    background: #fefefe;
}

/* 拖拽分隔条 */
.resizer {
    width: 5px;
    background: #e2e8f0;
    cursor: col-resize;
    transition: background 0.2s;
    position: relative;
    z-index: 5;
}

.resizer:hover, .resizer.active {
    background: #3b82f6;
}

/* 底部状态栏 */
.status-bar {
    background: #f8fafc;
    border-top: 1px solid #e9eef3;
    padding: 6px 20px;
    font-size: 0.7rem;
    color: #5b6e8c;
    display: flex;
    justify-content: space-between;
    font-weight: 450;
}

/* Markdown 预览样式 */
.markdown-body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: #1e293b;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    border-bottom: 1px solid #e9edf2;
    padding-bottom: 0.3em;
}

.markdown-body h1 { font-size: 1.9rem; }
.markdown-body h2 { font-size: 1.5rem; }
.markdown-body code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    font-family: 'SF Mono', monospace;
    font-size: 0.85em;
}
.markdown-body pre {
    background: #1e293b;
    padding: 1rem;
    border-radius: 12px;
    overflow-x: auto;
}
.markdown-body pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
}
.markdown-body blockquote {
    border-left: 4px solid #3b82f6;
    color: #475569;
    margin: 1em 0;
    padding-left: 1em;
    background: #f8fafc;
}
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
}
.markdown-body th, .markdown-body td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
}
.markdown-body img {
    max-width: 100%;
    border-radius: 10px;
}
.markdown-body a {
    color: #2563eb;
    text-decoration: none;
}
.markdown-body a:hover {
    text-decoration: underline;
}

/* 目录样式 */
.toc-container {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.toc-container h2 {
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 16px;
    color: #1e293b;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 8px;
}

.toc-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.toc-list ul {
    list-style: none;
    padding-left: 20px;
    margin: 4px 0;
}

.toc-list li {
    margin: 6px 0;
    line-height: 1.5;
}

.toc-list li a {
    color: #475569;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.95rem;
}

.toc-list li a:hover {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.08);
    transform: translateX(4px);
}

.toc-list li > a {
    font-weight: 500;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* 响应式: 小屏上下布局 */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    .resizer {
        display: none;
    }
    .editor-pane, .preview-pane {
        min-height: 40vh;
        border-right: none;
    }
    .toolbar {
        overflow-x: auto;
        justify-content: flex-start;
    }
}

/* 模态对话框样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #1e293b;
    font-weight: 600;
}

.modal-header h3 i {
    margin-right: 8px;
    color: #3b82f6;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    color: #64748b;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #eef2ff;
    color: #3b82f6;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 80px);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.template-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.template-card:hover {
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.12);
}

.template-card:hover::before {
    transform: scaleX(1);
}

.template-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.template-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.template-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 12px;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.template-tag {
    background: #f1f5f9;
    color: #475569;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* 模板卡片颜色主题 */
.template-card[data-type="doc"]::before {
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
}

.template-card[data-type="meeting"]::before {
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
}

.template-card[data-type="project"]::before {
    background: linear-gradient(90deg, #10b981, #3b82f6);
}

.template-card[data-type="note"]::before {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.template-card[data-type="blog"]::before {
    background: linear-gradient(90deg, #ec4899, #8b5cf6);
}

.template-card[data-type="api"]::before {
    background: linear-gradient(90deg, #06b6d4, #10b981);
}

.template-card[data-type="tutorial"]::before {
    background: linear-gradient(90deg, #f97316, #f59e0b);
}

.template-card[data-type="changelog"]::before {
    background: linear-gradient(90deg, #6366f1, #a855f7);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .toolbar {
        padding: 6px 12px;
    }
    /* 移动端返回首页按钮调整 */
    .back-home-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
        margin-right: 4px;
    }
    .back-home-btn span {
        display: none;
    }
    .toolbar-group {
        padding: 3px 6px;
    }
}
