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

:root {
    --bg: #0a0a0a;
    --bg-alt: #111;
    --border: #222;
    --text: #e5e5e5;
    --text-dim: #666;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', Consolas, monospace;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 0 32px;
}

.logo {
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    letter-spacing: -0.02em;
}

.amp, .null { color: var(--text-dim); }

.header-actions { display: flex; gap: 16px; align-items: center; }

.save-status {
    font-size: 0.75rem;
    color: var(--text-dim);
    opacity: 0.7;
}

.btn-primary, .btn-secondary {
    padding: 8px 16px;
    font-size: 0.8125rem;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.15s;
}

.btn-primary { background: var(--text); color: var(--bg); }
.btn-secondary { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-primary:hover, .btn-secondary:hover { opacity: 0.8; }

.btn-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.8125rem;
}
.btn-link:hover { color: var(--text); }

/* Editor */
.editor-container { padding-bottom: 80px; }

.title-input {
    width: 100%;
    font-size: 2rem;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
    margin-bottom: 24px;
    letter-spacing: -0.03em;
}
.title-input::placeholder { color: var(--text-dim); }

.editor {
    width: 100%;
    min-height: 60vh;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.9375rem;
    line-height: 1.8;
    resize: none;
    outline: none;
}
.editor::placeholder { color: var(--text-dim); }

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.hint { font-size: 0.75rem; color: var(--text-dim); }
.char-count { font-size: 0.75rem; color: var(--text-dim); font-family: var(--mono); }

/* Post */
.post-container { padding: 0 0 80px; }

.post-title {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.post-meta {
    color: var(--text-dim);
    font-size: 0.8125rem;
    margin-bottom: 48px;
}
.post-meta .separator { margin: 0 8px; }

.post-content { font-size: 1rem; }

/* Typography */
.post-content h1 { font-size: 1.5rem; font-weight: 600; margin: 2em 0 0.5em; }
.post-content h2 { font-size: 1.25rem; font-weight: 600; margin: 1.5em 0 0.5em; }
.post-content h3 { font-size: 1rem; font-weight: 600; margin: 1.25em 0 0.5em; }
.post-content p { margin: 1em 0; }

.post-content a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-content blockquote {
    margin: 1.5em 0;
    padding-left: 16px;
    border-left: 2px solid var(--border);
    color: var(--text-dim);
}

.post-content ul, .post-content ol { margin: 1em 0; padding-left: 20px; }
.post-content li { margin: 0.25em 0; }

.post-content hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2em 0;
}

/* Code */
.post-content code {
    font-family: var(--mono);
    font-size: 0.875em;
    background: var(--bg-alt);
    padding: 2px 5px;
    border-radius: 3px;
}

.post-content pre {
    margin: 1.5em 0;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 4px;
    overflow-x: auto;
    position: relative;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-dim);
    font-size: 0.6875rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.post-content pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

.hljs-keyword { color: #c9a; }
.hljs-string { color: #9b9; }
.hljs-number { color: #ca9; }
.hljs-function, .hljs-title { color: #9bc; }
.hljs-comment { color: #555; }
.hljs-built_in { color: #bc9; }

/* KaTeX */
.katex-display {
    margin: 1.5em 0;
    padding: 16px;
    background: transparent;
    border-left: 2px solid var(--border);
    border-radius: 0;
    overflow-x: auto;
}

.katex { color: var(--text); }
.katex .mord, .katex .mbin, .katex .mrel, .katex .mopen, .katex .mclose,
.katex .mpunct, .katex .minner, .katex .mop { color: var(--text); }
.katex .katex-html { color: var(--text); }

/* Mermaid */
.mermaid {
    margin: 1.5em 0;
    padding: 16px 0;
    background: transparent;
    text-align: center;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid text { fill: var(--text) !important; }
.mermaid .node rect, .mermaid .node circle, .mermaid .node polygon {
    fill: var(--bg-alt) !important;
    stroke: var(--border) !important;
}
.mermaid .edgePath path { stroke: var(--text-dim) !important; }
.mermaid .arrowheadPath { fill: var(--text-dim) !important; }
.mermaid .cluster rect { fill: var(--bg) !important; stroke: var(--border) !important; }
.mermaid-error { color: #a66; font-size: 0.8125rem; }

/* Posts list */
.posts-container { padding-bottom: 80px; }
.posts-container h1 { font-size: 1.5rem; margin-bottom: 32px; }

.post-item {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}
.post-item:first-child { border-top: 1px solid var(--border); }

.post-item h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.post-date { font-size: 0.75rem; color: var(--text-dim); }

.empty { padding: 32px 0; color: var(--text-dim); }
.empty a { color: var(--text); }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.visible { display: flex; }

.modal-content {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
}

.modal-content h3 { font-size: 1rem; margin-bottom: 8px; }
.modal-content p { font-size: 0.875rem; color: var(--text-dim); margin-bottom: 16px; }

.link-box { display: flex; gap: 8px; margin-bottom: 20px; }

.link-box input {
    flex: 1;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.8125rem;
}

.btn-copy {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.75rem;
}

.modal-actions { display: flex; gap: 8px; }
.modal-actions > * { flex: 1; text-align: center; }

/* 404 */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}
.error-container h1 { font-size: 4rem; color: var(--text-dim); }
.error-container p { color: var(--text-dim); margin: 8px 0 24px; }

/* Footer */
footer { padding: 24px 0; border-top: 1px solid var(--border); }
footer p { font-size: 0.75rem; color: var(--text-dim); text-align: center; }
footer a { color: var(--text-dim); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

::selection { background: #333; }

@media (max-width: 600px) {
    .title-input, .post-title { font-size: 1.5rem; }
}
