:root {
    --bg: #f3f1eb;
    --surface: #fffdfa;
    --surface-2: #ece8de;
    --ink: #141414;
    --muted: #696b6e;
    --line: rgba(20, 20, 20, 0.12);
    --accent: #b61f2a;
    --accent-2: #006f73;
    --accent-3: #d6a12a;
    --good: #28764d;
    --shadow: 0 24px 70px rgba(20, 20, 20, 0.11);
    --radius: 8px;
    --max: 1240px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --bg: #10110f;
        --surface: #191a17;
        --surface-2: #23251f;
        --ink: #f5f1e8;
        --muted: #aaa79f;
        --line: rgba(245, 241, 232, 0.14);
        --accent: #ff5a64;
        --accent-2: #37b8b4;
        --accent-3: #f2c35a;
        --good: #5dca8c;
        --shadow: 0 28px 75px rgba(0, 0, 0, 0.42);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #10110f;
    --surface: #191a17;
    --surface-2: #23251f;
    --ink: #f5f1e8;
    --muted: #aaa79f;
    --line: rgba(245, 241, 232, 0.14);
    --accent: #ff5a64;
    --accent-2: #37b8b4;
    --accent-3: #f2c35a;
    --good: #5dca8c;
    --shadow: 0 28px 75px rgba(0, 0, 0, 0.42);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent-2), transparent 82%), transparent 34vw),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-2), transparent 32%), transparent 460px),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}

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

img {
    max-width: 100%;
}

.site-header,
.page-shell,
.site-footer {
    width: min(var(--max), calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 10px;
    z-index: 20;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface), transparent 8%);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.header-inner {
    display: grid;
    grid-template-columns: max-content minmax(260px, 1fr) max-content;
    gap: 16px;
    align-items: center;
    padding: 12px;
}

.brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--bg);
    font-weight: 900;
}

.brand-copy strong,
.brand-copy small {
    display: block;
}

.brand-copy small {
    max-width: 310px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-search {
    display: flex;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    overflow: hidden;
}

.quick-search input,
.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 12px 14px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.quick-search button,
.search-box button,
.button,
.theme-toggle {
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.quick-search button,
.search-box button,
.button--primary {
    background: var(--accent);
    color: #fff;
    padding: 11px 16px;
}

.theme-toggle,
.button--ghost {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 11px 14px;
}

.main-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 0 10px 10px;
    scrollbar-width: none;
}

.main-nav a {
    flex: 0 0 auto;
    padding: 9px 11px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
}

.main-nav a:hover,
.main-nav a.is-active {
    background: var(--ink);
    color: var(--bg);
}

.page-shell {
    padding: 28px 0 54px;
}

.hero-news {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    min-height: clamp(430px, 62vh, 680px);
    align-items: stretch;
}

.hero-news__main,
.hero-news__side,
.content-block,
.mini-widget,
.listing-hero,
.search-page,
.archive-month,
.article-header,
.article-image,
.article-quote {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero-news__main {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(28px, 5vw, 72px);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 84%), transparent 55%),
        linear-gradient(180deg, transparent, color-mix(in srgb, var(--surface), var(--bg) 14%)),
        var(--surface);
}

.hero-news__main h1,
.listing-hero h1,
.article-header h1,
.search-page h1 {
    max-width: 920px;
    margin: 10px 0 16px;
    font-size: clamp(38px, 7vw, 86px);
    line-height: 0.95;
}

.hero-news__main p,
.listing-hero p,
.article-header p,
.search-page p {
    max-width: 760px;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 22px);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 11px 16px;
}

.hero-news__side {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
    background:
        linear-gradient(160deg, color-mix(in srgb, var(--accent-2), transparent 74%), transparent),
        var(--surface);
}

.hero-news__side span,
.eyebrow,
.news-meta,
.article-meta,
.article-source,
.site-footer,
.mini-widget li span,
.weather-tile small,
.exchange-board small {
    color: var(--muted);
}

.hero-news__side strong {
    display: block;
    margin-top: 6px;
    font-size: 32px;
    line-height: 1;
}

.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    margin-top: 22px;
}

.home-layout__main,
.home-layout__side {
    display: grid;
    gap: 22px;
    align-content: start;
}

.home-layout__side {
    position: sticky;
    top: 132px;
}

.content-block,
.listing-hero,
.search-page {
    padding: clamp(18px, 3vw, 30px);
}

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

.section-title h2,
.mini-widget h3,
.archive-month h2 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.05;
}

.section-title a,
.mini-widget a,
.article-source a,
.footer-grid a {
    color: var(--accent);
    font-weight: 850;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

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

.card-grid--listing {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.news-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface), var(--surface-2) 25%);
    overflow: hidden;
}

.news-card__media {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--surface-2);
}

.news-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-card__body {
    padding: 16px;
}

.news-meta,
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    font-size: 12px;
    font-weight: 800;
}

.news-meta span,
.article-meta span {
    color: var(--accent-2);
}

.news-card h3 {
    margin: 10px 0 8px;
    font-size: 21px;
    line-height: 1.12;
}

.news-card p {
    margin: 0;
    color: var(--muted);
}

.news-card--row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
}

.news-card--row .news-card__media {
    aspect-ratio: auto;
    min-height: 100%;
}

.latest-list,
.day-picture,
.archive-list {
    display: grid;
    gap: 10px;
}

