:root {
    --bg: #fafaf8;
    --surface: #ffffff;
    --border: #e8e8e4;
    --text: #1a1a1a;
    --text-muted: #6b6b6b;
    --text-light: #9b9b9b;
    --accent: #3d6b9e;
    --accent-hover: #2d5280;
    --accent-light: #eef3f9;
    --tag-bg: #f0f0ec;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.06);
    --font-sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    --font-serif: Georgia, 'Noto Serif SC', serif;
    --max-w: 780px;
    --max-w-wide: 1040px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.75;
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    display: block;
}

/* ── 导航栏 ── */
.site-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: var(--max-w-wide);
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.nav-logo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.nav-logo:hover {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background 0.2s, color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
}

/* ── 主内容区 ── */
.site-main {
    flex: 1;
    max-width: var(--max-w);
    width: 100%;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.site-main.wide {
    max-width: var(--max-w-wide);
}

/* ── 页面标题 ── */
.page-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
    margin-bottom: 8px;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ── 卡片 ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    border-color: #d4d4ce;
}

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

.card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.card-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── 按钮 ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    background: var(--tag-bg);
    color: var(--text-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--border);
    color: var(--text);
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #b02a37;
    border-color: #b02a37;
    color: #fff;
}

/* ── 表单 ── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61,107,158,0.12);
}

.form-control::placeholder {
    color: var(--text-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: #dc3545;
    margin-top: 4px;
    display: none;
}

.form-success {
    font-size: 0.8rem;
    color: #198754;
    margin-top: 4px;
    display: none;
}

/* ── 标签 ── */
.tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--tag-bg);
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

/* ── 分割线 ── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ── 提示框 ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-info {
    background: var(--accent-light);
    color: var(--accent);
    border-color: #c5d9ef;
}

.alert-success {
    background: #d1e7dd;
    color: #0a3622;
    border-color: #a3cfbb;
}

.alert-error {
    background: #f8d7da;
    color: #58151c;
    border-color: #f1aeb5;
}

/* ── 工具页布局 ── */
.tool-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}

.tool-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.tool-panel h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.tool-result {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 200px;
}

.result-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    min-height: 120px;
    color: var(--text);
    word-break: break-all;
}

/* ── 文章/内容区 ── */
.prose h1, .prose h2, .prose h3 {
    color: var(--text);
    line-height: 1.4;
    margin-top: 2em;
    margin-bottom: 0.6em;
}

.prose h1 { font-size: 1.7rem; }
.prose h2 {
    font-size: 1.2rem;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 1.05rem; }

.prose p {
    margin-bottom: 1.2em;
    color: var(--text);
}

.prose ul, .prose ol {
    padding-left: 1.5em;
    margin-bottom: 1.2em;
}

.prose li {
    margin-bottom: 0.4em;
}

.prose blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 1.5em 0;
    color: var(--text-muted);
    background: var(--accent-light);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── 标签页 ── */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    gap: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── 词条列表 ── */
.word-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.word-item:last-child {
    border-bottom: none;
}

.word-info strong {
    font-size: 1rem;
    color: var(--text);
    display: block;
    margin-bottom: 2px;
}

.word-info span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.word-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── 友情链接 ── */
.friend-link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.friend-link-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: #d4d4ce;
    color: var(--text);
}

.friend-link-card img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}

.friend-link-card .fl-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--accent);
}

.friend-link-card .fl-info p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── 文集正文兼容样式 ── */
.post-container {
    flex: 1;
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.post-container[style*="max-width:1100px"] {
    max-width: var(--max-w-wide) !important;
}

.back-link {
    display: inline-flex;
    margin-bottom: 24px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.back-link:hover {
    color: var(--accent);
}

.post-card,
.novel-content,
.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.post-title {
    font-size: 1.75rem;
    line-height: 1.35;
    margin-bottom: 12px;
    color: var(--text);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
    font-size: 0.85rem;
}

.post-content,
.novel-content {
    font-family: var(--font-sans);
    color: var(--text);
    line-height: 1.85;
}

.post-content h2,
.novel-content h2 {
    margin-top: 2em;
    margin-bottom: 0.75em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 1.2rem;
    color: var(--text);
}

.post-content h3,
.novel-content h3 {
    margin-top: 1.4em;
    margin-bottom: 0.6em;
    font-size: 1.05rem;
    color: var(--text);
}

.post-content p,
.novel-content p {
    margin-bottom: 1.1em;
}

.post-content ul,
.novel-content ul {
    padding-left: 1.5em;
    margin-bottom: 1.1em;
}

.novel-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 80px;
}

.sidebar h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar a {
    display: block;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.sidebar a:hover {
    color: var(--accent);
}

@media (max-width: 768px) {
    .post-container {
        padding: 32px 16px 48px;
    }

    .post-title {
        font-size: 1.4rem;
    }

    .novel-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }
}

/* ── 页脚 ── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-light);
    background: var(--surface);
}

/* ── 工具类 ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 8px 16px 16px;
        gap: 2px;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 10px 12px;
    }

    .nav-menu-btn {
        display: block;
    }

    .site-main {
        padding: 32px 16px 48px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .tool-layout {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nav-inner {
        padding: 0 16px;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    .btn {
        padding: 7px 13px;
        font-size: 0.83rem;
    }
}
