/* One theme control and one resolved palette for every customer-facing shell. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

.sitewide-theme-control {
    position: fixed;
    z-index: 2147481900;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
}

.sitewide-theme-control .theme-toggle {
    display: inline-flex;
    min-width: 48px;
    height: 48px;
    padding: 0 14px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid rgba(126, 135, 166, .28);
    border-radius: 999px;
    background: color-mix(in srgb, var(--briz-surface, #fff) 88%, transparent);
    box-shadow: 0 14px 38px rgba(9, 14, 31, .18);
    color: var(--briz-text, #11172c);
    cursor: pointer;
    backdrop-filter: blur(18px) saturate(145%);
    transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.sitewide-theme-control .theme-toggle::after {
    content: attr(data-theme-short-label);
    font: 780 11px/1 Inter, system-ui, sans-serif;
    text-transform: capitalize;
}

.sitewide-theme-control .theme-toggle:hover { transform: translateY(-2px); }
.sitewide-theme-control .theme-toggle:focus-visible { outline: 3px solid #6957df; outline-offset: 3px; }
.sitewide-theme-control .theme-toggle-icon {
    position: relative;
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.sitewide-theme-control [data-theme-choice="auto"] .theme-toggle-icon {
    background: linear-gradient(90deg, transparent 50%, currentColor 50%);
}

.sitewide-theme-control [data-theme-choice="light"] .theme-toggle-icon {
    border-width: 5px;
    box-shadow: 0 -7px 0 -5px currentColor, 0 7px 0 -5px currentColor,
        7px 0 0 -5px currentColor, -7px 0 0 -5px currentColor;
}

.sitewide-theme-control [data-theme-choice="dark"] .theme-toggle-icon {
    border: 0;
    background: currentColor;
}

.sitewide-theme-control [data-theme-choice="dark"] .theme-toggle-icon::after {
    position: absolute;
    top: -3px;
    left: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--briz-surface, #171c2d);
    content: "";
}

.sitewide-theme-control .theme-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Public homepage and content pages share the same dark surface tokens. */
html[data-theme="dark"] body.homepage-v3-page {
    --briz-page: #0d111d;
    --briz-surface: #171c2d;
    --briz-text: #f5f7ff;
    --hp3-ink: #f5f7ff;
    --hp3-muted: #aeb6cb;
    --hp3-paper: #0d111d;
    --hp3-surface: #171c2d;
    --hp3-indigo: #8f88ff;
    --hp3-indigo-dark: #aaa5ff;
    --hp3-line: rgba(218, 224, 244, .14);
    background: #0d111d;
    color: #f5f7ff;
}

html[data-theme="dark"] .homepage-v3-page .hp3-header { color: var(--hp3-ink); }
html[data-theme="dark"] .homepage-v3-page .hp3-header.is-scrolled,
html[data-theme="dark"] .homepage-v3-page .hp3-header:has(.hp-nav-links.is-open),
html[data-theme="dark"] .homepage-v3-page .hp3-header:has(.hp-nav-state:checked) {
    border-color: rgba(218, 224, 244, .1);
    background: rgba(13, 17, 29, .9);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .24);
}

