:root {
    --paper: #efede6;
    --paper-deep: #dedbd2;
    --ink: #11110f;
    --muted: #66635d;
    --line: rgba(17, 17, 15, 0.76);
    --soft-line: rgba(17, 17, 15, 0.22);
    --black: #11110f;
    --white: #faf9f4;
    --danger: #4d1919;
    --success: #1f3b2a;
    --max-width: 1180px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        linear-gradient(90deg, rgba(0, 0, 0, 0.018) 1px, transparent 1px),
        linear-gradient(rgba(0, 0, 0, 0.014) 1px, transparent 1px);
    background-size: 8px 8px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

body::before {
    position: fixed;
    z-index: 20;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: 0.075;
    background-image: radial-gradient(rgba(0, 0, 0, 0.75) 0.55px, transparent 0.7px);
    background-size: 4px 4px;
    mix-blend-mode: multiply;
}

body::after {
    position: fixed;
    z-index: 19;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: 0.05;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.7) 0,
        rgba(0, 0, 0, 0.7) 1px,
        transparent 1px,
        transparent 4px
    );
}

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-thickness: 2px;
}

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

button {
    cursor: pointer;
}

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

.skip-link {
    position: fixed;
    z-index: 100;
    top: -100px;
    left: 20px;
    padding: 10px 14px;
    color: var(--white);
    background: var(--black);
}

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

.site-header {
    border-bottom: 2px solid var(--ink);
    background: rgba(239, 237, 230, 0.94);
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(var(--max-width), calc(100% - 48px));
    min-height: 94px;
    margin: 0 auto;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    color: var(--ink);
    text-decoration: none;
}

.brand-main {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
}

.brand-sub {
    padding-left: 9px;
    border-left: 1px solid var(--ink);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.22em;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.site-nav a {
    text-decoration: none;
}

.site-nav a:hover {
    text-decoration: underline;
}

.nav-logout {
    margin: 0;
}

.nav-button {
    padding: 0;
    border: 0;
    color: var(--ink);
    background: transparent;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.site-main {
    width: min(var(--max-width), calc(100% - 48px));
    margin: 0 auto;
    padding: 54px 0 72px;
}

.site-footer {
    border-top: 2px solid var(--ink);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    width: min(var(--max-width), calc(100% - 48px));
    margin: 0 auto;
    padding: 24px 0 32px;
    gap: 20px;
    color: var(--muted);
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

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

.section-kicker,
.article-kicker,
.auth-kicker {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}

.section-title,
.admin-title,
.auth-title {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 3.55rem);
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 0.95;
}

.latest-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 2px solid var(--ink);
    border-left: 1px solid var(--ink);
}

.latest-card {
    display: flex;
    min-height: 365px;
    flex-direction: column;
    padding: 28px;
    border-right: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
    background: rgba(250, 249, 244, 0.33);
}

.card-icon {
    display: grid;
    width: 64px;
    height: 64px;
    margin-bottom: 42px;
    place-items: center;
    border: 1px solid var(--ink);
    border-radius: 50%;
}

.card-icon svg {
    width: 34px;
    height: 34px;
}

.card-meta,
.archive-meta,
.article-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.card-title {
    margin: 15px 0 12px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.35rem, 2.3vw, 1.8rem);
    line-height: 1.02;
}

.card-title a {
    text-decoration: none;
}

.card-title a:hover {
    text-decoration: underline;
}

.card-excerpt {
    margin: 0;
    color: #34322e;
    font-size: 0.95rem;
    line-height: 1.65;
}

.card-link {
    display: inline-block;
    width: fit-content;
    margin-top: auto;
    padding-top: 24px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
}

.card-link:hover {
    text-decoration: underline;
}

.archive-section {
    margin-top: 74px;
}

.archive-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 2px solid var(--ink);
}

.archive-item {
    display: grid;
    grid-template-columns: 75px minmax(0, 1fr) auto;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--soft-line);
    gap: 18px;
}

.archive-number {
    color: var(--muted);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.2rem;
}

.archive-copy {
    min-width: 0;
}

.archive-title {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    line-height: 1.15;
}

.archive-title a {
    text-decoration: none;
}

.archive-title a:hover {
    text-decoration: underline;
}

.archive-meta {
    white-space: nowrap;
}

