:root {
    --primary: #02993b;
    --ink: #15251a;
    --muted: #66736a;
    --line: #dfe8e2;
    --soft: #f6faf7;
    --panel: #ffffff;
    --page-gutter: clamp(20px, 4vw, 48px);
    --content-width: min(1180px, calc(100% - var(--page-gutter) - var(--page-gutter)));
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: #fbfdfb;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.75;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: var(--content-width);
    margin: 0 auto;
    padding: 28px 0 18px;
}

.brand {
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
}

.site-nav {
    display: flex;
    gap: 22px;
    color: var(--muted);
    font-size: 14px;
}

.site-nav a:hover,
.back-link:hover {
    color: var(--primary);
}

.page {
    width: var(--content-width);
    margin: 0 auto;
    padding: 52px 0 72px;
}

.intro {
    max-width: 980px;
    padding: 18px 0 38px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.intro h1,
.article h1,
.empty-state h1 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.14;
    letter-spacing: 0;
}

.intro p:not(.eyebrow) {
    max-width: 820px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 17px;
}

.post-list {
    display: grid;
    gap: 14px;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px auto auto;
    gap: 12px;
    align-items: end;
    margin: 10px 0 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.filter-bar label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.filter-bar input,
.filter-bar select,
.admin-form select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus,
.admin-form select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 153, 59, 0.12);
}

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 22px;
}

.category-pills a,
.post-category,
.article-category {
    border: 1px solid #d8e7dd;
    border-radius: 999px;
    padding: 4px 10px;
    background: #f5faf7;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.category-pills a.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.post-card,
.empty-state,
.admin-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.post-card a {
    display: block;
    padding: 24px 26px;
}

.post-card time,
.reaction-line,
.table-meta {
    color: var(--muted);
    font-size: 13px;
}

.post-card time {
    margin-right: 8px;
}

.post-card h2 {
    margin: 8px 0;
    color: var(--ink);
    font-size: 24px;
    line-height: 1.35;
    letter-spacing: 0;
}

.post-card p {
    margin: 0 0 14px;
    color: var(--muted);
}

.post-card:hover {
    border-color: rgba(2, 153, 59, 0.45);
    box-shadow: 0 16px 40px rgba(18, 55, 30, 0.08);
}

.empty-state {
    padding: 34px;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    margin: 0 0 22px;
    color: var(--muted);
}

.button,
.link-button,
.danger-button,
.reaction-box button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

.link-button {
    background: #edf8f1;
    color: var(--primary);
}

.danger-button {
    background: #fff1f1;
    color: #b42318;
}

.article-page {
    width: min(820px, calc(100% - 36px));
}

.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 14px;
}

.article-summary {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 18px;
}

.article-category {
    display: inline-flex;
    margin: 10px 0 12px;
}

.article-content {
    margin-top: 34px;
    padding-top: 26px;
    border-top: 1px solid var(--line);
    color: #253229;
    font-size: 18px;
}

.article-content p {
    margin: 0 0 22px;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    margin: 34px 0 14px;
    color: var(--ink);
    line-height: 1.35;
    letter-spacing: 0;
}

.article-content h1 {
    font-size: 30px;
}

.article-content h2 {
    font-size: 25px;
}

.article-content h3 {
    font-size: 21px;
}

.article-content ul,
.article-content ol {
    margin: 0 0 22px;
    padding-left: 1.35em;
}

.article-content li {
    margin: 6px 0;
}

.article-content blockquote {
    margin: 0 0 22px;
    border-left: 3px solid var(--primary);
    padding: 10px 0 10px 18px;
    color: #4e5d53;
    background: #f4faf6;
}

.article-content code {
    border: 1px solid #d8e7dd;
    border-radius: 4px;
    padding: 2px 5px;
    background: #f2f8f4;
    color: #0d7030;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.92em;
}

.article-content pre {
    overflow-x: auto;
    margin: 0 0 24px;
    border: 1px solid #d8e7dd;
    border-radius: 8px;
    padding: 16px;
    background: #0f1d14;
    color: #e8f4ec;
    line-height: 1.65;
}

.article-content pre code {
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: 14px;
}

