:root {
    --bg: #eaf1f3;
    --card: #f6fafb;
    --primary: #2f6f7a;
    --text: #1e2e34;
    --muted: #5a7077;
    --danger: #a03a2c;
    --header-bg: #000080;
    --header-text: #ffffff;
    --chip-bg: rgba(255, 255, 255, 0.9);
    --chip-border: rgba(15, 47, 132, 0.22);
    --chip-active-bg: #000080;
    --chip-active-text: #ffffff;
    --surface-elev: rgba(255, 255, 255, 0.9);
    --radius-sm: 10px;
    --radius-md: 12px;
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 24px;
}

@font-face {
    font-family: "Kis Cyrillic";
    src: local("Kis Cyrillic"), local("KisCyrillic");
    font-display: swap;
}

html[data-theme="dark"] {
    --bg: #0f1720;
    --card: #16212c;
    --primary: #4e9fb0;
    --text: #e6edf3;
    --muted: #9fb0be;
    --danger: #f06a5b;
    --header-bg: #0a0f19;
    --header-text: #eef5ff;
    --chip-bg: rgba(21, 33, 46, 0.86);
    --chip-border: rgba(137, 170, 214, 0.26);
    --chip-active-bg: #1b3358;
    --chip-active-text: #f2f7ff;
    --surface-elev: rgba(18, 30, 43, 0.92);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
}

:focus-visible {
    outline: 2px solid #2b6fd9;
    outline-offset: 2px;
}

body {
    position: relative;
    margin: 0;
    font-family: "Kis Cyrillic", "Segoe UI", Tahoma, sans-serif;
    background: #eef2f5 url("/img/site-background.png") center top / 100% auto repeat-y;
    animation: backgroundFloat 28s ease-in-out infinite alternate;
    color: var(--text);
    overflow-x: hidden;
}

html[data-theme="dark"] body {
    background-image:
        linear-gradient(180deg, rgba(7, 13, 24, 0.72) 0%, rgba(10, 19, 34, 0.78) 100%),
        url("/img/site-background.png");
    background-color: #0f1720;
    background-position: center top, center top;
    background-size: 100% auto, 100% auto;
    background-repeat: no-repeat, repeat-y;
    background-blend-mode: multiply, normal;
    animation: backgroundFloat 28s ease-in-out infinite alternate;
}

@keyframes backgroundFloat {
    0% {
        background-position: 50% 0%;
        background-size: 100% auto;
    }
    100% {
        background-position: 50% 8%;
        background-size: 102% auto;
    }
}

body::before,
body::after {
    content: none;
}

body::before {
    background: none;
}

body::after {
    background: none;
    opacity: 0;
}

html[data-theme="dark"] body::after {
    opacity: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    position: sticky;
    top: 0;
    z-index: 1200;
    transition: box-shadow 220ms ease, background-color 220ms ease;
    overflow: hidden;
}

.header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(173, 214, 255, 0.12) 15%,
        rgba(255, 255, 255, 0.56) 50%,
        rgba(173, 214, 255, 0.12) 85%,
        transparent 100%
    );
    background-size: 220% 100%;
    animation: headerAurora 10s linear infinite;
}

@keyframes headerAurora {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 220% 0;
    }
}

.header.scrolled {
    box-shadow: 0 6px 16px rgba(6, 18, 52, 0.18);
}

.header h1 {
    margin: 0;
    font-size: clamp(22px, 3.2vw, 28px);
}

.header h1 .news-title-link {
    color: var(--header-text);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d7e1f6;
    box-shadow: 0 3px 10px rgba(17, 32, 63, 0.1);
    background: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
}

.header-section {
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid rgba(255, 255, 255, 0.26);
}

.header-rubrics {
    min-width: 0;
    max-width: none;
    flex: 1;
}

.header-rubrics .rubric-nav {
    margin: 0;
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
    padding-bottom: 0;
}

.header-rubrics .rubric-chip {
    flex: 0 1 auto;
    box-shadow: none;
    padding: 6px 12px;
    font-size: 14px;
}

.mobile-rubric-controls,
.mobile-rubrics-panel {
    display: none;
}

