:root {
    color-scheme: light dark;
    --container: 1180px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --text: #111827;
    --muted: #64748b;
    --border: rgba(15, 23, 42, .12);
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .12);
    --shadow: 0 20px 45px rgba(15, 23, 42, .08);
    --header-h: 76px;
}

[data-theme="dark"] {
    --bg: #0b1020;
    --surface: #111827;
    --surface-2: #1f2937;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, .18);
    --primary: #60a5fa;
    --primary-strong: #3b82f6;
    --primary-soft: rgba(96, 165, 250, .16);
    --shadow: 0 20px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-width: 320px;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--primary-soft), transparent 36rem),
        var(--bg);
}

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

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

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

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

.container {
    width: min(100% - 32px, var(--container));
    margin-inline: auto;
}

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

.skip-link:focus {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--header-h);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.header__inner {
    display: grid;
    grid-template-columns: auto 1fr minmax(220px, 320px) auto;
    gap: 20px;
    align-items: center;
    min-height: var(--header-h);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: -.03em;
}

.logo__image { border-radius: 12px; }

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav__link {
    padding: 10px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 650;
}

.nav__link:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.header__burger {
    display: none;
    width: 42px;
    height: 42px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
}

.header__burger span:not(.sr-only) {
    display: block;
    height: 2px;
    margin: 5px 0;
    background: currentColor;
    border-radius: 99px;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
}

.search__input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.search__button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.hero {
    padding: 64px 0 32px;
}

.hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, .7fr);
    gap: 28px;
    align-items: stretch;
}

.hero__content,
.hero__card,
.card,
.widget {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow);
}

.hero__content {
    padding: clamp(28px, 6vw, 56px);
    border-radius: var(--radius-lg);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.hero__title {
    margin: 0;
    max-width: 820px;
    font-size: clamp(34px, 7vw, 72px);
    line-height: .96;
    letter-spacing: -.065em;
}

.hero__text {
    max-width: 650px;
    margin: 22px 0 0;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 20px);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.hero__card {
    display: grid;
    align-content: end;
    min-height: 320px;
    padding: 28px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(145deg, var(--primary-soft), transparent),
        var(--surface);
}

.hero__badge {
    display: inline-flex;
    width: max-content;
    margin-bottom: auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.hero__card strong {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1;
    letter-spacing: -.04em;
}

.hero__card small {
    margin-top: 10px;
    color: var(--muted);
}

.button,
.bb-editor .bbcodes,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}

.button:hover,
.bb-editor .bbcodes:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
}

.button--primary,
input[type="submit"] {
    background: var(--primary);
    color: #fff;
}

.button--primary:hover,
input[type="submit"]:hover {
    background: var(--primary-strong);
    color: #fff;
}

.button--ghost {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.main { padding: 32px 0 56px; }

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 28px;
    align-items: start;
}

.layout__content {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.sidebar-stack {
    display: grid;
    gap: 18px;
    position: sticky;
    top: calc(var(--header-h) + 18px);
}

.card,
.widget {
    border-radius: var(--radius-md);
}

.widget {
    padding: 18px;
}

.widget__title,
.section-title {
    margin: 0 0 14px;
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: -.03em;
}

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

.widget__links a,
.tag-cloud a,
.full-article__tags a {
    display: inline-flex;
    margin: 4px 4px 4px 0;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 14px;
}

.widget__links a:hover,
.tag-cloud a:hover,
.full-article__tags a:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.article-card {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    overflow: hidden;
}

.article-card__media {
    display: block;
    min-height: 220px;
    background: var(--surface-2);
}

.article-card__media img {
    width: 100%;
    height: 100%;
    min-height: 220px;
    object-fit: cover;
}

.article-card__media--placeholder img {
    object-fit: contain;
    padding: 40px;
}

.article-card__body {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--muted);
    font-size: 13px;
}

.meta__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.article-card__title,
.featured-card__title,
.search-result__title {
    margin: 0;
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.12;
    letter-spacing: -.04em;
}

.article-card__excerpt,
.featured-card__text,
.search-result__text {
    color: var(--muted);
}

.article-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.read-more {
    color: var(--primary);
    font-weight: 800;
}

.full-article {
    display: grid;
    gap: 22px;
}

.full-article__header,
.full-article__content,
.full-article__footer,
.related,
.comments-section,
.static-page,
.tags-page,
.search-result,
.empty-state,
.add-comment {
    padding: clamp(20px, 4vw, 34px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.full-article__title,
.static-page__title,
.tags-page__title {
    margin: 8px 0 0;
    font-size: clamp(34px, 6vw, 56px);
    line-height: 1;
    letter-spacing: -.06em;
}

.full-article__cover {
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.full-article__cover img {
    display: block;
    width: 100%;
    max-height: 560px;
    object-fit: cover;
}

.content {
    overflow-wrap: anywhere;
}

.content h2,
.content h3,
.content h4 {
    line-height: 1.18;
    letter-spacing: -.035em;
}

.content p { margin: 0 0 1.1em; }

.content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.content blockquote {
    margin: 22px 0;
    padding: 18px 22px;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--primary-soft);
}

.content table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.content th,
.content td {
    padding: 12px;
    border: 1px solid var(--border);
}

.full-article__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

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

.comment {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.comment__avatar {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--surface-2);
}

.comment__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment__header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.comment__date {
    color: var(--muted);
    font-size: 13px;
}

.comment__text {
    margin-top: 8px;
}

.comment__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.add-comment {
    margin-top: 22px;
}

.add-comment__title { margin-top: 0; }

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.field__label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.field__control,
textarea,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: 0;
    background: var(--surface-2);
    color: var(--text);
}

textarea { min-height: 160px; resize: vertical; }

.field__control:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.captcha {
    display: grid;
    gap: 12px;
    margin: 14px 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.pagination__pages {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pagination a,
.pagination span,
.pagination__pages li {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 700;
}

.pagination a:hover,
.pagination span:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.breadcrumbs {
    color: var(--muted);
    font-size: 14px;
}

.breadcrumbs a { color: var(--primary); }

.theme-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 120;
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
}

[data-theme="dark"] .theme-toggle__icon--sun,
[data-theme="light"] .theme-toggle__icon--moon { display: none; }

.footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 28px;
    padding: 34px 0;
}

.footer__text {
    max-width: 520px;
    color: var(--muted);
}

.footer__nav {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.footer__bottom {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0 24px;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 980px) {
    .header__inner {
        grid-template-columns: auto auto 1fr;
    }

    .header__burger { display: inline-block; order: 2; }

    .nav {
        position: fixed;
        inset: var(--header-h) 16px auto 16px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .nav.is-open { display: flex; }

    .search { grid-column: 1 / -1; }

    .header__login { display: none; }

    .hero__inner,
    .layout,
    .footer__inner {
        grid-template-columns: 1fr;
    }

    .sidebar-stack { position: static; }
}

@media (max-width: 720px) {
    .container { width: min(100% - 24px, var(--container)); }

    .hero { padding-top: 34px; }

    .article-card {
        grid-template-columns: 1fr;
    }

    .article-card__media,
    .article-card__media img {
        min-height: 190px;
    }

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

    .full-article__footer,
    .article-card__footer,
    .footer__bottom {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
