/* ============================================================
   博客 · blog.xhja.cn
   设计语言与 www.xhja.cn / news.xhja.cn 保持一致：浅色渐变 + 玻璃拟态
   ============================================================ */

:root {
    --brand: #4290f5;
    --brand-deep: #3b5bdb;
    --brand-soft: rgba(66, 144, 245, .12);
    --ink: #2c3e50;
    --ink-2: #5a6b7d;
    --ink-3: #93a1b0;
    --line: rgba(255, 255, 255, .65);
    --card: rgba(255, 255, 255, .62);
    --radius: 14px;
    --shadow: 0 2px 10px rgba(31, 45, 61, .06);
}

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

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #e0f7ff, #f0efff);
    font-family: system-ui, "Microsoft Yahei", sans-serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.7;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ---------- 顶栏 ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, .55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 19px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b5bdb, #7048e8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 17px;
    height: 17px;
}

.brand-sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--ink-3);
    padding-left: 8px;
    border-left: 1px solid rgba(0, 0, 0, .1);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}

.topbar nav a {
    color: var(--ink-2);
}

.topbar nav a:hover {
    color: var(--brand);
    text-decoration: none;
}

/* ---------- 布局 ---------- */

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 26px 20px 60px;
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 26px;
    align-items: start;
}

.main {
    min-width: 0;
}