.header-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-elev);
    border: 1px solid rgba(112, 139, 156, 0.26);
    border-radius: 999px;
    padding: 3px 3px 3px 10px;
    box-shadow: 0 6px 14px rgba(20, 46, 53, 0.12);
}

.header-search-input {
    width: min(180px, 30vw);
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: inherit;
    outline: none;
}

.header-search-input::placeholder {
    color: var(--muted);
}

.header-search-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #1f4ab8;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(31, 74, 184, 0.28);
}

.header-search-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    background: #ffffff;
    color: #0f2f84;
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 3000;
}

.skip-link:focus {
    left: 8px;
}

.news-list {
    display: grid;
    gap: 16px;
}

.news-list-main {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 980px) {
    .news-list-main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .news-list-main {
        grid-template-columns: 1fr;
    }
}

.rubric-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.rubric-chip {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--chip-border);
    border-radius: 999px;
    color: #0f2f84;
    text-decoration: none;
    background: var(--chip-bg);
    box-shadow: 0 4px 10px rgba(15, 47, 132, 0.08);
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, color 180ms ease;
}

html[data-theme="dark"] .rubric-chip {
    color: #d7e6ff;
}

html[data-theme="dark"] .header-search-btn {
    background: #294f9e;
    box-shadow: 0 4px 12px rgba(25, 56, 118, 0.34);
}

.rubric-chip.active {
    background: var(--chip-active-bg);
    color: var(--chip-active-text);
    border-color: var(--chip-active-bg);
    box-shadow: 0 8px 16px rgba(0, 0, 128, 0.22);
}

.rubric-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(15, 47, 132, 0.14);
}

.home-section + .home-section {
    margin-top: 24px;
}

.section-title {
    margin: 0 0 12px 0;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.02em;
}

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

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

.feed-list {
    display: grid;
    gap: 8px;
}

.feed-item {
    padding: 12px;
}

.feed-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.feed-item .news-card-link {
    z-index: 5;
}

.feed-item-text {
    min-width: 0;
}

.feed-item h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
}

.feed-thumb {
    width: 102px;
    height: 102px;
    min-width: 102px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #d9e3ff;
}

.feed-subtitle {
    margin: 0 0 6px 0;
    color: var(--muted);
}

.news-admin-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-news-card {
    width: 260px;
    padding: 12px;
}

.admin-news-card .news-image {
    height: 110px;
    margin-bottom: 8px;
}

.news-card {
    background:
        radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.54) 0%, rgba(255, 255, 255, 0) 55%),
        var(--card);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(27, 57, 66, 0.16);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.75) inset,
        0 1px 0 rgba(9, 24, 29, 0.08),
        0 12px 26px rgba(19, 45, 53, 0.14);
    position: relative;
    overflow: hidden;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.news-card::before {
    content: "";
    position: absolute;
    left: -65%;
    top: -110%;
    width: 55%;
    height: 320%;
    transform: rotate(20deg);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    opacity: 0;
    transition: transform 420ms ease, opacity 220ms ease;
    pointer-events: none;
    z-index: 1;
}

html[data-theme="dark"] .news-card {
    background: var(--card);
    border-color: rgba(132, 161, 190, 0.24);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.06) inset,
        0 1px 0 rgba(0, 0, 0, 0.18),
        0 12px 26px rgba(0, 0, 0, 0.3);
}

.news-card:hover {
    transform: translateY(-1px);
    border-color: rgba(17, 60, 72, 0.3);
    box-shadow: 0 8px 16px rgba(15, 47, 132, 0.14);
}

.news-card:hover::before {
    opacity: 1;
    transform: translateX(245%) rotate(20deg);
}

.news-card-square {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.news-list .news-card {
    container-type: inline-size;
}

.news-card h2 {
    margin: 0 0 10px 0;
    font-size: clamp(18px, 8cqi, 28px);
}

.news-card > * {
    position: relative;
    z-index: 2;
}

.news-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 12px;
}

.news-title-link {
    color: inherit;
    text-decoration: none;
}

.news-title-link:hover {
    text-decoration: underline;
}

.header h1 .news-title-link:hover {
    text-decoration: none;
}

.news-media-link {
    display: block;
}

.news-subtitle {
    margin: 0 0 10px 0;
    color: var(--muted);
    font-size: clamp(14px, 4.8cqi, 18px);
    font-weight: 500;
}

