/* ===================== 基础样式 ===================== */
:root {
    --bg: #fef9ef;
    --card-bg: #fff8ee;
    --text: #5c3a1e;
    --text-light: #78716c;
    --primary: #d97706;
    --primary-hover: #b45309;
    --border: #fde68a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(180, 120, 30, 0.08);
    --shadow-hover: 0 4px 12px rgba(180, 120, 30, 0.12);
    --max-width: 800px;
    --pre-bg: #1e293b;
    --pre-color: #e2e8f0;
    --code-bg: #f3f4f6;
}

/* 暗色模式 */
body.dark-mode {
    --bg: #1a1a2e;
    --card-bg: #16213e;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --pre-bg: #0f172a;
    --pre-color: #e2e8f0;
    --code-bg: #1e293b;
}

* { 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);
    line-height: 1.8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ===================== 导航 ===================== */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text) !important;
    text-decoration: none !important;
}

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

.nav-links a {
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: all 0.2s;
    text-decoration: none !important;
}

.nav-links a:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* 暗色模式切换按钮 */
.dark-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 10px;
    margin-left: 4px;
    transition: all 0.2s;
    line-height: 1;
}
.dark-toggle:hover {
    background: var(--card-bg);
    border-color: var(--primary);
}

/* ===================== Flash 消息 ===================== */
.flash {
    padding: 12px 20px;
    border-radius: var(--radius);
    margin: 20px 0;
    font-size: 0.9rem;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }
.flash-info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ===================== Hero ===================== */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.hero p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* ===================== 搜索 ===================== */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    white-space: nowrap;
}

.search-btn:hover {
    background: var(--primary-hover);
}

.search-clear {
    color: var(--text-light);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ===================== 标签 ===================== */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.tag-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none !important;
    transition: all 0.2s;
}

.tag:hover {
    background: #c7d2fe;
}

.tag-active {
    background: var(--primary);
    color: white;
}

.tag-clear {
    background: #f3f4f6;
    color: var(--text-light);
}

/* ===================== 文章列表 ===================== */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.article-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    border: 1px solid var(--border);
}

.article-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.article-title {
    font-size: 1.35rem;
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-title a {
    color: var(--text) !important;
    text-decoration: none !important;
}

.article-title a:hover {
    color: var(--primary) !important;
}

.article-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.article-tag {
    color: var(--primary);
}

.article-summary {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 12px;
}

.read-more {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===================== 分页 ===================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 40px 0;
}

.page-link {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
    text-decoration: none !important;
    color: var(--text) !important;
}

.page-link:hover {
    background: var(--primary);
    color: white !important;
    border-color: var(--primary);
}

.page-info {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===================== 文章详情 ===================== */
.post-full {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    margin: 30px 0;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.post-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.post-title {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 16px;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.post-meta .tag {
    font-size: 0.75rem;
}

.post-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: #2c3e50;
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin: 28px 0 16px;
    line-height: 1.4;
}

.post-content h1 { font-size: 1.8rem; }
.post-content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.post-content h3 { font-size: 1.25rem; }

.post-content p {
    margin-bottom: 16px;
}

.post-content ul,
.post-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 6px;
}

.post-content blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--primary);
    background: #f0f4ff;
    border-radius: 0 8px 8px 0;
    color: var(--text-light);
}