.side {
    position: sticky;
    top: 82px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ---------- 卡片 ---------- */

.card {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card h3::before {
    content: "";
    width: 3px;
    height: 13px;
    border-radius: 2px;
    background: linear-gradient(135deg, #3b5bdb, #7048e8);
}

/* ---------- 文章列表 ---------- */

.post-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    transition: transform .16s, box-shadow .16s;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(31, 45, 61, .1);
}

.post-card h2 {
    font-size: 18px;
    line-height: 1.45;
    margin-bottom: 6px;
}

.post-card h2 a {
    color: var(--ink);
}

.post-card h2 a:hover {
    color: var(--brand);
    text-decoration: none;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--ink-3);
    margin-bottom: 8px;
}

.post-meta .lock {
    color: #d97706;
}

.post-excerpt {
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.72;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tag {
    font-size: 11px;
    color: var(--brand-deep);
    background: var(--brand-soft);
    border-radius: 20px;
    padding: 2px 10px;
}

.category-chip {
    font-size: 12px;
    color: #fff;
    background: linear-gradient(135deg, #3b5bdb, #7048e8);
    border-radius: 20px;
    padding: 2px 10px;
}

/* ---------- 侧边栏组件 ---------- */

.search-box {
    display: flex;
    gap: 6px;
}

.search-box input {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 8px;
    background: rgba(255, 255, 255, .8);
    color: var(--ink);
    outline: none;
}

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

.mini-list {
    list-style: none;
    font-size: 13px;
}

.mini-list li {
    padding: 5px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, .06);
    color: var(--ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.mini-list a {
    color: var(--ink-2);
}

.mini-list a:hover {
    color: var(--brand);
}

.count {
    color: var(--ink-3);
    font-size: 12px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.author {
    text-align: center;
}

.author-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.author-desc {
    font-size: 12px;
    color: var(--ink-3);
    line-height: 1.7;
}

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

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 22px;
    font-size: 13px;
}

.pager button {
    padding: 6px 13px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 8px;
    background: rgba(255, 255, 255, .7);
    color: var(--ink-2);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}

.pager button:hover:not(:disabled) {
    border-color: var(--brand);
    color: var(--brand);
}

.pager button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.pager .cur {
    color: var(--ink-3);
}

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

.article {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 30px 34px;
    box-shadow: var(--shadow);
}

.article-head {
    border-bottom: 1px solid rgba(0, 0, 0, .07);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.article-head h1 {
    font-size: 26px;
    line-height: 1.4;
    margin-bottom: 10px;
}

/* Markdown 正文排版 */
.md-body {
    font-size: 15px;
    line-height: 1.85;
    color: var(--ink);
    word-wrap: break-word;
}

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
    margin: 26px 0 12px;
    line-height: 1.45;
    font-weight: 600;
}

.md-body h1 {
    font-size: 22px;
    border-left: 4px solid var(--brand);
    padding-left: 10px;
}

.md-body h2 {
    font-size: 19px;
    border-left: 3px solid var(--brand);
    padding-left: 9px;
}

.md-body h3 {
    font-size: 16px;
}

.md-body p {
    margin: 12px 0;
}

.md-body ul,
.md-body ol {
    margin: 12px 0 12px 24px;
}

.md-body li {
    margin: 5px 0;
}

.md-body blockquote {
    margin: 14px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--brand);
    background: rgba(66, 144, 245, .07);
    border-radius: 0 8px 8px 0;
    color: var(--ink-2);
}

.md-body code {
    background: rgba(0, 0, 0, .06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
}

.md-body pre {
    margin: 16px 0;
    padding: 14px 16px;
    background: #1f2430;
    border-radius: 10px;
    overflow-x: auto;
}

.md-body pre code {
    background: none;
    padding: 0;
    color: #e6e6e6;
    font-size: 13px;
    line-height: 1.6;
}

.md-body img {
    max-width: 100%;
    border-radius: 10px;
    margin: 14px 0;
    display: block;
}

.md-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.md-body th,
.md-body td {
    border: 1px solid rgba(0, 0, 0, .1);
    padding: 8px 12px;
    text-align: left;
}

.md-body th {
    background: rgba(66, 144, 245, .1);
    font-weight: 600;
}

.md-body hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, .1);
    margin: 24px 0;
}

/* ---------- 私密解锁 ---------- */

.lock-panel {
    text-align: center;
    padding: 40px 20px;
}

.lock-panel .icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.lock-panel input {
    padding: 9px 14px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 9px;
    background: rgba(255, 255, 255, .85);
    font-size: 14px;
    outline: none;
    margin-right: 8px;
    font-family: inherit;
    color: var(--ink);
}

.lock-panel input:focus {
    border-color: var(--brand);
}

/* ---------- 按钮 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b5bdb, #7048e8);
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .16s;
}

.btn:hover {
    opacity: .88;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn.ghost {
    background: rgba(255, 255, 255, .8);
    color: var(--ink-2);
    border: 1px solid rgba(0, 0, 0, .1);
}

/* ---------- 编辑器 ---------- */

.editor-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 26px 20px 60px;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.field input[type="text"],
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 9px;
    background: rgba(255, 255, 255, .8);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.editor-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.editor-panes textarea {
    min-height: 420px;
    resize: vertical;
    line-height: 1.7;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 14px;
}

.preview-pane {
    min-height: 420px;
    max-height: 620px;
    overflow-y: auto;
    padding: 16px 18px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.8;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.toolbar button {
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
    color: var(--ink-2);
    cursor: pointer;
    font-family: inherit;
}

.toolbar button:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.hint {
    font-size: 12px;
    color: var(--ink-3);
    line-height: 1.7;
}

.status {
    font-size: 13px;
    margin-top: 10px;
    padding: 9px 13px;
    border-radius: 8px;
}

.status.ok {
    background: rgba(15, 157, 88, .1);
    color: #0f9d58;
}

.status.err {
    background: rgba(229, 72, 77, .1);
    color: #e5484d;
}

.status.info {
    background: var(--brand-soft);
    color: var(--brand-deep);
}

/* 已发布文章管理表 */
.post-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}

.post-table th,
.post-table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, .07);
}

.post-table th {
    color: var(--ink-3);
    font-weight: 500;
    font-size: 12px;
}

.post-table .ops {
    display: flex;
    gap: 8px;
}

.post-table .ops button {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 6px;
    background: rgba(255, 255, 255, .8);
    cursor: pointer;
    color: var(--ink-2);
    font-family: inherit;
}

.post-table .ops button:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.post-table .ops button.danger:hover {
    border-color: #e5484d;
    color: #e5484d;
}

/* ---------- 空状态 ---------- */

.empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--ink-3);
    font-size: 14px;
}

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