.news-card p {
    margin: 0 0 12px 0;
    overflow: hidden;
    font-size: clamp(13px, 4.2cqi, 17px);
}

.news-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 8px 18px rgba(14, 35, 42, 0.16);
}

.news-image-large {
    height: 320px;
}

.news-card time {
    color: var(--muted);
    font-size: clamp(12px, 3.6cqi, 14px);
    margin-top: auto;
}

.news-card form,
.news-card .btn {
    position: relative;
    z-index: 3;
}

.news-delete-form {
    margin-top: 0;
}

.news-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 6;
}

.admin-news-card .news-card-link {
    pointer-events: none;
}

.admin-form-actions {
    display: flex;
    gap: 8px;
}

.top-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-position-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 6px;
}

.top-slot-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(15, 47, 132, 0.24);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--surface-elev);
}

.top-slot-option span {
    font-size: 14px;
}

.news-form select {
    width: 100%;
    border: 1px solid #c8d3f7;
    border-radius: 8px;
    padding: 10px;
    font: inherit;
    background: #fff;
}

.news-card-link:focus-visible {
    outline: 2px solid #0f2f84;
    outline-offset: -2px;
}

.news-details-card {
    max-width: 760px;
    margin: 0 auto;
}

.news-content-full {
    overflow: visible;
    line-height: 1.5;
    text-transform: none;
}

.news-content-full * {
    text-transform: none;
}

.news-content-full table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.news-content-full td,
.news-content-full th {
    border: 1px solid #c8d3f7;
    padding: 6px 8px;
}

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

.editor-toolbar button {
    border: 1px solid #c8d3f7;
    background: #f7f9ff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font: inherit;
}

.html-editor {
    min-height: 180px;
    border: 1px solid #c8d3f7;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.html-editor:focus {
    outline: 2px solid #1f4ab8;
    outline-offset: 1px;
}

.news-form {
    display: grid;
    gap: 10px;
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(19, 45, 53, 0.14);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.85) inset,
        0 10px 24px rgba(16, 40, 48, 0.14);
}

.news-form input,
.news-form textarea {
    width: 100%;
    border: 1px solid #c8d3f7;
    border-radius: 8px;
    padding: 10px;
    font: inherit;
}

.admin-page .news-form input,
.admin-page .news-form textarea,
.admin-page .news-form select,
.admin-page .html-editor {
    direction: ltr;
    unicode-bidi: normal;
    text-align: left;
    writing-mode: horizontal-tb;
}

.admin-page #contentEditor,
.admin-page #content {
    direction: ltr !important;
    unicode-bidi: normal !important;
    text-align: left !important;
    writing-mode: horizontal-tb !important;
}

.empty-state {
    display: grid;
    gap: 10px;
    justify-items: start;
}

.news-form input[type="file"] {
    padding: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    padding: 0 14px;
    min-width: 128px;
    height: 38px;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.28) inset,
        0 8px 18px rgba(18, 44, 52, 0.2);
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.3) inset,
        0 12px 22px rgba(18, 44, 52, 0.24);
    filter: saturate(1.04);
}

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

.btn-light {
    background: var(--surface-elev);
    color: #0f2f84;
}

html[data-theme="dark"] .btn-light {
    color: #cfe0ff;
    border: 1px solid rgba(141, 168, 204, 0.24);
}

.btn-login-highlight {
    background: #0f2f84;
    box-shadow: 0 0 0 2px #c8d3f7 inset, 0 6px 18px rgba(15, 47, 132, 0.24);
}

.btn-publish-highlight {
    background: #0b7a3a;
    box-shadow: 0 0 0 2px #c8f1da inset, 0 6px 18px rgba(11, 122, 58, 0.24);
}

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

.social-float {
    position: fixed;
    left: 16px;
    bottom: 82px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1100;
}

.site-counters {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1110;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.counter-item {
    font-size: 11px;
    line-height: 1.2;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(15, 47, 132, 0.14);
    color: #2a3e5e;
    border-radius: 999px;
    padding: 3px 8px;
    backdrop-filter: blur(3px);
}

html[data-theme="dark"] .counter-item {
    background: rgba(16, 24, 36, 0.82);
    color: #d8e6ff;
    border-color: rgba(149, 176, 219, 0.28);
}

.counter-item a {
    color: inherit;
    text-decoration: none;
}

.social-float-link {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.18) inset,
        0 12px 20px rgba(10, 28, 34, 0.24);
}

