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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1d2129;
    background: #f7f8fa;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: #1677ff; cursor: pointer; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e5e6eb;
}
.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo {
    font-size: 18px;
    font-weight: 700;
    color: #1d2129;
    letter-spacing: -0.3px;
    cursor: pointer;
}
.nav-logo:hover { text-decoration: none; color: #1d2129; }
.nav-right { display: flex; align-items: center; gap: 12px; }

.user-menu {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.user-menu:hover { background: #f2f3f5; }
.user-name { font-size: 14px; color: #4e5969; }

/* Avatar */
.avatar, .avatar-sm, .avatar-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    font-size: 14px;
}
.avatar { width: 36px; height: 36px; font-size: 15px; }
.avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }

/* Buttons */
.btn-text {
    background: none;
    border: none;
    color: #4e5969;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
}
.btn-text:hover { color: #1d2129; }

.btn-primary-sm {
    background: #1d2129;
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-primary-sm:hover { background: #333; }

.btn-write {
    background: #1677ff;
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
}
.btn-write:hover { background: #4096ff; }

.btn-primary {
    background: #1d2129;
    color: #fff;
    border: none;
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}
.btn-primary:hover { background: #333; }
.btn-primary:disabled { background: #c9cdd4; cursor: not-allowed; }

.btn-outline {
    background: #fff;
    color: #4e5969;
    border: 1px solid #e5e6eb;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.btn-outline:hover { border-color: #c9cdd4; color: #1d2129; }
.btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background: none;
    color: #f53f3f;
    border: 1px solid #fdcdc5;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.btn-danger:hover { background: #fff7f5; border-color: #f53f3f; }

.btn-back {
    background: none;
    border: none;
    color: #86909c;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 20px;
}
.btn-back:hover { color: #1d2129; }

.btn-full { width: 100%; }

/* Toast */
.toast {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 200;
    animation: toast-in 0.2s ease;
}
.toast.success { background: #e8ffea; color: #00b42a; border: 1px solid #aff0b5; }
.toast.error { background: #ffece8; color: #f53f3f; border: 1px solid #fdcdc5; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Layout */
.main {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.main-article { max-width: 760px; }
.main-editor { max-width: 1060px; }
.main-auth { max-width: 400px; }

.page-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}
.page-title h1 { font-size: 20px; font-weight: 600; }
.post-count { font-size: 13px; color: #86909c; }

.empty {
    text-align: center;
    color: #86909c;
    padding: 60px 0;
    font-size: 15px;
}

.meta-sep {
    margin: 0 6px;
    color: #c9cdd4;
}

/* Thread List */
.thread-list {
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    overflow: hidden;
}
.thread-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    border-bottom: 1px solid #f2f3f5;
    transition: background 0.1s;
}
.thread-item:last-child { border-bottom: none; }
.thread-item:hover { background: #f7f8fa; }
.thread-item .avatar { margin-top: 2px; }

.thread-body { flex: 1; min-width: 0; }
.thread-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.thread-meta {
    font-size: 13px;
    color: #86909c;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.meta-author { color: #4e5969; font-weight: 500; }
.meta-views { color: #86909c; }

.load-more {
    text-align: center;
    margin-top: 16px;
}

/* Post Detail */
.post-detail {}
.post-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 12px;
    letter-spacing: -0.2px;
}
.post-meta {
    font-size: 14px;
    color: #86909c;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}
.post-meta .avatar-sm { margin-right: 6px; }
.post-content {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    word-break: break-word;
}
.post-actions {
    margin-top: 36px;
    padding-top: 16px;
    border-top: 1px solid #f2f3f5;
    display: flex;
    gap: 10px;
}

/* Markdown Content */
.md-content h1 { font-size: 24px; font-weight: 700; margin: 28px 0 12px; }
.md-content h2 { font-size: 20px; font-weight: 600; margin: 24px 0 10px; }
.md-content h3 { font-size: 17px; font-weight: 600; margin: 20px 0 8px; }
.md-content h4 { font-size: 15px; font-weight: 600; margin: 16px 0 6px; }
.md-content p { margin-bottom: 14px; }
.md-content ul, .md-content ol { padding-left: 24px; margin-bottom: 14px; }
.md-content li { margin-bottom: 4px; }
.md-content blockquote {
    border-left: 3px solid #e5e6eb;
    padding: 8px 16px;
    margin: 14px 0;
    color: #4e5969;
    background: #f7f8fa;
    border-radius: 0 4px 4px 0;
}
.md-content pre {
    background: #f6f8fa;
    border-radius: 6px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 14px 0;
    border: 1px solid #e5e6eb;
}
.md-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
}
.md-content p code, .md-content li code {
    background: #f2f3f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}
.md-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 14px 0;
}
.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
}
.md-content th, .md-content td {
    border: 1px solid #e5e6eb;
    padding: 8px 12px;
    text-align: left;
}
.md-content th { background: #f7f8fa; font-weight: 600; }
.md-content hr { border: none; border-top: 1px solid #e5e6eb; margin: 24px 0; }
.md-content a { color: #1677ff; }
.md-content a:hover { text-decoration: underline; }

/* Editor */
.editor-heading {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}
.editor-title {
    width: 100%;
    font-size: 20px;
    font-weight: 600;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    padding: 10px 14px;
    outline: none;
    background: #fff;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}
.editor-title:focus { border-color: #1677ff; }
.editor-title::placeholder { color: #c9cdd4; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e5e6eb;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    flex-wrap: wrap;
}
.toolbar button, .toolbar-upload {
    background: none;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #4e5969;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}
.toolbar button:hover, .toolbar-upload:hover {
    background: #f2f3f5;
    border-color: #e5e6eb;
}
.upload-tip { font-size: 12px; color: #86909c; margin-left: 4px; }
.toolbar-right { margin-left: auto; }

.editor-tabs {
    display: none;
    border: 1px solid #e5e6eb;
    border-radius: 4px;
    overflow: hidden;
}
.editor-tabs button {
    border: none;
    background: none;
    padding: 3px 12px;
    font-size: 12px;
    cursor: pointer;
    color: #86909c;
}
.editor-tabs button.active {
    background: #1d2129;
    color: #fff;
}

.editor-split {
    display: flex;
    border: 1px solid #e5e6eb;
    border-radius: 0 0 6px 6px;
    background: #fff;
    min-height: 420px;
    overflow: hidden;
}
.pane-write, .pane-preview {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    max-height: 520px;
}
.pane-write textarea {
    width: 100%;
    height: 100%;
    min-height: 420px;
    border: none;
    outline: none;
    resize: none;
    padding: 14px 16px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #1d2129;
    background: transparent;
}
.pane-write textarea::placeholder { color: #c9cdd4; }
.pane-divider {
    width: 1px;
    background: #e5e6eb;
    flex-shrink: 0;
}
.pane-preview {
    padding: 14px 16px;
    background: #fafbfc;
}
.md-preview { font-size: 15px; line-height: 1.75; }
.preview-empty { color: #c9cdd4; font-size: 14px; padding: 20px 0; }

.editor-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
}
.char-hint { font-size: 13px; color: #86909c; }
.char-hint.warn { color: #f53f3f; }
.editor-footer .btn-primary { margin-left: auto; }

/* Auth */
.auth-card {
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 10px;
    padding: 28px 24px;
}
.auth-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.auth-card input:focus { border-color: #1677ff; }
.row-2 { display: flex; gap: 10px; }
.row-2 input { flex: 1; }
.auth-switch {
    text-align: center;
    margin-top: 14px;
    font-size: 14px;
    color: #86909c;
}

/* Profile */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.profile-header h2 { margin-bottom: 0; }
.profile-info { margin-bottom: 4px; }
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid #f2f3f5;
    font-size: 14px;
}
.info-row span:first-child { color: #86909c; }
.info-row span:last-child { font-weight: 500; }
.section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 18px 0 10px;
    padding-top: 14px;
    border-top: 1px solid #f2f3f5;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-inner { padding: 0 14px; }
    .main { padding: 18px 14px 48px; }
    .post-title { font-size: 22px; }
    .editor-title { font-size: 17px; }

    .editor-tabs { display: flex; }
    .editor-split { flex-direction: column; min-height: 0; }
    .pane-write, .pane-preview { max-height: none; }
    .pane-write textarea { min-height: 300px; }
    .pane-divider { width: auto; height: 1px; }

    .pane-preview { display: none; }
    .editor-split.show-preview .pane-write { display: none; }
    .editor-split.show-preview .pane-preview { display: block; min-height: 300px; }
    .editor-split.show-preview .pane-divider { display: none; }

    .auth-card { padding: 22px 18px; }
    .row-2 { flex-direction: column; }
    .thread-title { white-space: normal; }
}