.footer {
    text-align: center;
    font-size: 12px;
    color: var(--ink-3);
    padding: 24px 20px;
    line-height: 1.9;
    border-top: 1px solid var(--line);
    margin-top: 20px;
}

/* ---------- 返回顶部 ---------- */

.to-top {
    position: fixed;
    right: 22px;
    bottom: 26px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .8);
    backdrop-filter: blur(8px);
    color: var(--ink-2);
    cursor: pointer;
    font-size: 17px;
    box-shadow: var(--shadow);
    display: none;
    align-items: center;
    justify-content: center;
}

.to-top.show {
    display: flex;
}

/* ---------- 深色模式 ---------- */

@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #171a26, #1f2130);
        color: #e8eaf2;
    }

    :root {
        --ink: #e8eaf2;
        --ink-2: #a6a9bd;
        --ink-3: #6b6e80;
        --line: rgba(255, 255, 255, .1);
        --card: rgba(31, 33, 48, .72);
    }

    .topbar {
        background: rgba(31, 33, 48, .72);
        border-bottom-color: rgba(255, 255, 255, .08);
    }

    .brand,
    .post-card h2 a,
    .md-body {
        color: #e8eaf2;
    }

    .search-box input,
    .field input,
    .field select,
    .field textarea,
    .lock-panel input {
        background: rgba(0, 0, 0, .25);
        color: #e8eaf2;
        border-color: rgba(255, 255, 255, .12);
    }

    .md-body blockquote {
        color: #a6a9bd;
    }

    .md-body code {
        background: rgba(255, 255, 255, .1);
    }

    .preview-pane {
        background: rgba(0, 0, 0, .22);
    }

    .btn.ghost,
    .toolbar button,
    .pager button,
    .post-table .ops button,
    .to-top {
        background: rgba(255, 255, 255, .08);
        color: #a6a9bd;
        border-color: rgba(255, 255, 255, .12);
    }

    .category-chip {
        background: linear-gradient(135deg, #3b5bdb, #7048e8);
    }
}

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

@media (max-width: 860px) {
    .wrap {
        grid-template-columns: 1fr;
    }

    .side {
        position: static;
        order: 2;
    }

    .field-row,
    .editor-panes {
        grid-template-columns: 1fr;
    }

    .editor-panes textarea,
    .preview-pane {
        min-height: 300px;
    }

    .article {
        padding: 22px 18px;
    }

    .article-head h1 {
        font-size: 21px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .brand-sub {
        display: none;
    }
}

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

/* 评论表单输入框统一风格 */
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea,
#c-content {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 9px;
    background: rgba(255, 255, 255, .8);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

.comment-form textarea,
#c-content {
    resize: vertical;
}

.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus,
.comment-form textarea:focus,
#c-content:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, .12);
}

/* 评论表单里昵称/邮箱并排两列 */
.comment-form .field-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#comment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.comment-item {
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, .07);
    border-radius: 10px;
    background: rgba(255, 255, 255, .5);
}

.c-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 4px;
}

.c-head b {
    color: var(--brand-deep);
}

.c-time {
    color: var(--ink-3);
    font-size: 12px;
}

.c-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink);
    word-break: break-word;
}

#comment-mod .comment-item {
    margin-bottom: 12px;
}

@media (prefers-color-scheme: dark) {
    .comment-item {
        background: rgba(0, 0, 0, .2);
        border-color: rgba(255, 255, 255, .1);
    }
    .comment-form input[type="text"],
    .comment-form input[type="email"],
    .comment-form textarea,
    #c-content {
        background: rgba(0, 0, 0, .25);
        color: #e8eaf2;
        border-color: rgba(255, 255, 255, .12);
    }
    .comment-form input[type="text"]:focus,
    .comment-form input[type="email"]:focus,
    .comment-form textarea:focus,
    #c-content:focus {
        box-shadow: 0 0 0 3px rgba(108, 139, 255, .18);
    }
}

/* 小屏：昵称邮箱上下堆叠 */
@media (max-width: 640px) {
    .comment-form .field-row {
        grid-template-columns: 1fr;
    }
}