.empty-state,
.archive-empty {
    margin: 0;
    padding: 28px;
    border: 1px solid var(--soft-line);
    color: var(--muted);
    background: rgba(250, 249, 244, 0.35);
    line-height: 1.7;
}

.article-page {
    width: min(820px, 100%);
    margin: 0 auto;
}

.article-header {
    padding-bottom: 31px;
    border-bottom: 2px solid var(--ink);
}

.article-author-line {
    margin: 0 0 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.article-page h1 {
    max-width: 800px;
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.5rem, 7vw, 5.4rem);
    font-weight: 700;
    letter-spacing: -0.06em;
    line-height: 0.89;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    margin-top: 27px;
    gap: 10px;
}

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

.article-content {
    padding-top: 44px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.08rem, 1.8vw, 1.22rem);
    line-height: 1.82;
}

.article-content > :first-child {
    margin-top: 0;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content pre,
.article-content table {
    margin: 0 0 1.5em;
}

.article-content h2,
.article-content h3,
.article-content h4 {
    margin: 2em 0 0.75em;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.article-content h2 {
    font-size: clamp(1.75rem, 3.2vw, 2.5rem);
}

.article-content h3 {
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
}

.article-content h4 {
    font-size: 1.2rem;
}

.article-content a {
    color: inherit;
    text-decoration-thickness: 1px;
}

.article-content blockquote {
    margin-left: 0;
    padding: 16px 24px;
    border-left: 3px solid var(--ink);
    background: rgba(17, 17, 15, 0.055);
    font-style: italic;
}

.article-content pre {
    overflow-x: auto;
    padding: 20px;
    color: var(--white);
    background: var(--black);
    font-family: "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.6;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.91rem;
}

.article-content th,
.article-content td {
    padding: 12px;
    border: 1px solid var(--soft-line);
    text-align: left;
    vertical-align: top;
}

.article-content th {
    background: rgba(17, 17, 15, 0.08);
}

.article-footer {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--soft-line);
}

.back-link {
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
}

.back-link:hover {
    text-decoration: underline;
}

.auth-wrap {
    display: grid;
    min-height: calc(100vh - 300px);
    place-items: center;
}

.auth-card {
    width: min(100%, 470px);
    padding: 36px;
    border: 2px solid var(--ink);
    background: rgba(250, 249, 244, 0.48);
}

.auth-note,
.admin-subtitle {
    margin: 16px 0 0;
    color: var(--muted);
    line-height: 1.65;
}

.stack-form {
    display: grid;
    margin-top: 29px;
    gap: 17px;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.field-hint {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--ink);
    border-radius: 0;
    outline: none;
    color: var(--ink);
    background: rgba(250, 249, 244, 0.58);
}

input[type="text"],
input[type="password"],
select {
    min-height: 47px;
    padding: 10px 12px;
}

textarea {
    min-height: 120px;
    padding: 12px;
    resize: vertical;
    line-height: 1.55;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px rgba(17, 17, 15, 0.14);
}

.editor-field {
    display: block;
}

.editor-tools {
    display: flex;
    flex-wrap: wrap;
    margin: 12px 0 0;
    gap: 7px;
}

.editor-tools button {
    padding: 8px 10px;
    border: 1px solid var(--ink);
    color: var(--ink);
    background: transparent;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.editor-tools button:hover {
    color: var(--white);
    background: var(--black);
}

.article-source {
    min-height: 380px;
    margin-top: 12px;
    font-family: "Courier New", monospace;
    font-size: 0.84rem;
}

.rich-editor {
    display: none;
    min-height: 380px;
    margin-top: 12px;
    padding: 18px;
    border: 1px solid var(--ink);
    outline: none;
    background: rgba(250, 249, 244, 0.58);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.7;
}

.rich-editor:focus {
    box-shadow: 0 0 0 2px rgba(17, 17, 15, 0.14);
}

.rich-editor:empty::before {
    color: var(--muted);
    content: "Введите текст материала";
    pointer-events: none;
}

.rich-editor h2,
.rich-editor h3 {
    font-family: Georgia, "Times New Roman", serif;
}

.rich-editor a {
    text-decoration-thickness: 1px;
}

.js .article-source {
    display: none;
}

.js .rich-editor {
    display: block;
}

.seo-fields {
    grid-column: 1 / -1;
    padding: 15px 0 0;
    border-top: 1px solid var(--soft-line);
}

.seo-fields summary {
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.seo-fields .form-grid {
    margin-top: 20px;
}

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

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border: 1px solid var(--ink);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

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

.button-dark:hover {
    color: var(--black);
    background: var(--white);
}

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

.button-light:hover {
    color: var(--white);
    background: var(--black);
}

.form-errors {
    margin: 0 0 22px;
    padding: 14px 18px;
    border: 1px solid var(--danger);
    color: var(--danger);
    background: rgba(77, 25, 25, 0.06);
}

.form-errors ul {
    margin: 0;
    padding-left: 18px;
}

.flash {
    margin-bottom: 22px;
    padding: 13px 16px;
    border: 1px solid var(--ink);
    font-size: 0.88rem;
}

.flash-success {
    border-color: var(--success);
    color: var(--success);
    background: rgba(31, 59, 42, 0.07);
}

.flash-error {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(77, 25, 25, 0.07);
}

.admin-shell {
    width: min(100%, 1080px);
    margin: 0 auto;
}

.admin-top {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 20px;
}

.admin-table-wrap {
    overflow-x: auto;
    border-top: 2px solid var(--ink);
}

.admin-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--soft-line);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.admin-article-title {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
    text-decoration: none;
}

.admin-article-title:hover {
    text-decoration: underline;
}

.admin-slug {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.72rem;
}

.status {
    display: inline-flex;
    padding: 5px 7px;
    border: 1px solid var(--ink);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.status-published {
    color: var(--white);
    background: var(--black);
}

.status-draft {
    color: var(--ink);
    background: transparent;
}

.inline-form {
    display: inline;
    margin: 0 0 0 9px;
}

.text-link {
    padding: 0;
    border: 0;
    color: var(--ink);
    background: transparent;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-transform: uppercase;
}

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

.danger-zone {
    margin-top: 36px;
    padding: 23px;
    border: 1px solid var(--danger);
    background: rgba(77, 25, 25, 0.04);
}

.danger-title {
    margin: 0 0 8px;
    color: var(--danger);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
}

.danger-zone p {
    margin: 0 0 17px;
    color: #623535;
}

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

.button-danger:hover {
    color: var(--danger);
    background: transparent;
}

.error-page {
    display: grid;
    min-height: calc(100vh - 320px);
    place-items: center;
    text-align: center;
}

.error-page > div {
    max-width: 550px;
}

.error-code {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.error-page h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.4rem, 7vw, 5rem);
    letter-spacing: -0.06em;
    line-height: 0.92;
}

.error-page p:not(.error-code) {
    margin: 20px 0 27px;
    color: var(--muted);
}

@media (max-width: 900px) {
    .latest-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .latest-card {
        min-height: 330px;
    }
}

@media (max-width: 680px) {
    .header-inner,
    .site-main,
    .footer-inner {
        width: min(100% - 32px, var(--max-width));
    }

    .header-inner {
        min-height: auto;
        flex-direction: column;
        align-items: flex-start;
        padding: 21px 0;
        gap: 15px;
    }

    .site-nav {
        width: 100%;
        flex-wrap: wrap;
        gap: 15px;
    }

    .site-main {
        padding-top: 38px;
    }

    .latest-grid {
        grid-template-columns: 1fr;
    }

    .latest-card {
        min-height: 280px;
        padding: 24px;
    }

    .card-icon {
        margin-bottom: 28px;
    }

    .archive-item {
        grid-template-columns: 45px minmax(0, 1fr);
        gap: 13px;
    }

    .archive-meta {
        grid-column: 2;
        white-space: normal;
    }

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

    .field-wide {
        grid-column: auto;
    }

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

    .article-content {
        padding-top: 32px;
    }

    .article-page h1 {
        font-size: clamp(2.5rem, 13vw, 4.1rem);
    }

    .footer-inner {
        flex-direction: column;
        gap: 8px;
    }

    .auth-card {
        padding: 26px 20px;
    }
}

@media (max-width: 420px) {
    .site-nav {
        font-size: 0.64rem;
    }

    .brand-main {
        font-size: 1.36rem;
    }

    .brand-sub {
        font-size: 0.53rem;
    }

    .section-title,
    .admin-title,
    .auth-title {
        font-size: 2rem;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
