/* Shared public theme controls and light palette. */
.codex-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    flex-shrink: 0;
    border: 1px solid #4a4a4e;
    border-radius: 9px;
    background: #171719;
    color: #f4f4f5;
    font: 700 11px/1.2 Inter, Arial, sans-serif;
    cursor: pointer;
    white-space: nowrap;
}
.codex-theme-toggle:hover { border-color: #d6be8d; background: #25231f; }
.codex-theme-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.codex-theme-icon { display: flex; width: 22px; height: 22px; align-items: center; justify-content: center; line-height: 1; }
.codex-theme-icon svg { display: block; width: 22px; height: 22px; }
.codex-theme-label { display: none !important; }
.mobile-menu > .codex-theme-toggle { align-self: center; margin: 12px 0 0; }

html[data-theme="light"] {
    color-scheme: light;
    --bg-dark: #f6f4ef;
    --bg-medium: #ece9e2;
    --bg-light: #e8e5de;
    --text-primary: #171b20;
    --text-secondary: #555c65;
    --text-muted: #65707a;
    --border-color: #d4d0c7;
    --codex-surface: #fffdfa;
    --codex-surface-raised: #fff;
    --codex-border: #d4d0c7;
    --codex-border-strong: #a9a397;
    --codex-muted: #56616d;
    --codex-text: #191d23;
    --codex-text-soft: #4d5660;
    --codex-text-muted: #5e6872;
    --codex-shadow: 0 18px 45px rgba(35, 32, 24, .1);
    --portal-bg: #f6f4ef;
    --portal-glow: #e4dfd2;
    --portal-card-top: #fffdfa;
    --portal-card-bottom: #f1eee7;
    --portal-surface: #fffdfa;
    --portal-field: #fff;
    --portal-text: #191d23;
    --portal-soft: #4d5660;
    --portal-muted: #5e6872;
    --portal-border: #c4bfb5;
    --portal-accent-text: #725423;
    --portal-success: #206b40;
    --portal-error: #a42620;
}
html[data-theme="light"] body { background: #f6f4ef; color: #191d23; }
html[data-theme="light"] #loader-screen { background: #050505; color: #fff; }
html[data-theme="light"] ::selection { background: #252d36; color: #fff; }
html[data-theme="light"] :where(a,button,input,select,textarea):focus-visible { outline-color: #23313e; }

/* Navigation follows the selected theme; photo covers own a dark palette. */
html[data-theme="light"] .navbar,
html[data-theme="light"] .navbar.scrolled { background: rgba(255,253,250,.97) !important; border-bottom-color: #d4d0c7; color: #191d23; }
html[data-theme="light"] .navbar nav a { color: #4d5660; }
html[data-theme="light"] .navbar nav a:hover,
html[data-theme="light"] .navbar nav a.active { color: #191d23; }
html[data-theme="light"] .navbar nav a::after { background: #191d23; }
html[data-theme="light"] .navbar .button { background: #202a33; color: #fff; border-color: #202a33; }
html[data-theme="light"] .mobile-menu { background: #f6f4ef; color: #191d23; }
html[data-theme="light"] .mobile-menu a { color: #4d5660; }
html[data-theme="light"] .mobile-menu .button { color: #fff; background: #202a33; border-color: #202a33; }
html[data-theme="light"] .mobile-menu a.active { color: #191d23; }
html[data-theme="light"] .mobile-menu nav a.active::before { background: #202a33; }
html[data-theme="light"] .codex-client-link { color: #202a33; border-color: #c4bfb5; background: #fffdfa; }
html[data-theme="light"] .codex-client-link:hover { color: #191d23; background: #ece9e2; border-color: #8b8375; }
html[data-theme="light"] .codex-theme-toggle { background: #fffdfa; color: #202a33; border-color: #c4bfb5; }
html[data-theme="light"] .codex-theme-toggle:hover { background: #ece9e2; border-color: #8b8375; }
html[data-theme="light"] .codex-theme-toggle:focus-visible { outline-color: #23313e; }
html[data-theme="light"] .menu-toggle span { background: #202a33; }
html[data-theme="light"] :is(.navbar .codex-logo,footer .codex-logo) { background: #171b20; border-radius: 8px; padding: 5px; }
html[data-theme="light"] .codex-cover,
html[data-theme="light"] .codex-cover :is(h1,h2,h3,h4) { color: #f8f8fa; }
html[data-theme="light"] .codex-cover p { color: #e2e2e7; }
html[data-theme="light"] .hero-tag,
html[data-theme="light"] .codex-cover .section-label { color: #d6d9df; }
html[data-theme="light"] .codex-cover .button { background: #fff; color: #111; border-color: #fff; }
html[data-theme="light"] .codex-cover .button.outline { background: transparent; color: #fff; }

/* Editorial surfaces and cards. */
html[data-theme="light"] :is(.section,.resource-section,.codex-custom-article,.portfolio-section) { color: #191d23; }
html[data-theme="light"] .diferenciais-section,
html[data-theme="light"] .depoimentos-section,
html[data-theme="light"] .resource-section { background: #ece9e2; }
html[data-theme="light"] .resource-section.alt { background: #f7f5f0; }
html[data-theme="light"] .processo-section { background: #ece9e2; }
html[data-theme="light"] :is(.service-card,.feature-item,.processo-item,.depoimento-card,.contato-card,.resource-card,.codex-block,.faq-list details,.history-item) {
    background: #fffdfa;
    border-color: #d4d0c7;
    color: #191d23;
    box-shadow: 0 12px 34px rgba(40,35,28,.045);
}
html[data-theme="light"] :is(.service-card,.feature-item,.processo-item,.depoimento-card,.contato-card,.resource-card,.codex-block):hover { border-color: #a9a397; }
html[data-theme="light"] :is(.service-card p,.feature-item p,.processo-item p,.depoimento-card p,.contato-card p,.resource-card p,.resource-card li,.codex-block p,.codex-custom-article p,.resource-heading p,.policy p,.policy li,.faq-list p) { color: #4d5660; }
html[data-theme="light"] :is(.service-card .number,.service-card a,.servico-lista li,.feature-item svg,.contato-card small,.resource-heading span,.codex-block small,.codex-partner-card small) { color: #53606b; }
html[data-theme="light"] .resource-kicker,
html[data-theme="light"] .resource-section .section-label { color: #53606b; }
html[data-theme="light"] .codex-cover .resource-kicker,
html[data-theme="light"] .codex-cover .section-label { color: #d6d9df; }
html[data-theme="light"] .service-card::before { background: #333b43; }
html[data-theme="light"] .services-grid { background: transparent !important; border: 0 !important; }
html[data-theme="light"] .stats-band .stat-box { background: #fffdfa !important; border-color: #d4d0c7 !important; color: #191d23; }
html[data-theme="light"] .stat-box span,
html[data-theme="light"] .stats-band .stat-box span { color: #53606b; }
html[data-theme="light"] .depoimento-stars { color: #8b6337; }
html[data-theme="light"] .depoimento-avatar { background: #202b34; color: #fff; }
html[data-theme="light"] .depoimento-autor span { color: #58626c; }
html[data-theme="light"] .marquee-track span { color: #59636e; }
html[data-theme="light"] .marquee-track span::after { color: #8c7052; }
html[data-theme="light"] .faq-list { border-color: #d4d0c7; }
html[data-theme="light"] .faq-item { border-color: #d4d0c7; }
html[data-theme="light"] .codex-block-cta { background: #242c33; color: #fff; }
html[data-theme="light"] .codex-block-cta :is(h2,p,a) { color: #fff; border-color: #fff; }
html[data-theme="light"] .codex-block-quote { border-left-color: #9f835f; }
html[data-theme="light"] .codex-model-reference { background: #fffdfa; border-color: #d4d0c7; }
html[data-theme="light"] .codex-model-reference :is(p,a,span) { color: #4d5660; }
html[data-theme="light"] .codex-unavailable-page p { color: #4d5660; }
html[data-theme="light"] .codex-partner-preview { background: #1c2126; color: #fff; }
html[data-theme="light"] .codex-partner-preview span { color: #fff; }
html[data-theme="light"] .resource-cta { background: #192027; color: #fff; }
html[data-theme="light"] .resource-cta :is(h1,h2,h3,p) { color: #fff; }
html[data-theme="light"] .resource-cta .button { background: #fff; color: #171b20; border-color: #fff; }

/* Portfolio previews keep their dark overlay so labels are readable over any template. */
html[data-theme="light"] :is(.project,.codex-real-project-card) { background: #fffdfa !important; box-shadow: 0 15px 36px rgba(30,28,24,.09); }
html[data-theme="light"] .project-info p { color: #53606b; }
html[data-theme="light"] .codex-showcase-toolbar { background: #fffdfa; border-color: #d4d0c7; }
html[data-theme="light"] .codex-showcase-search { background: #f5f2eb; border-color: #d4d0c7; }
html[data-theme="light"] .codex-showcase-search input { color: #191d23; }
html[data-theme="light"] .codex-showcase-search span,
html[data-theme="light"] .codex-showcase-summary span { color: #57616d; }
html[data-theme="light"] .codex-showcase-filters button { color: #3d4854; border-color: #c7c2b8; }
html[data-theme="light"] .codex-showcase-filters button:hover,
html[data-theme="light"] .codex-showcase-filters button.active { background: #222a32; color: #fff; border-color: #222a32; }
html[data-theme="light"] .codex-showcase-empty { color: #53606b; }
html[data-theme="light"] .codex-model-card .project-overlay,
html[data-theme="light"] .codex-model-card:hover .project-overlay { background: #12161b; color: #fff; }
html[data-theme="light"] .codex-model-card .project-content h3 { color: #fff; }
html[data-theme="light"] .codex-model-card .project-content p { color: #d1d5dc; }

/* Forms and actions never use white text on a white field. */
html[data-theme="light"] main .button { background: #202a33; border-color: #202a33; color: #fff; }
html[data-theme="light"] main .button.outline { background: transparent; color: #202a33; }
html[data-theme="light"] main .button.dark-button { background: #202a33; color: #fff; border-color: #202a33; }
html[data-theme="light"] .codex-cover .button { background: #fff; color: #111; border-color: #fff; }
html[data-theme="light"] .codex-cover .button.outline { background: transparent; color: #fff; border-color: #fff; }
html[data-theme="light"] .contato-cta { background: #fffdfa; border-color: #d4d0c7; }
html[data-theme="light"] .contato-cta p { color: #53606b; }
html[data-theme="light"] .contato-icon { color: #202a33; border-color: #c6c2b8; }
html[data-theme="light"] .contato-horario { color: #206e4a; }
html[data-theme="light"] .budget-field :is(input,select,textarea) { background: #fffdfa; color: #191d23; border-color: #bcb9b2; }
html[data-theme="light"] .budget-field :is(input,select,textarea):focus { background: #fff; border-color: #475766; }
html[data-theme="light"] .budget-field select option { background: #fff; color: #191d23; }
html[data-theme="light"] .feature label { background: #fffdfa; border-color: #c9c5bc; color: #242a31; }
html[data-theme="light"] .feature input:checked + label { background: #e0e9ed; border-color: #304c5c; }
html[data-theme="light"] .budget-section { border-color: #d4d0c7; }
html[data-theme="light"] .budget-header.codex-cover :is(h1,p) { color: #f8f8fa; }

/* Footer surfaces and secondary links match the page palette. */
html[data-theme="light"] footer { background: #ece9e2; border-color: #d4d0c7; color: #191d23; }
html[data-theme="light"] footer .footer-bottom,
html[data-theme="light"] footer .footer-social a { border-color: #b9b3a8; }
html[data-theme="light"] footer :is(h1,h2,h3,h4) { color: #191d23; }
html[data-theme="light"] footer :is(.footer-brand p,.footer-links a,.footer-contato a,.footer-bottom) { color: #4d5660; }
html[data-theme="light"] footer a:hover { color: #191d23; }
html[data-theme="light"] footer .codex-footer-release { color: #4d5660; }
html[data-theme="light"] footer .codex-admin-access:focus-visible { outline-color: #23313e; }
html[data-theme="light"] .back-to-top { background: #202a33; color: #fff; }
html[data-theme="light"] #scrollProgress { background: #8a6c45; }
html[data-theme="light"] .studio-tour,
html[data-theme="light"] .codex-presentation { color-scheme: dark; color: #fff; }
html[data-theme="light"] .studio-tour :is(h1,h2,h3,h4),
html[data-theme="light"] .codex-presentation :is(h1,h2,h3,h4) { color: #fff; }

/* Nested dark surfaces own their tokens, including future content in these regions. */
html[data-theme="light"] :is(.codex-cover,.studio-tour,.codex-presentation,.project-overlay,.codex-partner-preview,.resource-cta) {
    color-scheme: dark;
    --text-primary: #f8f8fa;
    --text-secondary: #c4c7cf;
    --text-muted: #aeb5c0;
    --codex-text: #f8f8fa;
    --codex-text-soft: #e2e2e7;
    --codex-text-muted: #aeb5c0;
    --codex-muted: #bcc1c9;
    --codex-border: #343a43;
}
html[data-theme="light"] :is(.section-heading > span,.service-icon,.service-card:hover .service-icon,.service-card a:hover,.servico-lista li::before,.processo-item > span,.processo-item:hover > span,.stat-item span,.sobre-missao li,.project-info .tags,.project-info .project-number,.back-link,.back-link:hover,.resource-card small) { color: var(--text-secondary); }
html[data-theme="light"] .service-card { border-color: var(--border-color) !important; }
html[data-theme="light"] main .service-card .button { color: #fff; }
html[data-theme="light"] main .service-card .button.outline { color: #202a33; }
/* Opaque fallback behind the preview gradient, before each iframe is loaded. */
html[data-theme="light"] .faq-question { color: var(--text-primary); }
html[data-theme="light"] .faq-question:hover { color: #374b5c; }
html[data-theme="light"] .faq-answer p { color: var(--text-secondary); }
html[data-theme="light"] .faq-icon::before,
html[data-theme="light"] .faq-icon::after,
html[data-theme="light"] .faq-item.open .faq-icon::before { background: #53606c; }
html[data-theme="light"] .codex-real-projects-head :is(h2,strong) { color: var(--text-primary); }
html[data-theme="light"] :is(.codex-real-projects-kicker,.codex-real-projects-head p,.codex-real-projects-empty,.codex-real-project-number) { color: var(--text-secondary); }
html[data-theme="light"] .codex-real-projects-empty { border-color: var(--border-color); background: #fffdfa; }
html[data-theme="light"] .codex-real-project-info { color: var(--text-primary); }
html[data-theme="light"] .codex-real-project-info :is(h3,p,a,small) { color: inherit; }
html[data-theme="light"] .codex-project-reviews { background: #ece9e2; color: #191d23; }
html[data-theme="light"] .codex-project-review { background: #fffdfa; border-color: #c4bfb5; }
html[data-theme="light"] :is(.codex-project-reviews-head p,.codex-project-review p,.codex-project-review small,.codex-project-reviews-empty) { color: #4d5660; }
html[data-theme="light"] :is(.codex-project-reviews-head > span,.codex-project-review-target,.codex-project-review-stars) { color: #725423; }
html[data-theme="light"] .codex-project-reviews-empty { border-color: #b5afa4; }
html[data-theme="light"] .policy article { border-color: #d4d0c7; }
html[data-theme="light"] .codex-clear-filters { color: #4d5660; border-color: #b5afa4; }
html[data-theme="light"] .codex-cover .hero-subtitle,
html[data-theme="light"] .codex-cover .budget-header p { opacity: 1; }
html[data-theme="light"] .budget-field :is(input,textarea)::placeholder { color: #5e6872; opacity: 1; }
html[data-theme="light"] .feature label:hover { border-color: #53606c; }
html[data-theme="light"] .portal-header { color: var(--portal-text); }
html[data-theme="light"] .portal-header .brand img { background: #171b20; padding: 4px; border-radius: 8px; }
html[data-theme="light"] .portal-header .codex-theme-toggle { background: #fffdfa; color: #191d23; border-color: #c4bfb5; }
html[data-theme="light"] .portal-header .codex-theme-toggle:focus-visible { outline-color: #23313e; }
html[data-theme="light"] main .button.outline:hover { background: #202a33; color: #fff; }
html[data-theme="light"] .codex-cover .button.outline:hover { background: #fff; color: #111; }
html[data-theme="light"] .button:hover { box-shadow: 0 8px 24px #202a3320; }
html[data-theme="light"] .portal-header .back:hover { background: #ece9e2; border-color: #8b8375; }
html[data-theme="light"] .portal-card :is(input,select,textarea):focus-visible { outline-color: #725423; }
html[data-theme="light"] :is(.auth-switch,.account-tabs) button:focus-visible { outline-color: #725423; }

@media (max-width: 680px) {
    html[data-theme="light"] .codex-showcase-toolbar { padding: 16px; }
    html[data-theme="light"] .codex-theme-toggle { min-height: 46px; }
}

/* Solid editorial surfaces use readable secondary text in both themes. */
html:not([data-theme="light"]) :is(.section-heading > span,.service-card .number,.feature-item p,.processo-item > span,.processo-item p,.marquee-track span,.stat-item span,.sobre-missao p,.contato-card small,.contato-card p,.footer-brand p,.codex-real-projects-kicker,.codex-real-projects-empty) { color: #aaaab4; }
html:not([data-theme="light"]) .service-card .button { color: #111; }
html:not([data-theme="light"]) .service-card .button.outline { color: #f4f4f5; }
html:not([data-theme="light"]) .service-card .button.outline:hover { color: #111; }
html:not([data-theme="light"]) .mobile-menu-footer a { color: #aaaab4; }
html:not([data-theme="light"]) .resource-section.alt { background: #111113; color: #f4f4f5; }
html:not([data-theme="light"]) .resource-section.alt :is(h1,h2,h3,h4) { color: #f4f4f5; }
html:not([data-theme="light"]) .resource-section.alt .resource-card { background: #19191c; border-color: #3c3c43; }
html:not([data-theme="light"]) .resource-section.alt :is(.resource-heading span,.resource-heading p,.resource-card small,.resource-card p,.resource-card li) { color: #b5b5bf; }
.cta { background: var(--bg-light); color: var(--text-primary); border-color: var(--border-color); }
.cta :is(h2,h2 span,h2 strong) { color: var(--text-primary); }
.cta > span { color: var(--text-secondary); background: var(--bg-medium); border-color: var(--border-color); }
html:not([data-theme="light"]) .cta .dark-button { background: #f4f4f5; color: #111; border-color: #f4f4f5; }
html:not([data-theme="light"]) .cta .dark-button:hover { background: transparent; color: #f4f4f5; }
html[data-theme="light"] footer :is(.codex-version-badge strong,.codex-version-channel,.codex-version-status,.codex-version-status span) { color: #4d5660; }

/* Controles da apresentação acompanham o tema; as capas mantêm suas cores. */
html[data-theme="light"] .codex-presentation { color-scheme:light; background:#efede7; color:#191d23; }
html[data-theme="light"] :is(.codex-presentation-header,.codex-presentation-footer) { background:#f9f8f4; border-color:#c9c5bc; color:#191d23; }
html[data-theme="light"] :is(.codex-presentation-header small,.codex-presentation-footer>span,.codex-presentation [data-presentation-count]) { color:#4d5660; }
html[data-theme="light"] .codex-presentation-stage { background:#e7e3db; }
html[data-theme="light"] .codex-presentation-controls button { background:#fff; color:#191d23; border-color:#afa99e; }
html[data-theme="light"] .codex-presentation-controls button[aria-pressed="false"] { border-color:#4d5660; }
html[data-theme="light"] .codex-presentation-footer a { background:#191d23; color:#fff; border-color:#191d23; }
html[data-theme="light"] .codex-presentation-footer>div { background:#d7d2c8; }
html[data-theme="light"] .codex-presentation-footer i { background:#4d5660; }
html[data-theme="light"] .codex-presentation-loader { background:#efede7; color:#4d5660; }
html[data-theme="light"] .codex-presentation-loader span { border-color:#d7d2c8; border-top-color:#191d23; }
html[data-theme="light"] .codex-presentation-error { color:#4d5660; }
html[data-theme="light"] :is(.codex-presentation-controls button,.codex-presentation-footer a):focus-visible { outline-color:#23313e; }
