html[data-theme="dark"] {
    --page-bg: #151d14;
    --page-surface: #1b241a;
    --page-surface-strong: #131912;
    --page-line: rgba(215, 228, 198, 0.12);
    --page-text: #edf2e2;
    --page-muted: #b4c0aa;
    --page-accent: #8cab63;
    --page-accent-strong: #6f8f49;
    --page-panel: rgba(255, 255, 255, 0.04);
    --page-button-text: #10160d;
    --page-shadow: rgba(10, 15, 9, 0.32);
}

html[data-theme="light"] {
    --page-bg: #ebe1c7;
    --page-surface: rgba(255, 255, 255, 0.34);
    --page-surface-strong: #f4ebd7;
    --page-line: rgba(88, 73, 45, 0.14);
    --page-text: #2f2a1d;
    --page-muted: #5d523f;
    --page-accent: #6c844a;
    --page-accent-strong: #547038;
    --page-panel: rgba(255, 255, 255, 0.24);
    --page-button-text: #ffffff;
    --page-shadow: rgba(28, 34, 18, 0.14);
}

body {
    background: radial-gradient(circle at top right, rgba(240, 205, 132, 0.22) 0%, rgba(240, 205, 132, 0.14) 16%, rgba(240, 205, 132, 0.06) 32%, transparent 50%), var(--page-bg) !important;
    color: var(--page-text) !important;
    transition: background 0.25s ease, color 0.25s ease;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.page,
.main {
    padding-top: 14px !important;
    padding-bottom: 22px !important;
}

.hero {
    gap: 20px !important;
}

.copy {
    gap: 12px !important;
}

.actions,
.topic-grid,
.faq {
    margin-top: 14px !important;
}

h1,
h2,
h3,
p,
li,
.list,
.footnote,
.topic-card span,
.faq-item p,
.site-footer,
.footer,
.ad-slot-label,
.ad-slot-body {
    color: inherit;
}

.topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.topbar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sr-only,
.translate-anchor {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.language-select,
.theme-toggle {
    border: 1px solid var(--page-line);
    background: color-mix(in srgb, var(--page-surface-strong) 88%, transparent);
    color: var(--page-text);
}

.language-select {
    width: auto;
    min-width: 210px;
    max-width: min(52vw, 280px);
    padding: 12px 40px 12px 13px;
    border-radius: 14px;
    font: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23665942' d='M1.4 1.2a1 1 0 0 1 1.4 0L6 4.38 9.2 1.2a1 1 0 1 1 1.4 1.42l-3.9 3.86a1 1 0 0 1-1.4 0L1.4 2.62a1 1 0 0 1 0-1.42Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 8px;
}

.language-select.language-select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.language-picker {
    position: relative;
    width: auto;
    min-width: 210px;
    max-width: min(52vw, 280px);
}

.language-picker-trigger {
    width: 100%;
    min-height: 48px;
    padding: 12px 13px;
    border-radius: 14px;
    border: 1px solid var(--page-line);
    background: color-mix(in srgb, var(--page-surface-strong) 88%, transparent);
    color: var(--page-text);
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.language-picker-trigger-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.language-picker-code {
    font-weight: 760;
    letter-spacing: .08em;
}

.language-picker-flag,
.language-picker-option-flag {
    font-size: 1.1rem;
    line-height: 1;
}

.language-picker-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.language-picker-caret svg {
    width: 12px;
    height: 8px;
    display: block;
    fill: #665942;
}

html[data-theme="dark"] .language-picker-caret svg {
    fill: #edf2e2;
}

.language-picker-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 20;
    max-height: min(360px, 60vh);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--page-line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--page-surface-strong) 96%, transparent);
    box-shadow: 0 18px 30px var(--page-shadow);
}

.language-picker-option {
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--page-text);
    font: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
    cursor: pointer;
}

.language-picker-option:hover,
.language-picker-option:focus-visible,
.language-picker-option.is-selected {
    background: color-mix(in srgb, var(--page-accent) 12%, transparent);
    outline: none;
}

.language-picker-option-label {
    min-width: 0;
}

html[data-theme="dark"] .language-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23edf2e2' d='M1.4 1.2a1 1 0 0 1 1.4 0L6 4.38 9.2 1.2a1 1 0 1 1 1.4 1.42l-3.9 3.86a1 1 0 0 1-1.4 0L1.4 2.62a1 1 0 0 1 0-1.42Z'/%3E%3C/svg%3E");
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.home-link {
    text-decoration: none;
}