.post-content code {
    background: var(--code-bg, #f3f4f6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.post-content pre {
    background: var(--pre-bg, #1e293b);
    color: var(--pre-color, #e2e8f0);
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.post-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 16px 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.post-content th,
.post-content td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.post-content th {
    background: var(--bg);
    font-weight: 600;
}

.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

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

/* ===================== 文章上下篇 ===================== */
.post-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.post-nav-link {
    max-width: 45%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    text-decoration: none !important;
    color: var(--text) !important;
    transition: all 0.2s;
}

.post-nav-link:hover {
    border-color: var(--primary);
    color: var(--primary) !important;
}

.post-nav-link.prev { text-align: left; }
.post-nav-link.next { text-align: right; }

/* ===================== 下载按钮 ===================== */
.download-btn {
    display: inline-block;
    padding: 4px 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none !important;
    transition: all 0.2s;
    margin-left: 4px;
}
.download-btn:hover {
    background: #fde68a;
    color: #78350f !important;
}

/* ===================== 分享按钮 ===================== */
.share-btn {
    display: inline-block;
    padding: 4px 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none !important;
    transition: all 0.2s;
    margin-left: 4px;
}
.share-btn:hover {
    background: #bbf7d0;
    color: #14532d !important;
}

/* ===================== 归档页面 ===================== */
.archive-page {
    padding: 40px 0;
}
.archive-page h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}
.archive-subtitle {
    color: var(--text-light);
    margin-bottom: 40px;
    font-size: 1rem;
}
.archive-year {
    margin-bottom: 40px;
}
.year-heading {
    font-size: 1.6rem;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.year-count {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: normal;
}
.archive-month {
    margin-left: 20px;
    margin-bottom: 24px;
}
.month-heading {
    font-size: 1.15rem;
    color: var(--primary);
    margin-bottom: 12px;
}
.month-count {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: normal;
}
.archive-list {
    list-style: none;
    padding: 0;
}
.archive-list li {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.archive-list li:last-child {
    border-bottom: none;
}
.archive-day {
    font-size: 0.85rem;
    color: var(--text-light);
    min-width: 36px;
    flex-shrink: 0;
}
.archive-title {
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none !important;
}
.archive-title:hover {
    color: var(--primary);
}

/* ===================== 微信公众号关注 ===================== */
.wechat-follow {
    margin-top: 24px;
    padding: 16px 20px;
    background: #fef3c7;
    border-radius: 10px;
    border: 1px solid #fde68a;
    text-align: center;
}
.wechat-follow p {
    margin: 0;
    font-size: 1rem;
    color: #92400e;
}
.wechat-follow strong {
    color: #d97706;
}

/* ===================== 网站运行天数 ===================== */
.site-days {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===================== 登录 ===================== */
.login-form {
    max-width: 400px;
    margin: 80px auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.login-form h1 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.5rem;
}

/* ===================== 关于 ===================== */
.about-page {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
}

.about-page h1 {
    margin-bottom: 24px;
}

.about-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: left;
}

.about-content p {
    margin-bottom: 12px;
    font-size: 1.05rem;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group .required { color: #dc2626; }

.form-group .hint {
    font-weight: normal;
    color: var(--text-light);
    font-size: 0.85rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===================== 按钮 ===================== */
.btn {
    display: inline-block;
    padding: 8px 20px;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.2s;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary) !important;
}

.btn-primary {
    background: var(--primary);
    color: white !important;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-danger {
    background: #dc2626;
    color: white !important;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c !important;
}

.btn-sm {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    text-decoration: none !important;
    color: var(--text);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary) !important;
}

/* ===================== 摘要行（AI 按钮） ===================== */
.summary-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.summary-row textarea {
    flex: 1;
}
.summary-row .btn-sm {
    align-self: flex-end;
    padding: 10px 16px;
    height: fit-content;
}

/* ===================== 分栏编辑器 ===================== */
.editor-split {
    display: flex;
    gap: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card-bg);
    min-height: 500px;
}
.editor-pane,
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.editor-pane {
    border-right: 1px solid var(--border);
}
.pane-label {
    padding: 8px 14px;
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.editor-pane textarea {
    flex: 1;
    border: none;
    border-radius: 0;
    resize: vertical;
    min-height: 400px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    padding: 14px;
}
.editor-pane textarea:focus {
    box-shadow: none;
    border-color: transparent;
}
.markdown-preview {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text);
    background: #fffdf7;
}
.markdown-preview h1 { font-size: 1.5rem; margin: 12px 0 8px; }
.markdown-preview h2 { font-size: 1.3rem; margin: 10px 0 6px; }
.markdown-preview h3 { font-size: 1.1rem; margin: 8px 0 4px; }
.markdown-preview p { margin-bottom: 10px; }
.markdown-preview pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}
.markdown-preview code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
.markdown-preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.markdown-preview blockquote {
    border-left: 3px solid var(--primary);
    padding: 6px 14px;
    margin: 10px 0;
    background: #fef9ef;
    color: var(--text-light);
}
.markdown-preview ul, .markdown-preview ol {
    padding-left: 20px;
    margin: 6px 0;
}
.markdown-preview li {
    margin-bottom: 4px;
}
.markdown-preview img {
    max-width: 100%;
    border-radius: 8px;
}
.markdown-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}
.markdown-preview a {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .editor-split {
        flex-direction: column;
    }
    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .editor-pane textarea {
        min-height: 250px;
    }
    .markdown-preview {
        min-height: 250px;
    }
}

/* ===================== 管理后台 ===================== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin: 30px 0 24px;
}

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

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 统计卡片 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* 最近文章列表 */
.recent-list {
    list-style: none;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.recent-list li {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-list li:last-child { border-bottom: none; }

.recent-list .date {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    text-decoration: none !important;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 文章表格 */
.post-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-collapse: collapse;
    overflow: hidden;
}

.post-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.post-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.post-table tr:last-child td { border-bottom: none; }

.post-table tr:hover {
    background: #f8fafc;
}

.date-cell {
    color: var(--text-light);
    font-size: 0.85rem !important;
    white-space: nowrap;
}

.action-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

.status-published {
    color: #166534;
    font-size: 0.85rem;
}

.status-draft {
    color: var(--text-light);
    font-size: 0.85rem;
}

.tag-sm {
    display: inline-block;
    padding: 2px 8px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 12px;
    font-size: 0.75rem;
    margin: 2px;
}

/* 编辑表单 */
.edit-form {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 12px;
}

/* ===================== 空状态 ===================== */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* ===================== Footer ===================== */
.footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ===================== 响应式 ===================== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        padding: 12px;
        gap: 4px;
    }

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

    .nav-links a {
        padding: 10px 16px;
        width: 100%;
    }

    .nav-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .post-full {
        padding: 24px 20px;
    }

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

    .post-nav {
        flex-direction: column;
    }

    .post-nav-link {
        max-width: 100%;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .post-table {
        font-size: 0.85rem;
    }

    .post-table th,
    .post-table td {
        padding: 8px 10px;
    }

    .edit-form {
        padding: 20px;
    }

    .stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-number {
        font-size: 1.6rem;
    }
}