.reaction-box {
    display: flex;
    gap: 12px;
    margin-top: 38px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.reaction-box button {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}

.reaction-box button:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.site-footer {
    width: var(--content-width);
    margin: 0 auto;
    padding: 24px 0 34px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 28px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.pagination a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 14px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.admin-page {
    width: min(1040px, calc(100% - 36px));
}

.admin-page.narrow {
    width: min(480px, calc(100% - 36px));
}

.admin-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-heading h1,
.login-panel h1 {
    margin: 0;
    font-size: clamp(32px, 4vw, 48px);
    line-height: 1.15;
    letter-spacing: 0;
}

.admin-panel {
    padding: 26px;
}

.login-panel {
    margin-top: 52px;
}

.admin-form {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.admin-form label {
    display: grid;
    gap: 8px;
    color: var(--ink);
    font-weight: 700;
}

.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form textarea,
.admin-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.admin-filter {
    grid-template-columns: minmax(220px, 1fr) 160px 150px auto auto;
    margin-top: 0;
    margin-bottom: 22px;
}

.content-input {
    min-height: 420px;
    line-height: 1.75;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
}

.format-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    border: 1px solid #d8e7dd;
    border-radius: 8px;
    padding: 12px;
    background: #f5faf7;
    color: var(--muted);
    font-size: 13px;
}

.format-guide strong {
    color: var(--ink);
}

.format-guide span {
    border: 1px solid #dfe8e2;
    border-radius: 999px;
    padding: 3px 9px;
    background: #fff;
}

.captcha-widget {
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 360px;
    border: 1px solid #d7e8dd;
    border-radius: 12px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
    box-shadow: 0 18px 46px rgba(18, 55, 30, 0.08);
    --captcha-progress: 44px;
}

.captcha-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.captcha-head span {
    font-weight: 800;
    color: var(--ink);
}

.captcha-head strong {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.captcha-scene {
    width: 100%;
}

.captcha-bg {
    position: relative;
    height: 128px;
    overflow: hidden;
    border: 1px solid #cfe5d6;
    border-radius: 12px;
    background:
        radial-gradient(circle at 22% 26%, rgba(2, 153, 59, 0.14), transparent 26%),
        radial-gradient(circle at 84% 20%, rgba(20, 117, 64, 0.12), transparent 22%),
        linear-gradient(135deg, rgba(2, 153, 59, 0.15), rgba(255, 255, 255, 0.65)),
        repeating-linear-gradient(45deg, #f5fbf7 0 16px, #e9f5ed 16px 32px);
}

.captcha-bg::before,
.captcha-bg::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.56);
}

.captcha-bg::before {
    width: 112px;
    height: 112px;
    left: -38px;
    bottom: -52px;
}

.captcha-bg::after {
    width: 76px;
    height: 76px;
    right: 28px;
    top: -36px;
}

.captcha-hole,
.captcha-piece {
    position: absolute;
    top: 42px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
}

.captcha-hole {
    left: var(--captcha-target);
    border: 2px dashed rgba(2, 153, 59, 0.58);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: inset 0 0 0 5px rgba(2, 153, 59, 0.06);
}

.captcha-piece {
    left: 0;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 26px rgba(2, 153, 59, 0.28);
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.captcha-piece span {
    transform: rotate(45deg);
    font-size: 17px;
}

.captcha-track {
    position: relative;
    width: 100%;
    height: 48px;
    overflow: hidden;
    border: 1px solid #cfe5d6;
    border-radius: 999px;
    background: #f7fbf8;
}

.captcha-progress {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--captcha-progress);
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(2, 153, 59, 0.16), rgba(2, 153, 59, 0.28));
    transition: background 0.15s ease;
}

.captcha-tip {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
}

.captcha-handle {
    position: absolute;
    left: 0;
    top: 2px;
    width: 44px;
    height: 42px;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    cursor: grab;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(2, 153, 59, 0.28);
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.captcha-handle span {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
}

.captcha-handle.dragging {
    cursor: grabbing;
    box-shadow: 0 14px 30px rgba(2, 153, 59, 0.34);
}

.captcha-widget.is-passed {
    border-color: rgba(2, 153, 59, 0.62);
}

.captcha-widget.is-passed .captcha-head strong,
.captcha-widget.is-passed .captcha-tip {
    color: var(--primary);
}

.captcha-widget.is-passed .captcha-progress,
.captcha-widget.is-passed .captcha-handle,
.captcha-widget.is-passed .captcha-piece {
    background: var(--primary);
}

.captcha-widget.is-passed .captcha-hole {
    border-style: solid;
    background: rgba(2, 153, 59, 0.08);
}

.captcha-widget.is-failed {
    animation: captcha-shake 0.28s ease;
    border-color: #f1b9b9;
}

.captcha-widget.is-failed .captcha-head strong,
.captcha-widget.is-failed .captcha-tip {
    color: #b42318;
}

@keyframes captcha-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.admin-form input:focus,
.admin-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 153, 59, 0.12);
}

.checkbox-label {
    display: flex !important;
    grid-template-columns: none;
    align-items: center;
    gap: 10px !important;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-error {
    margin: 16px 0 0;
    border: 1px solid #ffd4d4;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff5f5;
    color: #b42318;
}

.post-table {
    display: grid;
}

.post-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
}

.post-row:first-child {
    padding-top: 0;
}

.post-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.post-row h2 {
    margin: 0 0 6px;
    font-size: 21px;
    line-height: 1.35;
}

.post-row form {
    margin: 0;
}

.inline-empty {
    border: 0;
    padding: 10px 0;
}

@media (max-width: 640px) {
    .site-header {
        align-items: flex-start;
        gap: 14px;
        flex-direction: column;
    }

    .page {
        padding-top: 32px;
    }

    .post-card a,
    .empty-state {
        padding: 22px;
    }

    .filter-bar,
    .admin-filter {
        grid-template-columns: 1fr;
    }

    .intro h1,
    .article h1,
    .empty-state h1 {
        font-size: 34px;
    }

    .admin-heading,
    .post-row,
    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions a,
    .row-actions button,
    .form-actions a,
    .form-actions button {
        width: 100%;
    }
}
