/* ============================================================
   梯度札记 · 极简博客样式
   设计原则：单栏阅读、克制的留白、一套 CSS 变量驱动明暗主题。
   ============================================================ */

:root {
    --bg: #faf9f7;
    --surface: #ffffff;
    --surface-2: #f3f2ef;
    --text: #23272b;
    --text-muted: #6b7178;
    --border: #e4e2dd;
    --accent: #0f766e;
    --accent-soft: #e6f2f0;
    --danger: #b42318;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 24, 28, 0.05);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
    --bg: #15181b;
    --surface: #1c2024;
    --surface-2: #23282e;
    --text: #d8dde2;
    --text-muted: #8b949e;
    --border: #2d333a;
    --accent: #2dd4bf;
    --accent-soft: #16302d;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.75;
    transition: background 0.2s ease, color 0.2s ease;
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
}

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

h1, h2, h3 { line-height: 1.4; color: var(--text); }

/* ---------------- 顶部导航 ---------------- */

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); flex: none; }

.site-nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-wrap: wrap;
}
.site-nav a {
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 15px;
}
.site-nav a:hover { background: var(--surface-2); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex: none;
}
.theme-toggle:hover { background: var(--surface-2); }
[data-theme="light"] .icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: none; }

/* ---------------- 首页 Hero ---------------- */

.hero {
    padding: 56px 0 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}
.hero h1 {
    font-size: 26px;
    margin: 0 0 14px;
    font-weight: 700;
}
.hero-sub { color: var(--text-muted); margin: 0 0 20px; }
.hero-actions { display: flex; gap: 12px; margin: 0; }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- 两栏布局 ---------------- */

.home-grid {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 36px;
    padding-bottom: 48px;
}
.home-side { font-size: 14px; }

.section-title {
    font-size: 15px;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 0 0 16px;
}

/* ---------------- 文章卡片 ---------------- */

.post-card {
    padding: 22px 0;
    border-bottom: 1px solid var(--border);
}
.post-card:first-of-type { padding-top: 4px; }
.post-title { margin: 6px 0 8px; font-size: 20px; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); text-decoration: none; }
.post-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.post-meta .cat { color: var(--accent); }
.dot { opacity: 0.5; }
.post-excerpt {
    color: var(--text-muted);
    margin: 0 0 10px;
    font-size: 15px;
}
.tag-row, .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag-row a, .tag-cloud a {
    font-size: 13px;
    color: var(--text-muted);
}
.tag-row a:hover, .tag-cloud a:hover { color: var(--accent); }

.side-list { list-style: none; padding: 0; margin: 0 0 28px; }
.side-list li { border-bottom: 1px solid var(--border); }
.side-list a {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    color: var(--text);
}
.side-list a span { color: var(--text-muted); font-size: 13px; }
.more-link { margin-top: 18px; }

/* ---------------- 文章详情 ---------------- */

.post-detail { padding: 36px 0 24px; }
.post-detail-head h1 { font-size: 30px; margin: 0 0 10px; }
.post-detail-foot {
    margin-top: 36px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.post-detail-foot a { color: var(--text-muted); font-size: 14px; }

/* 正文：纯文本渲染，段落 + 换行 + 图片 + 自动链接 */
.article-body { padding: 8px 0; }
.narrow { max-width: 680px; }
.article-body p { margin: 14px 0; }
.article-body a { text-decoration: underline; text-underline-offset: 2px; }
.article-body img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.article-image {
    margin: 22px 0;
    text-align: center;
}
.article-image img { display: block; margin: 0 auto; }
.article-image figcaption {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------------- 分页 ---------------- */

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 36px 0;
    font-size: 14px;
}
.pager .disabled { color: var(--text-muted); opacity: 0.5; }
.pager-info { color: var(--text-muted); }

/* ---------------- 页面标题 ---------------- */

.page-title {
    font-size: 26px;
    margin: 36px 0 18px;
}
.page-title small {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 10px;
}
.page-desc { color: var(--text-muted); font-size: 15px; }
.empty { color: var(--text-muted); padding: 40px 0; text-align: center; }

/* ---------------- 关于页链接 ---------------- */

.about-links { margin-top: 28px; }
.about-link-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.about-link-list li {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.about-link-list a { font-size: 15px; }

/* ---------------- 项目页 ---------------- */

.project-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 48px;
}
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.project-head h2 { font-size: 17px; margin: 0; }
.project-tech {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    margin: 4px 0 10px;
}
.project-desc { font-size: 14px; color: var(--text-muted); margin: 0 0 10px; }
.status {
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid var(--border);
}
.status-done { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-doing { background: var(--surface-2); color: var(--text); }
.status-plan { color: var(--text-muted); }

/* ---------------- 404 ---------------- */

.error-page { text-align: center; padding: 90px 0; }
.error-code { font-size: 64px; font-weight: 700; color: var(--accent); margin: 0; }
.error-page h1 { font-size: 22px; }
.error-page p { color: var(--text-muted); }

/* ---------------- 页脚 ---------------- */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 28px 0 40px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}
.footer-links { display: flex; gap: 18px; margin-bottom: 8px; }
.footer-links a { color: var(--text-muted); }
.footer-meta { margin: 0; }

/* ---------------- 后台 ---------------- */

.admin-body { background: var(--bg); }
.admin-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}
.admin-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 56px;
    max-width: 1000px;
}
.admin-menu { display: flex; gap: 2px; margin-left: 12px; overflow-x: auto; }
.admin-menu a {
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
}
.admin-menu a.active { color: var(--accent); background: var(--accent-soft); }
.admin-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.inline-form { display: inline; }
.admin-main { max-width: 1000px; padding-bottom: 60px; }

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    border: 1px solid var(--border);
}
.alert-ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.alert-error { background: rgba(180, 35, 24, 0.08); color: var(--danger); border-color: transparent; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 20px 0;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    font-size: 14px;
    color: var(--text-muted);
}
.stat-card span {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 18px 0;
}
.filter-links { display: flex; gap: 10px; font-size: 14px; }
.filter-links a.active { color: var(--accent); font-weight: 600; }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 14px;
}
.table th, .table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.table th { background: var(--surface-2); font-weight: 600; font-size: 13px; color: var(--text-muted); }
.table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.link-danger {
    background: none;
    border: none;
    padding: 0;
    color: var(--danger);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
}
.link-danger:hover { text-decoration: underline; }
.badge {
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 999px;
}
.badge-published { background: var(--accent-soft); color: var(--accent); }
.badge-draft { background: var(--surface-2); color: var(--text-muted); }

