/* ============================================================
   AgNews Mini App — Telegram-native design
   Supports: Telegram theme vars, light/dark, responsive
   ============================================================ */

/* --- CSS Variables with Telegram fallbacks --- */
:root {
    --bg:            var(--tg-theme-bg-color, #ffffff);
    --text:          var(--tg-theme-text-color, #1a1a1a);
    --hint:          var(--tg-theme-hint-color, #8e8e93);
    --link:          var(--tg-theme-link-color, #007aff);
    --btn-bg:        var(--tg-theme-button-color, #007aff);
    --btn-text:      var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg:  var(--tg-theme-secondary-bg-color, #f2f2f7);
    --section-bg:    var(--tg-theme-section-bg-color, #ffffff);
    --section-header: var(--tg-theme-section-header-text-color, #8e8e93);
    --subtitle:      var(--tg-theme-subtitle-text-color, #8e8e93);
    --destructive:   var(--tg-theme-destructive-text-color, #ff3b30);
    --separator:     var(--tg-theme-section-separator-color, rgba(0,0,0,0.08));
    --header-bg:     var(--tg-theme-header-bg-color, #ffffff);

    --card-radius:   12px;
    --page-padding:  16px;
    --max-width:     1200px;
    --font-base:     16px;
    --font-family:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --safe-top:      env(safe-area-inset-top, 0px);
    --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

/* Dark theme manual fallback for non-Telegram */
@media (prefers-color-scheme: dark) {
    :root:not([data-tg-theme]) {
        --bg: #1c1c1e;
        --text: #f2f2f7;
        --hint: #98989d;
        --link: #0a84ff;
        --btn-bg: #0a84ff;
        --btn-text: #ffffff;
        --secondary-bg: #2c2c2e;
        --section-bg: #2c2c2e;
        --section-header: #98989d;
        --subtitle: #98989d;
        --separator: rgba(255,255,255,0.08);
        --header-bg: #1c1c1e;
    }
}

/* --- Font size modifiers (class on <html>) — задают --font-base для html { font-size }; все rem в проекте масштабируются пропорционально; medium = текущий базовый размер --- */
.font-small  { --font-base: 14px; }
.font-medium { --font-base: 16px; }
.font-large  { --font-base: 18px; }
.font-xlarge { --font-base: 20px; }

/* --- Text-only mode --- */
.text-only .news-card__image,
.text-only .article-full__image,
.text-only .inline-teaser__img {
    display: none !important;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-base);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body.app-body {
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--link);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================================
   App Container
   ============================================================ */
.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding-bottom: calc(var(--safe-bottom) + 16px);
}

/* ============================================================
   Header (non-Telegram fallback)
   ============================================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--separator);
    padding-top: var(--safe-top);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 var(--page-padding);
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--link);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.header-btn:active {
    background: var(--secondary-bg);
}

/* Hide header when inside Telegram */
body.is-telegram .no-tg-only {
    display: none !important;
}

/* ============================================================
   Web Push overlay (browser only)
   ============================================================ */
body.web-push-overlay-open {
    overflow: hidden;
}

.web-push-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.web-push-overlay[hidden] {
    display: none !important;
}

#pwaInstallOverlay {
    z-index: 10002;
}

.web-push-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.web-push-overlay__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 340px;
    padding: 20px 18px;
    border-radius: 16px;
    background: var(--bg);
    border: 1px solid var(--separator);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.web-push-overlay__question {
    margin: 0 0 18px;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
    text-align: center;
}

.web-push-overlay__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.web-push-overlay__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.05s;
}

.web-push-overlay__btn:active {
    transform: scale(0.98);
}

.web-push-overlay__btn--primary {
    background: var(--btn-bg);
    color: var(--btn-text);
}

.web-push-overlay__btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.web-push-overlay__btn--secondary {
    background: transparent;
    color: var(--hint);
    font-weight: 500;
    padding: 8px 16px;
}

.web-push-toast {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    max-width: min(420px, calc(100% - 32px));
    z-index: 10001;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(40, 40, 40, 0.94);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    animation: web-push-toast-in 0.25s ease-out;
}

.web-push-toast--out {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes web-push-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================================
   Category Tabs
   ============================================================ */
.category-tabs {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--bg);
    border-bottom: 1px solid var(--separator);
    padding-top: 4px;
}

body:not(.is-telegram) .category-tabs {
    top: 57px;
}

.tabs-scroll {
    display: flex;
    gap: 4px;
    padding: 8px var(--page-padding);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x mandatory;
}

.tabs-scroll::-webkit-scrollbar {
    display: none;
}

.tab {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text);
    background: var(--secondary-bg);
    transition: all 0.2s;
    scroll-snap-align: start;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.tab:hover {
    background: var(--secondary-bg);
    color: var(--text);
    opacity: 0.85;
}

.tab.active {
    background: var(--btn-bg);
    color: var(--btn-text);
}

/* ============================================================
   Feed / News Cards
   ============================================================ */
.feed {
    padding: 8px var(--page-padding);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.news-card {
    background: var(--section-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.news-card:active {
    transform: scale(0.985);
}

.news-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.news-card__image {
    position: relative;
    width: 100%;
    padding-top: 52%;
    overflow: hidden;
    background: var(--secondary-bg);
}

.news-card__image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.news-card__image.img-error img {
    opacity: 0;
}

.news-card__body {
    padding: 12px 16px 14px;
}

.news-card__category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--link);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.news-card__title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card__excerpt {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--subtitle);
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card__time {
    font-size: 0.75rem;
    color: var(--hint);
}

/* Spotlight — full width on mobile (first in flow); larger hero on wide layouts */
.news-card--spotlight .news-card__image {
    padding-top: 56%;
}

.news-card--spotlight .news-card__title {
    font-size: 1.125rem;
}

/* ============================================================
   Ad Teaser — looks like news card + optional label
   ============================================================ */
.ad-teaser {
    /* Visually identical to news card */
}

.news-card.ad-teaser .news-card__title {
    color: blue;
}

.ad-label {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0,0,0,0.45);
    color: #fff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}

/* To hide ad labels globally, uncomment: */
/* .ad-label { display: none !important; } */

/* ============================================================
   Inline Teaser (inside article content)
   ============================================================ */
.inline-teaser {
    margin: 24px -16px;
    background: var(--secondary-bg);
    border-radius: 0;
    overflow: hidden;
}

.inline-teaser__link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: inherit;
    text-decoration: none;
    position: relative;
}

.inline-teaser__img {
    width: 46%;
    min-width: 240px;
    max-width: 320px;
    height: 180px;
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 0;
    flex-shrink: 0;
}

.inline-teaser__title {
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.35;
    color: blue;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.inline-teaser .ad-label {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.5625rem;
}

@media (max-width: 767px) {
    .inline-teaser__link {
        display: block;
    }

    .inline-teaser__img {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        height: 200px;
        margin-bottom: 10px;
    }
}

/* ============================================================
   Article Page
   ============================================================ */
.article-page {
    padding-bottom: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.article-top-ad {
    padding: 8px var(--page-padding) 0;
}

.article-top-ad--grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    align-items: start;
}

.article-top-ad__item {
    min-width: 0;
}

/* Mobile: show 1 teaser above article */
.article-top-ad__item--2 {
    display: none;
}

/* Tablet: show 2 teasers above article */
@media (min-width: 768px) {
    .article-top-ad--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .article-top-ad__item--2 {
        display: block;
    }
}

/* Top teaser cards should be compact on wide screens */
.article-top-ad .news-card__image {
    padding-top: 42%;
}

.article-top-ad .news-card__body {
    padding: 10px 12px 12px;
}

.article-top-ad .news-card__title {
    font-size: 0.95rem;
    -webkit-line-clamp: 2;
}

.article-full {
    padding: 0 var(--page-padding);
}

.article-full__title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
    margin: 16px 0 10px;
}

.article-full__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8125rem;
    color: var(--hint);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.article-full__category {
    font-weight: 600;
    color: var(--link);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.article-full__views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.article-full__views svg {
    opacity: 0.6;
}

.article-full__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.article-tag {
    font-size: 0.8125rem;
    color: var(--link);
    background: var(--secondary-bg);
    padding: 3px 10px;
    border-radius: 12px;
}

.article-full__image {
    margin: 0 calc(-1 * var(--page-padding)) 20px;
    background: var(--secondary-bg);
}

.article-full__image img {
    width: 100%;
}

.article-full__content {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-full__content p {
    margin-bottom: 1em;
}

.article-full__content h2,
.article-full__content h3,
.article-full__content h4 {
    margin: 1.5em 0 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.article-full__content img {
    border-radius: 8px;
    margin: 1em 0;
}

.article-full__content blockquote {
    border-left: 3px solid var(--link);
    padding: 8px 16px;
    margin: 1em 0;
    color: var(--subtitle);
    background: var(--secondary-bg);
    border-radius: 0 8px 8px 0;
}

.article-full__content a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.article-full__content ul,
.article-full__content ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

/* Article paywall (browser): half content + Telegram CTA */
.article-paywall__visible {
    margin-bottom: 0;
}

.article-paywall__gate {
    margin: 20px 0;
}

.article-paywall__panel {
    padding: 18px 16px;
    border-radius: 14px;
    background: var(--secondary-bg);
    border: 1px solid var(--separator);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.article-paywall__option-text {
    margin: 0 0 12px;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--text);
}

.article-paywall__option-text--secondary {
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--subtitle);
}

.article-paywall__btn {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.article-paywall__btn--primary {
    background: var(--link);
    color: #fff;
}

/* .article-full__content a перебивает цвет — иначе синий текст на синей кнопке */
.article-full__content .article-paywall a.article-paywall__btn--primary,
.article-full__content .article-paywall a.article-paywall__btn--primary:visited {
    color: #fff;
    text-decoration: none;
}

.article-paywall__btn--primary:hover {
    filter: brightness(1.05);
}

.article-paywall__btn--secondary {
    background: var(--bg);
    color: var(--link);
    border: 2px solid var(--link);
}

.article-full__content .article-paywall .article-paywall__btn--secondary {
    text-decoration: none;
}

.article-paywall__btn--disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.article-paywall__blur-wrap {
    position: relative;
    max-height: 13rem;
    overflow: hidden;
    margin-top: 0;
    border-radius: 0 0 8px 8px;
}

.article-paywall__blur-wrap::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 72%;
    pointer-events: none;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        var(--bg, #fff) 88%
    );
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

@media (prefers-color-scheme: dark) {
    .article-paywall__blur-wrap::after {
        background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0%,
            var(--bg, #1c1c1e) 88%
        );
    }
}

.article-paywall--dismissed .article-paywall__gate {
    display: none;
}

.article-paywall--dismissed .article-paywall__blur-wrap {
    max-height: none;
    overflow: visible;
}

.article-paywall--dismissed .article-paywall__blur-wrap::after {
    display: none;
}

/* Telegram Mini App: пейволл статьи не показываем (ранний класс на html из layout) */
html.is-telegram-mini-app .article-paywall__gate {
    display: none !important;
}

html.is-telegram-mini-app .article-paywall__blur-wrap {
    max-height: none !important;
    overflow: visible !important;
}

html.is-telegram-mini-app .article-paywall__blur-wrap::after {
    display: none !important;
}

/* ============================================================
   Bottom Feed Section (under article)
   ============================================================ */
.bottom-feed-section {
    margin-top: 32px;
    border-top: 1px solid var(--separator);
    padding-top: 16px;
}

.bottom-feed-section__title {
    font-size: 1.125rem;
    font-weight: 600;
    padding: 0 var(--page-padding) 8px;
    color: var(--text);
}

/* ============================================================
   Feed Loader / Spinner
   ============================================================ */
.feed-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--hint);
    font-size: 0.875rem;
}

.feed-loader.hidden {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--separator);
    border-top-color: var(--link);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--hint);
}

.empty-state__icon {
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state__text {
    font-size: 1rem;
}

/* ============================================================
   Premium Banner
   ============================================================ */
.premium-banner {
    margin: 16px var(--page-padding) 8px;
    border-radius: var(--card-radius);
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.premium-banner__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}

.premium-banner__star {
    font-size: 1.125rem;
}

/* ============================================================
   Settings Page
   ============================================================ */
.settings-page {
    padding: 12px var(--page-padding) 32px;
}

.settings-section {
    margin-bottom: 28px;
}

.settings-section__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--section-header);
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.premium-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--link);
    background: var(--secondary-bg);
    padding: 3px 10px;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}

.premium-overlay-hint {
    padding: 8px 12px;
    margin-bottom: 12px;
    background: var(--secondary-bg);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--hint);
    text-align: center;
}

.settings-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--separator);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-item--locked {
    opacity: 0.5;
    pointer-events: none;
}

.settings-item__label {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text);
    flex-shrink: 0;
}

.settings-item__hint {
    width: 100%;
    font-size: 0.75rem;
    color: var(--hint);
    margin-top: 4px;
}

.settings-input {
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--secondary-bg);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 140px;
    max-width: 200px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.settings-input:focus {
    outline: 2px solid var(--link);
    outline-offset: -2px;
}

.settings-input--time {
    min-width: 90px;
    max-width: 110px;
    text-align: center;
}

.settings-time-range {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--hint);
}

/* Toggle switch */
.settings-toggle {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle__slider {
    position: absolute;
    inset: 0;
    background: var(--separator);
    border-radius: 31px;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-toggle__slider::before {
    content: '';
    position: absolute;
    left: 2px;
    bottom: 2px;
    width: 27px;
    height: 27px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.settings-toggle input:checked + .settings-toggle__slider {
    background: #34c759;
}

.settings-toggle input:checked + .settings-toggle__slider::before {
    transform: translateX(20px);
}

/* Checkbox list */
.settings-geo-list,
.settings-checklist {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.settings-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 4px 10px;
    background: var(--secondary-bg);
    border-radius: 8px;
    user-select: none;
    transition: background 0.15s;
}

.settings-checkbox input {
    accent-color: var(--link);
    width: 16px;
    height: 16px;
}

.settings-checkbox__label {
    color: var(--text);
}

.settings-save-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    border: none;
    border-radius: var(--card-radius);
    background: var(--btn-bg);
    color: var(--btn-text);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.settings-save-btn:active {
    opacity: 0.85;
}

.settings-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Premium Stars checkout: only in Telegram Mini App (see html.is-telegram-mini-app in layout head) */
.settings-premium-stars-btn {
    display: none;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
}

html.is-telegram-mini-app .settings-premium-stars-btn {
    display: block;
}

.settings-auth-hint {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.875rem;
    color: var(--hint);
    background: var(--secondary-bg);
    border-radius: var(--card-radius);
    margin-top: 16px;
}

/* ============================================================
   Error Page
   ============================================================ */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 64px 24px;
    min-height: 60vh;
}

.error-page__icon {
    color: var(--hint);
    margin-bottom: 16px;
    opacity: 0.4;
}

.error-page__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.error-page__message {
    font-size: 0.9375rem;
    color: var(--subtitle);
    margin-bottom: 24px;
    max-width: 360px;
}

.error-page__btn {
    display: inline-block;
    padding: 10px 24px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9375rem;
}

/* ============================================================
   Responsive — Desktop (> 768px)
   ============================================================ */
@media (min-width: 768px) {
    .feed {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px var(--page-padding);
    }

    .news-card__image {
        padding-top: 48%;
    }

    .news-card--spotlight {
        grid-column: span 2;
    }

    .news-card--spotlight .news-card__image {
        padding-top: 40%;
    }

    .news-card--spotlight .news-card__title {
        font-size: 1.35rem;
    }

    .inline-teaser {
        margin: 24px 0;
        border-radius: var(--card-radius);
    }

    .article-full__image {
        margin: 0 0 20px;
        border-radius: var(--card-radius);
        overflow: hidden;
    }

    .article-full__title {
        font-size: 1.75rem;
    }
}

@media (min-width: 1024px) {
    .feed {
        grid-template-columns: repeat(3, 1fr);
    }

    :root {
        --page-padding: 24px;
    }
}

/* ============================================================
   Responsive — Small screens (< 380px)
   ============================================================ */
@media (max-width: 380px) {
    :root {
        --page-padding: 12px;
    }

    .tab {
        padding: 5px 12px;
        font-size: 0.8125rem;
    }

    .article-full__title {
        font-size: 1.25rem;
    }
}

/* ============================================================
   Animations
   ============================================================ */
.news-card {
    animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for initial load */
.news-card:nth-child(1) { animation-delay: 0s; }
.news-card:nth-child(2) { animation-delay: 0.05s; }
.news-card:nth-child(3) { animation-delay: 0.1s; }
.news-card:nth-child(4) { animation-delay: 0.15s; }
.news-card:nth-child(5) { animation-delay: 0.2s; }
.news-card:nth-child(6) { animation-delay: 0.25s; }

/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .news-card {
        animation: none;
    }
}

/* ============================================================
   Scrollbar styling (desktop)
   ============================================================ */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 6px;
    }
    ::-webkit-scrollbar-track {
        background: transparent;
    }
    ::-webkit-scrollbar-thumb {
        background: var(--separator);
        border-radius: 3px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: var(--hint);
    }
}

/* ============================================================
   Utility: selection color
   ============================================================ */
::selection {
    background: var(--link);
    color: #fff;
}

/* Saved feedback */
.settings-save-btn.saved {
    background: #34c759;
}