.social-float-link svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.social-float-link-dzen {
    background: #111111;
}

.social-float-link-telegram {
    background: #229ed9;
}

.social-float-link:hover {
    transform: translateY(-2px);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.22) inset,
        0 14px 22px rgba(10, 28, 34, 0.28);
}

.theme-toggle {
    min-width: 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.theme-toggle:hover {
    background: transparent;
}

html[data-theme="dark"] .theme-toggle {
    color: #ffffff;
    background: transparent;
    border-color: transparent;
}

.theme-toggle .theme-icon {
    width: 22px;
    height: 22px;
    display: block;
    fill: #ffffff;
}

.site-footer {
    border-top: 1px solid rgba(17, 45, 84, 0.14);
    margin-top: 24px;
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: blur(2px);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding-top: 12px;
    padding-bottom: 12px;
}

.footer-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

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

.reveal-on-scroll {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 380ms ease, transform 380ms ease;
}

.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
    .soft-cursor,
    .soft-cursor-ring {
        position: fixed;
        top: 0;
        left: 0;
        pointer-events: none;
        opacity: 0;
        z-index: 9999;
        transition: opacity 180ms ease;
    }

    .soft-cursor {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(15, 47, 132, 0.75);
        transform: translate(-50%, -50%);
    }

    .soft-cursor-ring {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: 1px solid rgba(31, 74, 184, 0.4);
        background: rgba(31, 74, 184, 0.12);
        box-shadow: 0 0 22px rgba(31, 74, 184, 0.18);
        transform: translate(-50%, -50%);
    }

    .soft-cursor.visible,
    .soft-cursor-ring.visible {
        opacity: 1;
    }
}

@media (max-width: 760px) {
    .header {
        padding: 8px 12px;
        align-items: center;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-section {
        border-left: 0;
        padding-left: 0;
        margin-left: 0;
    }

    .header-brand {
        width: auto;
        justify-content: flex-start;
    }

    .site-logo {
        width: 42px;
        height: 42px;
    }

    .desktop-rubrics {
        display: none;
    }

    .mobile-rubric-controls {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        order: 1;
    }

    .mobile-rubric-controls .rubric-chip {
        padding: 6px 12px;
        font-size: 14px;
    }

    .mobile-rubrics-btn {
        cursor: pointer;
        border: 1px solid var(--chip-border);
    }

    .mobile-rubrics-panel {
        display: none;
        width: 100%;
        order: 2;
        margin-top: 2px;
    }

    .mobile-rubrics-panel.open {
        display: block;
    }

    .mobile-rubrics-panel .rubric-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        gap: 8px;
        padding-bottom: 4px;
        margin: 0;
    }

    .mobile-rubrics-panel .rubric-chip {
        flex: 0 0 auto;
    }

    .header-search {
        order: 3;
        min-width: 0;
        flex: 1 1 180px;
    }

    .header-search-input {
        width: 100%;
        min-width: 0;
    }

    .theme-toggle {
        order: 4;
        margin-left: auto;
    }

    .rubric-nav,
    .header-rubrics .rubric-nav {
        overflow: visible;
        flex-wrap: wrap;
        white-space: normal;
        padding-bottom: 0;
    }

    .rubric-chip {
        flex: 0 1 auto;
    }

    .social-float {
        left: 12px;
        bottom: 74px;
    }

    .social-float-link {
        width: 44px;
        height: 44px;
    }

    .site-counters {
        right: 8px;
        bottom: 8px;
    }
}

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

    .reveal-on-scroll,
    .reveal-on-scroll.is-visible,
    .news-card,
    .news-card::before,
    .btn,
    .rubric-chip {
        transition: none;
        transform: none;
        opacity: 1;
    }

    .header::after {
        animation: none;
    }

    body,
    html[data-theme="dark"] body {
        animation: none;
        background-position: center top;
        background-size: 100% auto;
        background-repeat: repeat-y;
    }
}