.theme-toggle:hover {
    transform: translateY(-1px);
}

.theme-toggle:focus-visible,
.language-select:focus-visible,
.home-link:focus-visible {
    outline: 2px solid var(--page-accent);
    outline-offset: 3px;
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    display: block;
}

.theme-toggle .sun {
    display: none;
}

html[data-theme="light"] .theme-toggle .sun {
    display: block;
}

html[data-theme="light"] .theme-toggle .moon {
    display: none;
}

.badge {
    background: color-mix(in srgb, var(--page-accent) 16%, transparent) !important;
    border-color: color-mix(in srgb, var(--page-accent) 28%, transparent) !important;
    color: var(--page-text) !important;
}

.section,
.box,
.ad-slot,
.site-footer,
.footer {
    margin-top: 18px !important;
}

.section,
.box {
    padding: 18px !important;
}

.footnote {
    margin-top: 12px !important;
}

.box,
.section,
.topic-card,
.faq-item,
.ad-slot,
.secondary,
.site-footer,
.footer {
    background: color-mix(in srgb, var(--page-surface) 90%, transparent) !important;
    border-color: var(--page-line) !important;
}

.site-footer,
.footer {
    color: var(--page-muted) !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    row-gap: 10px !important;
    margin-top: 34px !important;
    padding: 16px 18px !important;
    border: 1px solid var(--page-line) !important;
    border-radius: 18px !important;
    min-height: 64px;
}

.site-footer-links,
.footer-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.site-footer > div:first-child,
.footer > div:first-child {
    min-width: 0;
}

.section h2,
.box h2 {
    margin-bottom: 10px !important;
}

.list,
.footnote,
.topic-card span,
.ad-slot-label,
.ad-slot-body {
    color: var(--page-muted) !important;
}

.secondary {
    color: var(--page-text) !important;
}

.cta {
    background: linear-gradient(135deg, var(--page-accent), var(--page-accent-strong)) !important;
    color: var(--page-button-text) !important;
}

.site-footer a,
.footer a,
.topic-card strong {
    color: var(--page-accent-strong) !important;
}

.art {
    box-shadow: 0 18px 34px var(--page-shadow) !important;
}

@media (max-width: 640px) {
    body {
        padding: 14px !important;
    }

    .page,
    .main {
        padding-top: 8px !important;
        padding-bottom: 16px !important;
    }

    .topbar {
        justify-content: stretch;
        margin-bottom: 12px;
    }

    .topbar-controls {
        width: 100%;
        align-items: stretch;
    }

    .language-select {
        min-width: 0;
        max-width: none;
        flex: 1 1 220px;
    }

    .language-picker {
        min-width: 0;
        max-width: none;
        flex: 1 1 220px;
    }

    .theme-toggle,
    .home-link {
        flex: 0 0 48px;
    }

    .ad-slot-body {
        min-height: 72px;
    }

    .hero {
        gap: 16px !important;
    }

    .copy {
        gap: 10px !important;
    }

    .actions {
        gap: 10px !important;
    }

    .actions > * {
        width: 100%;
        justify-content: center;
    }

    .cta,
    .secondary,
    .button {
        width: 100%;
    }

    .list,
    .topic-grid,
    .faq {
        margin-top: 12px !important;
    }

    .section,
    .box {
        padding: 16px !important;
    }

    .site-footer,
    .footer {
        padding: 14px 16px !important;
        justify-content: center !important;
        text-align: center;
        min-height: 0;
    }

    .site-footer-links,
    .footer-links {
        justify-content: center;
        width: 100%;
    }

    .site-footer > div:first-child,
    .footer > div:first-child {
        width: 100%;
    }
}

@media (max-width: 420px) {
    body {
        padding: 10px !important;
    }

    .section,
    .box,
    .ad-slot,
    .site-footer,
    .footer {
        margin-top: 14px !important;
    }

    .section,
    .box {
        padding: 14px !important;
    }

    .badge {
        font-size: 0.82rem !important;
    }

    h1 {
        font-size: clamp(1.8rem, 9vw, 2.4rem) !important;
    }

    .topbar-controls {
        gap: 8px;
    }

    .language-select {
        padding: 11px 36px 11px 12px;
        font-size: 0.95rem;
    }

    .theme-toggle {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
    }

    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
}
