:root {
    --bg: #f6f8fa;
    --editor-bg: #fff;
    --border: #d1d5db;
    --text: #24292f;
    --text-secondary: #57606a;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --code-bg: #f0f2f4;
    --blockquote-bg: #f6f8fa;
    --table-border: #d1d5db;
    --table-header-bg: #f6f8fa;
    --toolbar-bg: #fafbfc;
    --media-btn-bg: #f6f8fa;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.header {
    background: var(--editor-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}
.header-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header-badge { font-size: 11px; background: #e8f0fe; color: var(--accent); padding: 2px 10px; border-radius: 12px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--editor-bg);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.btn:hover { background: var(--code-bg); border-color: #b8bfc7; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-warning { background: #f0ad4e; border-color: #f0ad4e; color: #fff; }
.btn-warning:hover { background: #ec971f; border-color: #ec971f; }
.btn-icon { font-size: 16px; }
.toolbar {
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex-shrink: 0;
    overflow-x: auto;
}
.toolbar-btn {
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all .12s;
    font-weight: 500;
    font-family: Consolas, Menlo, monospace;
    display: flex;
    align-items: center;
    gap: 3px;
}
.toolbar-btn:hover { background: #e8eaed; color: var(--text); border-color: #d1d5db; }
.toolbar-sep { width: 1px; background: var(--border); margin: 2px 6px; }
.media-btn {
    background: var(--media-btn-bg);
    border: 1px dashed #c4c9cf;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.main { display: flex; flex: 1; min-height: 0; }
.editor-panel { flex: 1; display: flex; flex-direction: column; background: var(--editor-bg); }
.preview-panel { flex: 1; display: flex; flex-direction: column; background: var(--editor-bg); border-left: 1px solid var(--border); }
.panel-header {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #8b949e;
    border-bottom: 1px solid #eef0f2;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fcfcfd;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-editor { background: #f0883e; }
.dot-preview { background: #28a745; }
#editor {
    flex: 1;
    width: 100%;
    padding: 16px 20px;
    border: none;
    outline: none;
    resize: none;
    font-family: Consolas, Menlo, monospace;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    background: var(--editor-bg);
    tab-size: 4;
    overflow-y: auto;
}
#preview {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
}
#preview h1, #preview h2, #preview h3, #preview h4, #preview h5, #preview h6 { margin: 24px 0 12px; font-weight: 700; }
#preview h1 { font-size: 2em; border-bottom: 2px solid #eaecef; padding-bottom: 8px; }
#preview h2 { font-size: 1.6em; border-bottom: 1px solid #eaecef; padding-bottom: 6px; }
#preview h3 { font-size: 1.3em; }
#preview p { margin-bottom: 12px; }
#preview a { color: var(--accent); text-decoration: none; }
#preview a:hover { text-decoration: underline; }
#preview code { font-family: monospace; background: var(--code-bg); padding: 2px 6px; border-radius: 4px; }
#preview pre { background: #1e1e2e; color: #e0e0e0; padding: 16px; border-radius: 8px; overflow-x: auto; }
#preview blockquote { border-left: 4px solid #dfe2e5; padding: 8px 16px; margin: 12px 0; background: var(--blockquote-bg); }
#preview img { max-width: 100%; border-radius: 6px; margin: 10px 0; }
#preview table { border-collapse: collapse; margin: 14px 0; width: 100%; }
#preview table th, #preview table td { border: 1px solid var(--table-border); padding: 8px 14px; text-align: left; }
#preview table th { background: var(--table-header-bg); font-weight: 600; }
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #24292f;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 9999;
}
.hidden { display: none !important; }
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    width: 320px;
    text-align: center;
}
.login-box h2 { margin-bottom: 20px; font-size: 20px; }
.login-box input[type="password"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}
.login-box button {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
}
.login-box button:hover { background: #0550ae; }
.doc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.doc-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}
.doc-modal-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}
.doc-modal-close { cursor: pointer; border: none; background: none; font-size: 22px; }
.doc-modal-tabs { display: flex; border-bottom: 1px solid var(--border); }
.doc-modal-tab { flex: 1; text-align: center; padding: 10px 0; cursor: pointer; font-weight: 600; }
.doc-modal-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.doc-modal-list { overflow-y: auto; flex: 1; padding: 8px 0; }
.doc-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f4;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.doc-item:hover { background: #f6f8fa; }
.delete-btn { background: #ff4d4f; border: none; color: #fff; padding: 4px 10px; border-radius: 4px; cursor: pointer; }
@media print {
    .header, .toolbar, .editor-panel, .toast, .doc-modal, #login-overlay { display: none !important; }
    .preview-panel { display: block !important; }
}
@media (max-width: 768px) {
    .header { padding: 10px 14px; }
    .toolbar { padding: 6px 10px; }
    .toolbar-btn { padding: 5px 7px; font-size: 12px; }
    .media-btn { padding: 3px 6px; font-size: 11px; }
}