.day-picture a,
.archive-month a {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 14px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.day-picture a:first-child,
.archive-month a:first-of-type {
    border-top: 0;
}

.day-picture span,
.archive-month span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.region-tabs {
    display: grid;
    gap: 14px;
}

.region-tabs__rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.region-tabs__rail a {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.region-tabs__rail strong,
.region-tabs__rail span {
    display: block;
}

.region-tabs__rail span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.mini-widget {
    padding: 18px;
}

.mini-widget ul {
    display: grid;
    gap: 10px;
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.mini-widget li,
.weather-tile,
.exchange-board article {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.mini-widget li strong {
    color: var(--good);
}

.listing-hero,
.search-page {
    margin-bottom: 22px;
}

.listing-hero h1,
.search-page h1 {
    font-size: clamp(34px, 6vw, 72px);
}

.search-box {
    display: flex;
    max-width: 760px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    overflow: hidden;
}

.article-page {
    max-width: 960px;
    margin: 0 auto;
}

.article-header {
    padding: clamp(22px, 5vw, 54px);
}

.article-header h1 {
    font-size: clamp(38px, 6vw, 78px);
}

.article-source {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 20px;
}

.article-image {
    margin: 22px 0 0;
    overflow: hidden;
}

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

.article-image figcaption {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    color: var(--muted);
    font-size: 14px;
}

.article-image figcaption a {
    color: var(--accent);
    font-weight: 800;
}

.article-body {
    padding: clamp(24px, 5vw, 56px) 0 12px;
    font-size: clamp(18px, 2vw, 21px);
}

.article-body p,
.article-body ul,
.article-body ol {
    max-width: 760px;
    margin: 0 auto 22px;
}

.article-body a {
    color: var(--accent);
    font-weight: 850;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.article-body .article-inline-image {
    max-width: 760px;
    margin: 10px auto 28px;
}

.article-body .article-inline-image img {
    max-height: 460px;
}

.article-quote {
    max-width: 800px;
    margin: 20px auto;
    padding: 22px;
    border-left: 5px solid var(--accent-2);
}

.article-quote p {
    margin: 0;
    font-size: 22px;
    font-weight: 750;
}

.article-quote cite {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}

.related-news {
    max-width: var(--max);
    margin: 34px auto 0;
}

.weather-grid,
.exchange-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.weather-tile,
.exchange-board article {
    min-height: 112px;
    flex-direction: column;
}

.weather-tile span,
.exchange-board span {
    color: var(--muted);
}

.weather-tile strong,
.exchange-board strong {
    font-size: 24px;
}

.archive-month {
    padding: 20px;
    box-shadow: none;
}

.empty-state {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--surface-2);
}

.site-footer {
    padding: 0 0 34px;
}

.footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content max-content;
    gap: 24px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.footer-grid p {
    max-width: 520px;
    margin: 6px 0 0;
}

.footer-grid nav,
.footer-note {
    display: grid;
    gap: 8px;
}

.admin-telegram,
.admin-digest,
.digest-panels {
    display: grid;
    gap: 18px;
}

.status-pill {
    align-self: start;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent-2), transparent 84%);
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.status-pill--disabled {
    background: color-mix(in srgb, var(--accent), transparent 84%);
    color: var(--accent);
}

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

.admin-grid > section,
.telegram-queue {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.admin-grid dl {
    margin: 0;
}

.admin-grid dl div,
.queue-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.admin-grid dl div:first-child {
    border-top: 0;
}

.admin-grid dt {
    color: var(--muted);
}

.admin-grid dd {
    margin: 0;
    font-weight: 850;
}

.digest-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 16px;
}

.digest-facts div {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.digest-facts dt,
.digest-source-feed span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.digest-facts dd {
    margin: 6px 0 0;
    font-weight: 900;
}

.digest-chipset {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.digest-chipset span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 850;
}

.digest-generate-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 14px;
}

.digest-generate-form label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-weight: 750;
}

.digest-source-feed {
    display: grid;
    gap: 12px;
}

.digest-source-feed article {
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
}

.digest-source-feed article:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.digest-source-feed strong {
    display: block;
    margin-top: 4px;
    font-size: 19px;
    line-height: 1.15;
}

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

.source-checks {
    display: grid;
    gap: 10px;
}

.source-checks label {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    gap: 10px;
    align-items: center;
}

.source-checks small {
    color: var(--muted);
}

.queue-row button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
    padding: 8px 10px;
}

@media (max-width: 980px) {
    .header-inner,
    .hero-news,
    .home-layout {
        grid-template-columns: 1fr;
    }

    .home-layout__side {
        position: static;
    }

    .card-grid,
    .card-grid--important,
    .region-tabs__rail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

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

@media (max-width: 640px) {
    .site-header,
    .page-shell,
    .site-footer {
        width: min(100% - 20px, var(--max));
    }

    .site-header {
        top: 6px;
    }

    .brand-copy small {
        max-width: 210px;
    }

    .quick-search {
        order: 3;
    }

    .card-grid,
    .card-grid--important,
    .card-grid--listing,
    .region-tabs__rail {
        grid-template-columns: 1fr;
    }

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

    .day-picture a,
    .archive-month a {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .hero-news {
        min-height: auto;
    }

    .hero-news__main,
    .listing-hero,
    .search-page,
    .content-block,
    .article-header {
        padding: 20px;
    }

    .article-body {
        padding-left: 2px;
        padding-right: 2px;
    }

    .digest-facts {
        grid-template-columns: 1fr;
    }
}
