/* ==========================================================================
   Base design tokens, reset and shared components
   ========================================================================== */

:root {
    --paper: #f7f4ee;
    --paper-2: #efeae1;
    --paper-3: #e5ddcf;
    --white: #fffdf9;
    --ink: #191c1f;
    --ink-soft: #2d3136;
    --muted: #6f726f;
    --muted-2: #96958e;
    --line: #ded6c8;
    --line-strong: #cfc4b3;
    --accent: #b4552d;
    --accent-dark: #8c3d1e;
    --accent-soft: #f3e3d9;
    --green: #2f5d50;
    --green-soft: #e4ece7;
    --amber: #a86a1f;
    --amber-soft: #f6ebd8;
    --danger: #a33a30;
    --danger-soft: #f7e3df;
    --dark: #14181c;
    --dark-2: #1d2228;
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(25, 28, 31, .05), 0 6px 20px rgba(25, 28, 31, .04);
    --shadow: 0 20px 50px rgba(25, 28, 31, .09);
    --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", "Microsoft YaHei", sans-serif;
    --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
    --max: 1200px;
    --header-h: 76px;
}

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

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

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.no-scroll {
    overflow: hidden;
}

img,
svg {
    max-width: 100%;
}

img {
    height: auto;
    display: block;
}

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

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote {
    margin: 0;
}

ul, ol {
    padding: 0;
    list-style: none;
}

table {
    border-collapse: collapse;
    width: 100%;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
}

::selection {
    background: var(--ink);
    color: var(--paper);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

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

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    left: 16px;
    top: -60px;
    z-index: 999;
    background: var(--ink);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    transition: top .2s ease;
}

.skip-link:focus {
    top: 16px;
}

.muted {
    color: var(--muted);
}

.nowrap {
    white-space: nowrap;
}

.dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
    opacity: .55;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--accent);
    font-family: var(--sans);
}

.text-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 2px;
    transition: border-color .2s ease, color .2s ease;
}

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

.text-link--light {
    color: var(--paper);
    border-color: rgba(255, 255, 255, .4);
}

.text-link--light:hover {
    color: #fff;
    border-color: #fff;
}

/* Buttons ---------------------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--paper-2);
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    text-align: center;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button--dark {
    background: var(--ink);
    color: var(--white);
    border-color: var(--ink);
}

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

.button--light {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--paper);
}

.button--light:hover {
    background: #fff;
    border-color: #fff;
}

.button--ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--ink);
}

.button--ghost:hover {
    border-color: var(--ink);
    background: rgba(25, 28, 31, .04);
}

.button--danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.button--danger:hover {
    background: #872d25;
    border-color: #872d25;
}

.button--sm {
    padding: 8px 14px;
    font-size: 13px;
}

.button--lg {
    padding: 15px 28px;
    font-size: 15px;
}

.button--block {
    width: 100%;
}

.button[disabled] {
    opacity: .55;
    pointer-events: none;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    transition: background .2s ease, border-color .2s ease;
}

.icon-button:hover {
    background: var(--paper-2);
    border-color: var(--line);
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: color .2s ease, border-color .2s ease;
}

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

.link-button--danger {
    color: var(--danger);
}

.link-button--danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Badges & status -------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--muted);
    line-height: 1.6;
}

.badge--admin {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

.badge--soft {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-dark);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.7;
    background: var(--paper-2);
    color: var(--muted);
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.status--published,
.status--approved {
    background: var(--green-soft);
    color: var(--green);
}

.status--draft {
    background: var(--paper-2);
    color: var(--muted);
}

.status--pending {
    background: var(--amber-soft);
    color: var(--amber);
}

.status--rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Avatars ---------------------------------------------------------------- */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    border: 1px solid rgba(25, 28, 31, .08);
    background: var(--paper-2);
}

.avatar--sm {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.avatar--lg {
    width: 64px;
    height: 64px;
    font-size: 22px;
}

.avatar--xl {
    width: 92px;
    height: 92px;
    font-size: 32px;
}

.avatar--initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: rgba(255, 255, 255, .95);
    font-family: var(--serif);
    letter-spacing: 0;
    border: 0;
}