html[data-theme="dark"] .homepage-v3-page .hp3-header .hp-nav-links a { color: #c2c9da; }
html[data-theme="dark"] .homepage-v3-page .hp3-header .hp-nav-links a:hover,
html[data-theme="dark"] .homepage-v3-page .hp3-header .hp-nav-links a:focus-visible { background: rgba(143, 136, 255, .14); color: #fff; }
html[data-theme="dark"] .homepage-v3-page .hp3-hero {
    background: linear-gradient(180deg, rgba(20, 25, 42, .96), rgba(13, 17, 29, .98)),
        radial-gradient(circle at 72% 18%, rgba(143, 136, 255, .2), transparent 36%);
}

html[data-theme="dark"] .homepage-v3-page :is(
    .hp3-trial-section, .hp3-faq, .hp3-pricing-section
) { background: #111625; }
html[data-theme="dark"] .homepage-v3-page :is(
    .hp3-showcase-section, .hp3-precision-section, .hp3-study-section,
    .hp3-audience-section, .hp3-clients-section, .hp3-branding-section
) { background: #0d111d; color: var(--hp3-ink); }

html[data-theme="dark"] .homepage-v3-page :is(
    .hp3-featured-card, .hp3-precision-card, .hp3-precision-card.is-ordinary,
    .hp3-plan, .hp3-plan.is-recommended, .hp3-trial-result, .hp3-trial-result.is-ready,
    .hp3-study-stats div, .hp3-study-visual, .hp3-audience-list li,
    .hp3-client-logos figure, .hp3-branding-demo figcaption, .hp3-precision-note,
    .hp3-sample-grid > button, .hp3-trial-dialog, .hp3-trial-dialog-compare,
    .hp3-trial-dialog-compare figcaption
) {
    border-color: var(--hp3-line);
    background: var(--hp3-surface);
    color: var(--hp3-ink);
}

html[data-theme="dark"] .homepage-v3-page :is(.hp3-dropzone, .hp3-billing-switch) {
    border-color: rgba(143, 136, 255, .32);
    background: #151b2b;
}
html[data-theme="dark"] .homepage-v3-page :is(.hp3-upload-icon, .hp3-sample-choice, .hp3-sample-choice button, .hp3-upload-progress, .hp3-plan-net) {
    border-color: var(--hp3-line);
    background: #1b2133;
    color: var(--hp3-ink);
}
html[data-theme="dark"] .homepage-v3-page .hp3-sample-dialog { background: #111625; }
html[data-theme="dark"] .homepage-v3-page .hp3-sample-dialog-head { border-color: var(--hp3-line); background: rgba(23, 28, 45, .95); }
html[data-theme="dark"] .homepage-v3-page .hp3-header .hp-nav-links { border-color: var(--hp3-line); background: rgba(23, 28, 45, .98); }
html[data-theme="dark"] .homepage-v3-page :is(.hp3-section-heading > p, .hp3-card-copy p, .hp3-study-copy > p, .hp3-branding-copy > p) { color: var(--hp3-muted); }
html[data-theme="dark"] .homepage-v3-page .hp3-branding-copy { color: var(--hp3-ink); }

/* Blog, manual, legal, privacy and contact use the same public shell. */
html[data-theme="dark"] body.public-content-v3-page { background: #0d111d; color: #f5f7ff; }
html[data-theme="dark"] .public-content-v3-page .content-v3-header { background: rgba(13, 17, 29, .92); box-shadow: 0 10px 32px rgba(0, 0, 0, .22); }
html[data-theme="dark"] .public-content-v3-page :is(.content-v3-hero, .content-v3-section-tint, .content-v3-cta, .legal-v3-body, .contact-v3-details, .contact-v3-cta) {
    background: #0d111d;
    color: #f5f7ff;
}
html[data-theme="dark"] .public-content-v3-page :is(
    .content-v3-hero-compare figcaption, .content-v3-jump, .content-v3-steps article,
    .content-v3-guide-grid article, .content-v3-featured-card, .content-v3-article-grid article,
    .content-v3-article-image, .content-v3-inline-compare, .content-v3-article-gallery figure,
    .content-v3-related > div > a, .legal-v3-switcher, .legal-v3-article,
    .contact-v3-detail-grid article, .contact-v3-company
) {
    border-color: rgba(218, 224, 244, .14);
    background: #171c2d;
    color: #f5f7ff;
}
html[data-theme="dark"] .public-content-v3-page :is(
    .content-v3-lead, .content-v3-section-head > p:last-child, .content-v3-steps p,
    .content-v3-guide-grid article > p:last-of-type, .content-v3-section-head ul,
    .content-v3-featured-card > div > span, .content-v3-article-grid article > div > p:last-of-type,
    .content-v3-article-body p, .content-v3-article-image figcaption,
    .content-v3-inline-compare figcaption, .content-v3-article-gallery figcaption,
    .legal-v3-article p, .contact-v3-help ul, .contact-v3-company span
) { color: #aeb6cb; }
html[data-theme="dark"] .public-content-v3-page :is(.legal-v3-article h2, .contact-v3-direct a, .contact-v3-company strong, .contact-v3-cta h2) { color: #f5f7ff; }
html[data-theme="dark"] .public-content-v3-page .content-v3-jump a:hover,
html[data-theme="dark"] .public-content-v3-page .legal-v3-switcher a:hover { background: rgba(143, 136, 255, .14); color: #fff; }

/* Authentication and account recovery pages retain their split layout. */
html[data-theme="dark"] body.briz-auth-page {
    --briz-surface: #171c2d;
    --briz-text: #f5f7ff;
    --auth-ink: #f5f7ff;
    --auth-muted: #aeb6cb;
    --auth-paper: #0d111d;
    --auth-line: rgba(218, 224, 244, .15);
    --auth-indigo: #8f88ff;
    --auth-indigo-dark: #aaa5ff;
    background: radial-gradient(circle at 8% 8%, rgba(47, 197, 177, .1), transparent 26rem),
        radial-gradient(circle at 92% 88%, rgba(143, 136, 255, .12), transparent 30rem), #0d111d;
    color: var(--auth-ink);
}
html[data-theme="dark"] .briz-auth-page .auth-v3-layout { border-color: var(--auth-line); background: #171c2d; }
html[data-theme="dark"] .briz-auth-page .auth-v3-panel { background: linear-gradient(180deg, #171c2d, #131827); }
html[data-theme="dark"] .briz-auth-page :is(.auth-v3-social-button, .auth-v3-field input:not([type="checkbox"]), .auth-v3-legal-dialog) {
    border-color: var(--auth-line);
    background: #101522;
    color: var(--auth-ink) !important;
}
html[data-theme="dark"] .briz-auth-page .auth-v3-field input:focus { background: #0d111d; }
html[data-theme="dark"] .briz-auth-page .auth-v3-field > span:first-child { color: #dce1ef; }
html[data-theme="dark"] .briz-auth-page .auth-v3-provider-icon { background: #22283a; }

@media (max-width: 620px) {
    .sitewide-theme-control { left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); }
    .sitewide-theme-control .theme-toggle { width: 46px; min-width: 46px; height: 46px; padding: 0; }
    .sitewide-theme-control .theme-toggle::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sitewide-theme-control .theme-toggle { transition: none; }
}
