/* Shared dark appearance layer. Page geometry remains owned by each page stylesheet. */
:root { color-scheme: light; }
html.article-theme-dark { color-scheme: dark; }

html.article-theme-dark {
    --theme-link: #ff7777;
    --theme-link-hover: #ff9999;
    --theme-control: #111827;
    --theme-soft: color-mix(in srgb, var(--accent) 15%, var(--surface));
}

html.article-theme-dark :is(
    .portal-home-hero,
    .portal-home-hero__chips span,
    .portal-sidebar .portal-section,
    .portal-card.card,
    .latest-item,
    .portal-home-region-strip,
    .portal-practical--priority,
    .practical-alert,
    .country-practical-alert,
    .country-practical-guide,
    .portal-home .portal-europe-focus__card,
    .portal-home .portal-followed-teaser,
    .portal-business__topic,
    .portal-discovery__links a,
    .portal-secondary-grid .portal-card,
    .tag-header,
    .tag-list-item,
    .tag-empty-tip,
    .practical-hub__hero,
    .practical-hub__countries a,
    .practical-card,
    .topic-card,
    .topic-article-card,
    .empty-state,
    .auth-card,
    .auth-tab,
    .auth-field input,
    .auth-action .btn,
    .hrj-sso-button,
    .user-profile,
    .user-page.user-assets,
    .user-center .uc-dashboard,
    .user-center .uc-card,
    .user-center .uc-assets-block,
    .user-center .uc-stat,
    .user-center .uc-item,
    .user-subnav .btn,
    .privacy-clear-summary div,
    .uc-empty-state,
    .mobile-bottom-nav,
    .pagination a,
    .pagination__jump input,
    .ui-sheet,
    .ui-sheet__close,
    .cookie-consent__banner,
    .cookie-consent__dialog,
    .cookie-consent__purpose
) {
    border-color: var(--border);
    background-color: var(--surface);
    color: var(--primary);
    box-shadow: none;
}

html.article-theme-dark :is(
    .portal-home-hero,
    .practical-hub__hero
) {
    background: linear-gradient(130deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface) 72%);
}

html.article-theme-dark :is(
    .portal-home-hero__desc,
    .portal-home-hero__chips span,
    .portal-sidebar .sidebar-list .meta,
    .latest-summary,
    .latest-meta,
    .portal-practical__alerts,
    .portal-practical__guides,
    .country-practical-alert span,
    .country-practical-guide > span,
    .country-practical-alert strong,
    .auth-subtitle,
    .auth-field-note,
    .auth-redirect-hint,
    .social-login-divider,
    .user-center .uc-section-copy,
    .user-center .uc-meta,
    .user-center .uc-muted,
    .user-page .meta,
    .user-page .page-info,
    .user-profile .status,
    .footer__description,
    .tag-list-meta,
    .tag-empty-tip__text
) {
    color: var(--muted);
}

html.article-theme-dark :is(
    .portal-home-hero__chips span,
    .portal-home .portal-hot .sidebar-list a,
    .latest-body h3 a,
    .portal-home .portal-europe-focus__card a,
    .portal-home .portal-discovery__links a,
    .portal-home .portal-business__topic,
    .country-practical-alert h3 a,
    .country-practical-guide h3 a,
    .tag-container a,
    .practical-hub__countries a,
    .auth-links a,
    .user-center a,
    .user-profile a,
    .user-page a,
    .pagination a,
    .topic-nav-entry a
) {
    color: var(--theme-link);
}

/* Match the homepage ranked-item selector so the dark link token wins the cascade. */
html.article-theme-dark .portal-home .portal-hot .sidebar-list li:not(.empty) > a {
    color: var(--theme-link);
}

html.article-theme-dark .portal-home .portal-hot .sidebar-list li:not(.empty) > a:hover,
html.article-theme-dark .portal-home .portal-hot .sidebar-list li:not(.empty) > a:focus-visible {
    color: var(--theme-link-hover);
}

html.article-theme-dark :is(
    .portal-home .portal-hot .sidebar-list a:hover,
    .latest-body h3 a:hover,
    .portal-home .portal-europe-focus__card a:hover,
    .tag-container a:hover,
    .auth-links a:hover,
    .user-center a:hover,
    .user-profile a:hover,
    .user-page a:hover,
    .pagination a:hover
) {
    color: var(--theme-link-hover);
}

html.article-theme-dark :is(
    .portal-home-hero__chips span,
    .portal-home-region-strip,
    .portal-practical--priority,
    .practical-alert,
    .country-practical-alert,
    .country-practical-guide,
    .portal-home .portal-europe-focus__card,
    .portal-home .portal-followed-teaser,
    .portal-business__topic,
    .portal-discovery__links a,
    .portal-card.card,
    .latest-item,
    .tag-header,
    .tag-list-item,
    .tag-empty-tip,
    .practical-card,
    .topic-card,
    .topic-article-card,
    .empty-state,
    .pagination,
    .user-center .uc-card,
    .user-center .uc-assets-block,
    .user-center .uc-stat,
    .user-center .uc-item,
    .user-profile,
    .user-page.user-assets,
    .auth-card,
    .auth-field input,
    .auth-tab,
    .hrj-sso-button
) {
    border-color: var(--border);
}

html.article-theme-dark :is(
    .portal-home-hero__chips span,
    .portal-home .portal-hot .sidebar-list li,
    .portal-main > .portal-latest .latest-item,
    .country-practical-alert,
    .country-practical-guide,
    .tag-list-item,
    .user-subnav,
    .privacy-section,
    .privacy-clear-summary div,
    .user-page .item,
    .pagination
) {
    border-color: var(--border);
}