.post-form label, .card-form label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.post-form input, .post-form select, .post-form textarea,
.card-form input, .card-form select, .card-form textarea,
.inline-create input, .inline-edit input {
    width: 100%;
    margin-top: 5px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
}
.post-form textarea, .card-form textarea { font-family: var(--font-mono); font-size: 14px; line-height: 1.7; }
.post-form input:focus, .post-form select:focus, .post-form textarea:focus,
.card-form input:focus, .card-form textarea:focus, .card-form select:focus {
    border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr 140px; gap: 12px; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.editor-toolbar { display: flex; align-items: center; gap: 12px; margin: 5px 0; }
.toolbar-hint { font-size: 12px; color: var(--text-muted); }
.full { grid-column: 1 / -1; }

.card-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-form h2 { font-size: 17px; margin: 0 0 14px; }

.inline-create {
    display: flex;
    gap: 10px;
    margin: 16px 0;
    align-items: center;
}
.inline-create input { margin-top: 0; }
.inline-create input:first-child { max-width: 180px; }
.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input { margin-top: 0; min-width: 220px; }

/* ---------------- 登录页 ---------------- */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 0 0 20px; text-align: center; }
.login-card label { display: block; font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }
.login-card input {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}
.login-card .btn { margin-top: 6px; }
.login-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin: 14px 0 0; }
.login-back { text-align: center; margin: 8px 0 0; font-size: 13px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 760px) {
    .home-grid { grid-template-columns: 1fr; gap: 12px; }
    .home-side { border-top: 1px solid var(--border); padding-top: 20px; }
    .project-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .hero { padding: 40px 0 26px; }
    .hero h1 { font-size: 22px; }
    .post-detail-head h1 { font-size: 24px; }
    .admin-nav { gap: 8px; }
    .admin-menu { order: 3; width: 100%; margin: 0; }
    .admin-header { height: auto; }
    .admin-nav { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 8px; }
    .table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------------- 无障碍：跳过链接 / 焦点 / 减弱动效 ---------------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--text);
    color: var(--bg);
    padding: 8px 14px;
    border-radius: 0 0 8px 0;
    z-index: 100;
}
.skip-link:focus { left: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------------- 搜索框 ---------------- */

.search-form { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.search-form input[type="search"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    min-width: 140px;
    font-family: inherit;
}
.search-form-large { display: flex; margin: 0 0 24px; }
.search-form-large input[type="search"] { flex: 1; padding: 10px 14px; font-size: 16px; }
.search-form-inline { margin-left: auto; }

/* ---------------- 编辑器预览 ---------------- */

.field label { display: block; font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.preview-pane {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 8px;
    background: var(--surface);
}

/* ---------------- 评论 ---------------- */

.comments { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.comment-list { list-style: none; padding: 0; margin: 0 0 32px; }
.comment-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px 18px;
    margin-bottom: 12px;
}
.comment-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.comment-name { color: var(--text); font-weight: 600; }
.comment-body { font-size: 15px; white-space: pre-wrap; word-break: break-word; }

.comment-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.comment-form h3 { margin: 0 0 6px; font-size: 16px; }
.comment-tip { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }
.comment-form label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.comment-form input, .comment-form textarea {
    width: 100%;
    margin-top: 5px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
}
.comment-form textarea { resize: vertical; }
/* 蜜罐：真实访客不可见，机器人填写后会被静默丢弃 */
.hp-field { position: absolute; left: -9999px; top: -9999px; height: 0; width: 0; overflow: hidden; }

/* 后台导航红点 / 状态徽标 */
.badge-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 2px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}
.stat-warn span { color: var(--danger); }
.comment-status {
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid var(--border);
}
.comment-status-pending { color: var(--danger); }
.comment-status-approved { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.comment-status-rejected { color: var(--text-muted); }
.comment-cell { max-width: 420px; }
.comment-cell-body { margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.audit-action {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 5px;
}
.check-line { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-size: 15px; }
.check-line input { width: auto; margin-top: 4px; }

/* ---------------- 两步验证 / 恢复码 ---------------- */

.mono { font-family: var(--font-mono); word-break: break-all; }
.recovery-codes {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 14px 16px;
    border-radius: 8px;
    line-height: 1.9;
    overflow-x: auto;
}
.page-desc code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

/* ---------------- 暗色主题：主按钮白字对比度修复 ---------------- */

[data-theme="dark"] .btn:not(.btn-ghost) { color: #06251f; }