.avatar--tone-1 { background: linear-gradient(135deg, #3b5f57, #6b8f7d); }
.avatar--tone-2 { background: linear-gradient(135deg, #8c3d1e, #c47a50); }
.avatar--tone-3 { background: linear-gradient(135deg, #3c4a63, #6e7f9c); }
.avatar--tone-4 { background: linear-gradient(135deg, #6f5336, #a98a61); }
.avatar--tone-5 { background: linear-gradient(135deg, #5d3a4a, #967082); }
.avatar--tone-6 { background: linear-gradient(135deg, #3f4f3b, #7a8d6a); }

/* Forms ------------------------------------------------------------------ */

.form .field + .field {
    margin-top: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field > label,
.field > .field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: .01em;
}

.field__optional {
    font-weight: 400;
    color: var(--muted-2);
    font-size: 12px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="search"],
.field input[type="number"],
.field input[type="datetime-local"],
.field input[type="date"],
.field textarea,
.field select,
.filter-form input,
.filter-form select {
    width: 100%;
    padding: 11px 13px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--ink);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    appearance: none;
}

.field select,
.filter-form select {
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(25, 28, 31, .07);
}

.field textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.7;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--muted-2);
}

.field input:disabled,
.field textarea:disabled {
    background: var(--paper-2);
    color: var(--muted);
    cursor: not-allowed;
}

.field__hint {
    font-size: 12px;
    color: var(--muted-2);
    line-height: 1.6;
}

.field__error {
    font-size: 12px;
    color: var(--danger);
    font-weight: 500;
}

.field.has-error input,
.field.has-error textarea,
.field.has-error select {
    border-color: var(--danger);
    background: #fffaf9;
}

.field__password {
    position: relative;
}

.field__password input {
    padding-right: 64px;
}

.field__reveal {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 5px;
}

.field__reveal:hover {
    color: var(--ink);
    background: var(--paper-2);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--ink);
    margin: 0;
}

.checkbox--danger {
    color: var(--danger);
}

.checkbox--danger input {
    accent-color: var(--danger);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.field--title input {
    font-family: var(--serif);
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 600;
    padding: 6px 0 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    line-height: 1.3;
}

.field--title input:focus {
    box-shadow: none;
    border-color: var(--ink);
}

.field--slug .field__hint {
    margin-top: 0;
}

.slug-input {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    overflow: hidden;
}

.slug-input > span {
    display: flex;
    align-items: center;
    padding: 0 10px;
    background: var(--paper-2);
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 11px;
    border-right: 1px solid var(--line);
    white-space: nowrap;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slug-input input {
    border: 0;
    border-radius: 0;
    background: transparent;
    flex: 1;
    min-width: 0;
}

.slug-input input:focus {
    box-shadow: none;
}

/* Tags ------------------------------------------------------------------- */

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

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
    color: var(--ink-soft);
    background: transparent;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.tag span {
    font-size: 10px;
    color: var(--muted-2);
    font-family: var(--mono);
}

.tag:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

.tag:hover span {
    color: rgba(255, 255, 255, .6);
}

.tag-cloud--compact {
    gap: 6px;
}

.tag-cloud--compact .tag {
    padding: 5px 10px;
    font-size: 12px;
}

/* Toasts ----------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    top: 92px;
    right: 24px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--white);
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.55;
    pointer-events: auto;
    animation: toastIn .28s ease both;
}

.toast--success .toast__dot { background: #82b08f; }
.toast--error .toast__dot { background: #e08a7b; }
.toast--info .toast__dot { background: #d8b36a; }

.toast__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-top: 6px;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, .7);
}

.toast__text {
    flex: 1;
}

.toast__close {
    border: 0;
    background: none;
    color: rgba(255, 255, 255, .6);
    font-size: 18px;
    line-height: 1;
    padding: 0 0 0 6px;
}

.toast__close:hover {
    color: #fff;
}

.toast.is-leaving {
    animation: toastOut .22s ease both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* Pagination ------------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

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

.pagination__page,
.pagination__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted);
    transition: background .2s ease, color .2s ease;
}

.pagination__page:hover,
.pagination__arrow:hover {
    background: var(--paper-2);
    color: var(--ink);
}

.pagination__page.is-current {
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
}

.pagination__arrow.is-disabled {
    opacity: .35;
}

.pagination__ellipsis {
    color: var(--muted-2);
    padding: 0 4px;
}

/* Empty states ----------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 80px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: rgba(255, 253, 249, .5);
}

.empty-state__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--paper-2);
    font-family: var(--serif);
    font-size: 26px;
    color: var(--muted);
    margin-bottom: 20px;
}

.empty-state h2 {
    font-family: var(--serif);
    font-size: 26px;
    margin-bottom: 8px;
}

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

/* Editorial prose shared by front article & editor ----------------------- */

.prose {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.95;
    color: #23262a;
    word-break: break-word;
}

.prose > * + * {
    margin-top: 1.15em;
}

.prose h2,
.prose h3,
.prose h4 {
    font-family: var(--serif);
    line-height: 1.35;
    font-weight: 600;
    color: var(--ink);
    margin-top: 1.8em;
    margin-bottom: .6em;
}

.prose h2 {
    font-size: clamp(24px, 2.6vw, 30px);
    letter-spacing: -.01em;
}

.prose h3 {
    font-size: 22px;
}

.prose h4 {
    font-size: 19px;
}

.prose p {
    margin: 0;
}

.prose a {
    color: var(--accent-dark);
    border-bottom: 1px solid rgba(180, 85, 45, .35);
    transition: border-color .2s ease;
}

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

.prose strong {
    font-weight: 700;
    color: var(--ink);
}

.prose blockquote {
    margin: 1.6em 0;
    padding: 4px 0 4px 24px;
    border-left: 2px solid var(--accent);
    color: var(--ink-soft);
    font-style: italic;
    font-size: 1.04em;
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
    list-style: disc;
}

.prose ol {
    list-style: decimal;
}

.prose li + li {
    margin-top: .4em;
}

.prose li::marker {
    color: var(--accent);
}

.prose img {
    width: 100%;
    border-radius: var(--radius-sm);
    margin: 1.8em 0;
}

.prose figure {
    margin: 1.8em 0;
}

.prose figcaption {
    margin-top: 8px;
    font-family: var(--sans);
    font-size: 12px;
    color: var(--muted-2);
    text-align: center;
}

.prose hr {
    margin: 2.4em 0;
    border-top: 1px solid var(--line);
}

.prose code {
    font-family: var(--mono);
    font-size: .86em;
    background: var(--paper-2);
    padding: 2px 6px;
    border-radius: 4px;
}

.prose pre {
    background: var(--dark);
    color: #e9e4d9;
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.7;
}

.prose pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.prose table {
    font-family: var(--sans);
    font-size: 14px;
    border: 1px solid var(--line);
}

.prose th,
.prose td {
    padding: 9px 12px;
    border: 1px solid var(--line);
    text-align: left;
}

.prose th {
    background: var(--paper-2);
    font-weight: 600;
}

.prose sup,
.prose sub {
    font-size: .7em;
}

/* Scrollbar -------------------------------------------------------------- */

::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

::-webkit-scrollbar-track {
    background: var(--paper);
}

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 999px;
    border: 3px solid var(--paper);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-2);
}

@media (max-width: 720px) {
    .container {
        padding: 0 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .toast-stack {
        top: 76px;
        right: 16px;
    }

    .button {
        padding: 11px 18px;
    }

    .prose {
        font-size: 17px;
        line-height: 1.9;
    }
}

/* The hidden attribute must always win over component display rules. */
[hidden] {
    display: none !important;
}

/* Primary submit buttons that sit directly inside a form need breathing room. */
.form > .button[type="submit"] {
    margin-top: 22px;
}