html.article-theme-dark :is(
    .portal-home-region-strip__copy h2,
    .portal-home .portal-europe-focus__card h3,
    .portal-business__topic,
    .portal-discovery__links a,
    .country-practical-alert h3,
    .country-practical-guide h3,
    .tag-title,
    .tag-header h1,
    .practical-hub h1,
    .auth-title,
    .uc-section-title,
    .uc-title,
    .uc-stat-label,
    .user-subnav-title,
    .privacy-section h2,
    .uc-empty-state__title
) {
    color: var(--primary);
}

html.article-theme-dark :is(
    .portal-home-hero__chips span,
    .portal-home .portal-hot .sidebar-list a,
    .portal-home .portal-discovery__links a,
    .portal-home .portal-business__topic,
    .tag-container a,
    .practical-hub__countries a,
    .auth-links a,
    .user-center a,
    .user-profile a,
    .user-page a,
    .pagination a,
    .topic-nav-entry a
):focus-visible,
html.article-theme-dark [data-site-theme-toggle]:focus-visible,
html.article-theme-dark [data-site-theme-option]:focus-visible {
    outline-color: var(--theme-link-hover);
}

html.article-theme-dark :is(
    .auth-field input,
    .form-control,
    .form-select,
    .pagination__jump input,
    .user-profile input,
    .user-profile select,
    .user-profile textarea,
    .user-center input,
    .user-center select,
    .user-center textarea
) {
    border-color: var(--border);
    background: var(--theme-control);
    color: var(--primary);
}

html.article-theme-dark :is(input, textarea, select)::placeholder { color: var(--muted); opacity: 1; }

html.article-theme-dark :is(.auth-tab.is-active, .user-subnav .btn.active, .uc-empty-state__icon) {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    background: color-mix(in srgb, var(--accent) 18%, var(--surface));
    color: var(--theme-link);
}

html.article-theme-dark :is(.auth-message--error, .user-profile .error) {
    border-color: #7f1d1d;
    background: #3b1e26;
    color: #fecaca;
}

html.article-theme-dark :is(.auth-message--success, .user-profile .success) {
    border-color: #166534;
    background: #123524;
    color: #bbf7d0;
}

html.article-theme-dark :is(.uc-profile-nudge, .privacy-chip, .privacy-danger-btn) {
    border-color: #6b3038;
    background: #3a2229;
    color: #fecaca;
}

html.article-theme-dark .uc-theme-settings { margin-top: 16px; }
.uc-theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.uc-theme-option {
    display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--primary);
    text-align: left; cursor: pointer; font: inherit;
}
.uc-theme-option.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.uc-theme-option strong, .uc-theme-option small { display: block; }
.uc-theme-option strong { font-size: .9rem; }
.uc-theme-option small { margin-top: 3px; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.uc-theme-preview { display: grid; align-content: start; gap: 4px; flex: 0 0 58px; height: 42px; padding: 6px; border: 1px solid #d6dbe2; border-radius: 7px; background: #fff; }
.uc-theme-preview i { display: block; width: 75%; height: 4px; border-radius: 3px; background: #d7dce3; }
.uc-theme-preview i:first-child { width: 100%; background: #c81d25; }
.uc-theme-preview--dark { border-color: #374151; background: #111827; }
.uc-theme-preview--dark i { background: #526074; }
.uc-theme-preview--dark i:first-child { background: #ff7777; }
.uc-theme-preview--system { background: linear-gradient(90deg, #fff 50%, #111827 50%); }

.site-theme-toggle { border: 0; cursor: pointer; font: inherit; }
.site-theme-toggle > span[aria-hidden="true"] { font-size: 1.35rem; line-height: 1; }
.site-theme-toggle [hidden] { display: none !important; }

html.article-theme-dark .mobile-bottom-nav { border-color: var(--border); background: var(--surface); color: var(--primary); }
html.article-theme-dark .mobile-bottom-nav a[aria-current="page"] { color: var(--theme-link); }
html.article-theme-dark .cookie-consent__copy,
html.article-theme-dark .cookie-consent__dialog,
html.article-theme-dark .cookie-consent__purpose,
html.article-theme-dark .ui-sheet { color: var(--primary); }

/* Article warm background remains an article-only reading preference. */
html.article-theme-warm .article-page { background: #f6f0e5; }
html.article-theme-warm .article-container,
html.article-theme-warm .article-main,
html.article-theme-warm .content-text { background: #fffaf0; color: #3f352b; }
html.article-theme-dark .content-text blockquote {
    border-left-color: var(--accent);
    background: var(--surface);
    color: var(--primary);
}
html.article-theme-dark .content-text table,
html.article-theme-dark .content-text th,
html.article-theme-dark .content-text td {
    border-color: var(--border);
    color: var(--primary);
}
html.article-theme-dark .content-text th { background: var(--surface); }
html.article-theme-warm.article-theme-dark .article-page,
html.article-theme-warm.article-theme-dark .article-container,
html.article-theme-warm.article-theme-dark .article-main,
html.article-theme-warm.article-theme-dark .content-text {
    background: var(--bg);
    color: var(--primary);
}

@media (max-width: 700px) {
    .uc-theme-options { grid-template-columns: 1fr; gap: 8px; }
    .uc-theme-option { min-height: 64px; }
}
