/* Explicit site themes. Keep these rules in the design layer: that layer owns
   important palette declarations in the older, independently styled screens. */
@layer fortune-design {
  html[data-fortune-theme="light"] {
    color-scheme: light !important;
    --fortune-surface-bg: #fbfbf8 !important;
    --fortune-surface-panel: #ffffff !important;
    --fortune-surface-raised: #f5f4ef !important;
    --fortune-surface-inset: #f5f4ef !important;
    --fortune-surface-hover: #ebe9e0 !important;
    --fortune-surface-line: #d9d8d2 !important;
    --fortune-surface-line-soft: #e4e3de !important;
    --fortune-surface-text: #1a1a1e !important;
    --fortune-surface-muted: #62626b !important;
    --fortune-surface-dim: #77777f !important;
    --fortune-surface-accent: #b83615 !important;
    --fortune-surface-accent-text: #ffffff !important;
    --fortune-surface-action: #1a1a1e !important;
    --fortune-surface-action-text: #fbfbf8 !important;
    --fortune-surface-active: #fff1e3 !important;
    --fortune-surface-active-text: #2a1407 !important;
    --fortune-surface-error: #9e3b29 !important;
    --fortune-surface-error-bg: #fff0eb !important;
    --fortune-surface-success: #34633f !important;
    --fortune-surface-success-bg: #edf5ec !important;
    --fortune-surface-shadow: 0 14px 40px #15152412 !important;
    --fortune-surface-overlay: #15152466 !important;
    --fortune-surface-scheme: light !important;
  }

  html[data-fortune-theme="dark"] {
    color-scheme: dark !important;
    --fortune-surface-bg: #101013 !important;
    --fortune-surface-panel: #151518 !important;
    --fortune-surface-raised: #1b1b1f !important;
    --fortune-surface-inset: #151518 !important;
    --fortune-surface-hover: #242326 !important;
    --fortune-surface-line: rgba(255,255,255,.16) !important;
    --fortune-surface-line-soft: rgba(255,255,255,.08) !important;
    --fortune-surface-text: #f3f1ee !important;
    --fortune-surface-muted: #a3a19c !important;
    --fortune-surface-dim: #8e8c89 !important;
    --fortune-surface-accent: #ff7f0a !important;
    --fortune-surface-accent-text: #101013 !important;
    --fortune-surface-action: #ff4a1f !important;
    --fortune-surface-action-text: #101013 !important;
    --fortune-surface-active: rgba(255,74,31,.08) !important;
    --fortune-surface-active-text: #ff7f0a !important;
    --fortune-surface-error: #f3b29f !important;
    --fortune-surface-error-bg: #38261f !important;
    --fortune-surface-success: #b4d9b7 !important;
    --fortune-surface-success-bg: #203025 !important;
    --fortune-surface-shadow: 0 14px 40px #00000033 !important;
    --fortune-surface-overlay: #00000099 !important;
    --fortune-surface-scheme: dark !important;
  }

  html[data-fortune-theme] {
    background: var(--fortune-surface-bg) !important;
    --fortune-paper: var(--fortune-surface-bg) !important;
    --fortune-paper-secondary: var(--fortune-surface-inset) !important;
    --fortune-ink: var(--fortune-surface-text) !important;
    --fortune-muted: var(--fortune-surface-muted) !important;
    --fortune-border: var(--fortune-surface-line) !important;
    --landing-paper: var(--fortune-surface-bg) !important;
    --landing-ink: var(--fortune-surface-text) !important;
    --landing-secondary: var(--fortune-surface-inset) !important;
    --landing-tertiary: var(--fortune-surface-raised) !important;
    --landing-line: var(--fortune-surface-line) !important;
    --landing-muted: var(--fortune-surface-muted) !important;
  }

  /* Director and Team retain their existing data-director-theme palettes.
     Projects needs body aliases because the old design layer forced it light. */
  html[data-fortune-theme] :is(body.fortune-ui, body.split-studio, body.fortune-landing, body.fortune-projects, body.fortune-signin, body.fortune-legal) {
    --ui-bg: var(--fortune-surface-bg) !important;
    --ui-panel: var(--fortune-surface-panel) !important;
    --ui-panel-2: var(--fortune-surface-raised) !important;
    --ui-surface: var(--fortune-surface-panel) !important;
    --ui-raised: var(--fortune-surface-raised) !important;
    --ui-inset: var(--fortune-surface-inset) !important;
    --ui-hover: var(--fortune-surface-hover) !important;
    --ui-line: var(--fortune-surface-line) !important;
    --ui-line-soft: var(--fortune-surface-line-soft) !important;
    --ui-text: var(--fortune-surface-text) !important;
    --ui-muted: var(--fortune-surface-muted) !important;
    --ui-dim: var(--fortune-surface-dim) !important;
    --ui-action: var(--fortune-surface-action) !important;
    --ui-action-text: var(--fortune-surface-action-text) !important;
    --ui-error: var(--fortune-surface-error) !important;
    --ui-error-bg: var(--fortune-surface-error-bg) !important;
    --bg: var(--ui-bg) !important;
    --panel: var(--ui-panel) !important;
    --surface: var(--ui-panel) !important;
    --elevated: var(--ui-raised) !important;
    --canvas: var(--ui-bg) !important;
    --inset: var(--ui-inset) !important;
    --soft: var(--ui-inset) !important;
    --hover: var(--ui-hover) !important;
    --line: var(--ui-line) !important;
    --text: var(--ui-text) !important;
    --ink: var(--ui-text) !important;
    --muted: var(--ui-muted) !important;
    --subtle: var(--ui-muted) !important;
    --dim: var(--ui-dim) !important;
    --gold: var(--fortune-surface-accent) !important;
    --accent: var(--ui-action) !important;
    --blue: var(--ui-action) !important;
    --blue-light: var(--ui-muted) !important;
    --button: var(--ui-action) !important;
    --button-text: var(--ui-action-text) !important;
    --error: var(--ui-error) !important;
    --chat-blue: var(--ui-action) !important;
    --vs-bg: var(--ui-bg) !important;
    --vs-surface: var(--ui-panel) !important;
    --vs-line: var(--ui-line) !important;
    --vs-yellow: var(--ui-action) !important;
    background: var(--ui-bg) !important;
    color: var(--ui-text) !important;
    color-scheme: var(--fortune-surface-scheme) !important;
  }

  /* Shared menus, navigation drawers, and account controls. */
  html[data-fortune-theme] body :is(.fortune-account-panel, .create-destination-menu, .create-destination-menu[data-theme="light"], .ui-quick-actions, .ui-edit-panel) {
    background: var(--fortune-surface-panel) !important;
    color: var(--fortune-surface-text) !important;
    border-color: var(--fortune-surface-line) !important;
    color-scheme: var(--fortune-surface-scheme) !important;
    box-shadow: var(--fortune-surface-shadow) !important;
  }
  html[data-fortune-theme] body :is(.fortune-account-menu summary, .fortune-account-panel button, .fortune-account-panel a, .fortune-account-link) {
    color: var(--fortune-surface-text) !important;
    border-color: var(--fortune-surface-line) !important;
  }
  html[data-fortune-theme] body :is(.create-destination-link small, .create-destination-menu[data-theme="light"] .create-destination-link small) { color: var(--fortune-surface-muted) !important; }
  html[data-fortune-theme] :is(body.app-hub .sidebar, body.app-editor .create-sidebar, body.split-studio .studio-rail) {
    background: var(--fortune-surface-bg) !important;
    color: var(--fortune-surface-text) !important;
    border-color: var(--fortune-surface-line) !important;
  }
  html[data-fortune-theme] body :is(.sidebar .main-nav > a, .sidebar .main-nav > .create-menu-trigger, .create-sidebar nav > a, .create-sidebar nav > .create-menu-trigger, .studio-rail > .rail-button, .studio-rail > .create-menu-trigger, .settings-link, .sidebar .hub-workspace > a, .sidebar .hub-workspace > span, .sidebar .about-link, .sidebar-footer, .create-sidebar .global-bottom button) {
    color: var(--fortune-surface-text) !important;
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  html[data-fortune-theme] body :is(.main-nav > a:hover, .main-nav > .create-menu-trigger:hover, .create-sidebar nav > a:hover, .create-sidebar nav > .create-menu-trigger:hover, .studio-rail > .rail-button:hover, .studio-rail > .create-menu-trigger:hover, .settings-link:hover, .create-destination-link:hover) {
    color: var(--fortune-surface-text) !important;
    background: var(--fortune-surface-hover) !important;
  }
  html[data-fortune-theme] body :is(.sidebar .main-nav > a.active, .create-sidebar nav > a.active, .create-menu-trigger[aria-expanded="true"], .create-destination-menu .create-destination-link[aria-current="page"]) {
    color: var(--fortune-surface-active-text) !important;
    background: var(--fortune-surface-active) !important;
    border-color: var(--fortune-surface-accent) !important;
  }
  html[data-fortune-theme] body :is(.main-nav a.active svg, .create-destination-link[aria-current="page"] svg) { color: inherit !important; }
  html[data-fortune-theme] body :is(.nav-section-divider, .studio-rail > .rail-divider, .header-divider) { background: var(--fortune-surface-line) !important; }
  html[data-fortune-theme] body :is(.nav-tag, .beta, .workspace-soon) {
    color: var(--fortune-surface-muted) !important;
    background: var(--fortune-surface-inset) !important;
    border-color: var(--fortune-surface-line) !important;
  }
  html[data-fortune-theme] body :is(.nav-beta, .launch-heading .nav-beta) {
    color: var(--fortune-surface-active-text) !important;
    background: var(--fortune-surface-active) !important;
    border-color: var(--fortune-surface-line) !important;
  }

  /* Hub Home and its context/history surfaces contain legacy literal colors. */
  html[data-fortune-theme] body.app-hub :is(#main, #home-chat-sidebar, .has-messages .chat-composer-area, .fw-heading) { background: var(--ui-bg) !important; }
  html[data-fortune-theme] body.app-hub :is(.chat-composer, .home-store-popover, #chat-context-dialog, #chat-context-dialog footer, #home-history-dialog, .home-chats-reopen, .fw-column, .fw-column-heading) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: var(--fortune-surface-shadow) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.home-context-bar, .context-tabs, .context-option-icon, .fw-tool, .fw-agent-card, .fw-agent-placeholder, .fw-chat-tabs, .fw-layout-toolbar, .fw-saved-asset, .fw-recent-chat, .chat-message.user) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.chat-welcome h1, .chat-welcome h2, .chat-message, .chat-composer textarea, .chat-add-context, .home-store-menu summary, .home-store-popover button, .context-option, #home-history-dialog button, #home-history-dialog a, #home-chat-sidebar .fw-recent-open, .fw-recent-open strong, .fw-tool strong, .fw-period strong, .fw-agent-card h3, .fw-fort-mark, .fw-settings-link) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.chat-composer textarea, #chat-input) { background: transparent !important; }
  html[data-fortune-theme] body.app-hub :is(.chat-composer textarea, #home-chats-search, #home-history-search, #chat-context-search)::placeholder { color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.app-hub :is(.home-store-popover label, .home-context-bar button, .chat-keyboard-hint, .chat-connection, #chat-signin, #chat-context-dialog header p, #chat-context-dialog header button, .context-tabs button, .context-option small, .context-empty, #chat-context-note, #home-history-dialog p, #home-chat-sidebar h3, #home-chat-sidebar footer, #home-chat-sidebar .history-icon-button, #home-chat-sidebar [data-chat-move], #home-chat-sidebar #fw-recent-list, .fw-folder-empty, .fw-top-label, .fw-intro, .fw-tool small, .fw-note, .fw-period > span, .fw-revenue > span, .fw-column-heading h2, .fw-column-heading svg, .fw-collapse, .fw-agent-intro, .fw-agent-card p, .fw-chat-context, .fw-recent-note, .fw-recent-open small, .fw-saved-asset small, .fw-saved-asset p, .composer-label, .chat-thinking, .chat-speaker, .chat-welcome p, .chat-message-context, #fw-library-status, .fw-folder-limit, .fw-drop-hint) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-hub :is(.home-store-popover select, #home-chats-search, #home-history-search, #chat-context-search, #home-history-dialog button, .fw-heading select, .fw-heading .fw-action, .fw-folder-controls button, .fw-file-label, .fw-saved-asset button, .fw-layout-toolbar button, .fw-recent-heading button, .chat-save-row button, .fw-recent-chat > button, .fw-coming-label, .fw-agent-icon) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.chat-context-chips button, .context-upload, #home-chat-sidebar .history-new-chat, #home-chat-sidebar .fw-recent-open[aria-current="true"], .context-tabs button[aria-pressed="true"], .context-option[aria-pressed="true"]) {
    background: var(--fortune-surface-active) !important;
    color: var(--fortune-surface-active-text) !important;
    border-color: var(--fortune-surface-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.chat-add-context:hover, .home-context-bar button:hover, .chat-suggestion:hover, .context-option:hover, #home-chat-sidebar .fw-recent-chat:hover, #home-chat-sidebar .history-icon-button:hover, #home-history-dialog button:hover, .fw-tool:hover) {
    background: var(--ui-hover) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.home-store-popover a, #chat-signin a, [data-context-count], .context-check svg, .context-empty a, .context-empty button, .fw-text-link, .fw-saved-asset a) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-hub :is(.chat-send, .context-done) {
    background: var(--ui-action) !important;
    color: var(--ui-action-text) !important;
    border-color: var(--ui-action) !important;
  }
  html[data-fortune-theme] body.app-hub .chat-send:disabled { background: var(--ui-raised) !important; color: var(--ui-dim) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub :is(.founder-workspace, .fw-column, .fw-column-heading, .fw-heading, .fw-tool, .fw-agent-card, .fw-agent-intro, .fw-chat-context, .fw-chat-tabs, .fw-chat-tabs button span, .fw-drop-hint, #home-chat-sidebar footer, .context-check) { border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub :is(.founder-workspace, .fw-heading h1, .fw-revenue > strong, .fw-metrics strong, .fw-agents h3, .fw-agent-placeholder strong, .fw-empty h3, .fw-club-empty h3, .fw-chat-context button, .fw-recent-heading h3, .fw-tool-icon) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.fw-tool > span:not(.fw-tool-icon), .fw-revenue p, .fw-metrics span, .fw-metrics small, .fw-agent-placeholder p, .fw-agent-placeholder > svg, .fw-empty, .fw-club-empty p, .fw-chat-tabs button, .fw-chat-tabs button span, .fw-eyebrow, .settings-workspaces p) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-hub .chat-suggestion { background: var(--ui-inset) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub .chat-suggestion svg { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-hub .fw-chat-tabs button[aria-selected="true"] { background: var(--ui-panel) !important; color: var(--ui-text) !important; border-bottom-color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-hub :is(.fw-menu-toggle:hover, .fw-collapse:hover) { color: var(--ui-text) !important; background: var(--ui-hover) !important; }
  html[data-fortune-theme] body.app-hub :is(.tracker-chart, .fw-revenue .tracker-chart, .fw-club-empty svg) { color: var(--fortune-surface-accent) !important; }

  /* Funnels: edit controls follow the site palette; rendered storefront and
     device iframe content keep their own authored colors. */
  html[data-fortune-theme] body.app-hub :is(.funnel-studio, .ff-dialog) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-composer, .ff-saved-card, .ff-preview-column, .ff-dialog, .ff-home-setup, .ff-editor-context, .ff-result-grid section) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.ff-conversation, .ff-editor-head) { background: var(--ui-bg) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-message.user, .ff-presets button, .funnel-studio .button, .ff-dialog .button, .ff-store-label select, .funnel-studio input, .ff-dialog input, .ff-dialog textarea, .ff-dialog select) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub .ff-composer textarea { background: transparent !important; color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub .ff-composer textarea::placeholder { color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-welcome h1 span, .ff-welcome p, .ff-composer-tools, .ff-preset-label, .ff-presets button span, .ff-presets button i, .ff-saved-card span, .ff-empty, .ff-notice, .ff-editor-head span, .ff-back, .ff-message small, .ff-message p, .ff-preview-note, .ff-dialog p, .ff-dialog small, .ff-dialog form > label, .ff-dialog-bottom, .ff-home-setup p, .ff-home-setup .ff-store-label, .ff-setup-summary, .ff-published-state, .ff-checklist, .ff-checklist small, .ff-setup-layout, .ff-experiment-label, .ff-setup-details p, .ff-setup-details ol, .ff-review-context, .ff-metrics dt, .ff-run-note p, .ff-run-note small, .ff-result-grid span) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-dialog .ff-close, .ff-checklist strong, .ff-setup-details summary, .ff-setup-details strong, .ff-metrics dd, .ff-editor-context strong) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-spark, .ff-dialog a, .ff-dialog .eyebrow, .ff-home-setup .eyebrow, .ff-result-grid strong, .ff-published-state a, .ff-metrics > div:first-child dd) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-review-notes, .ff-run-note, .ff-status-chip, .ff-unverified, .ff-setup-callout) {
    background: var(--fortune-surface-active) !important;
    color: var(--fortune-surface-active-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.ff-setup-callout > strong, .ff-checklist em) { color: var(--fortune-surface-active-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-status-chip.ready, .ff-check-pass > span, .ff-check-pass em) { color: var(--fortune-surface-success) !important; }
  html[data-fortune-theme] body.app-hub .ff-status-chip.ready { background: var(--fortune-surface-success-bg) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-check-optional > span, .ff-check-optional em) { color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-send, .funnel-studio .ff-primary, .ff-dialog .ff-primary, .ff-preview-toolbar .active) {
    background: var(--ui-action) !important;
    color: var(--ui-action-text) !important;
    border-color: var(--ui-action) !important;
  }
  html[data-fortune-theme] body.app-hub .ff-presets button:hover { background: var(--ui-hover) !important; border-color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-hub :is(.ff-notice.error, #ff-error, .ff-setup-error) { color: var(--ui-error) !important; }

  /* Launch and Connections also predate the shared token palette. */
  html[data-fortune-theme] body.app-hub :is(.launch-card, .launch-campaign, .launch-empty, .launch-review, .launch-preset-card, .launch-preset-card.scale, .launch-soon-card, .connection-detail, .connection-review) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.launch-card input, .launch-card textarea, .launch-card select, .launch-preview, .launch-stats div, .launch-mode-choice label, .launch-guided fieldset, .connections-page .connect-url, .connections-page .shop-manual-link input, .connections-page #meta-connect select, .meta-account-list, .connections-page .shop-product) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.launch-card label, .launch-guided summary, .connections-page, .integration-section > h2, .integration-card h3, .connection-detail-bar h2, .connection-provider h2, .connection-store strong, .connection-add-store > summary, .connections-page .connect-label, .connections-page .connect-url input, .connections-page #meta-connect h2, .connections-page #meta-connect legend, .connections-page .meta-account strong, .connections-page .shop-product h3) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-hub :is(.launch-kicker, .launch-heading p, .launch-help, .launch-manage-heading p, .launch-tabs button, .launch-stats small, .launch-review dt, .launch-preset-intro p, .launch-preset-card p, .launch-preset-card small, .launch-soon-card p, .launch-preset-back > span, .launch-asset-choice small, .launch-count-row p, .connections-heading p, .integration-section > p, .integration-card p, .integration-state, .connection-provider p, .connection-empty, .connection-help, .connections-page .connect-label span, .connections-page .connect-url svg, .connections-page .shop-status, .connections-page .shop-manual-link, .connections-page #shop-form-status, .connections-page #meta-connect legend span, .connections-page .meta-account small, .connections-footnote, .connections-page .shop-product p) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-hub :is(.launch-badge, .launch-card-title span, #launch-notice, .launch-preset-total, .launch-mode-choice label:has(input:checked), .launch-guided output, .connection-status, .connection-status.needs-attention) {
    background: var(--fortune-surface-active) !important;
    color: var(--fortune-surface-active-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-hub :is(.launch-tabs button.active, .launch-preset-number, .launch-preset-diagram .plus, .launch-guided legend) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-hub :is(.launch-preset-diagram i, .launch-card .launch-asset-choice, .launch-card .launch-upload-label) { border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub .launch-preset-diagram i { background: var(--fortune-surface-active) !important; }
  html[data-fortune-theme] body.app-hub :is(.launch-actions .primary, .launch-preset-cta, #launch-background-status, .connections-page .button) {
    background: var(--ui-action) !important;
    color: var(--ui-action-text) !important;
    border-color: var(--ui-action) !important;
  }
  html[data-fortune-theme] body.app-hub .connection-status.is-connected { background: var(--fortune-surface-success-bg) !important; color: var(--fortune-surface-success) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-hub :is(.launch-error, .connections-page .shop-error) { color: var(--ui-error) !important; }

  /* Image and Video Studio chrome. Artwork, photos, player contents, and the
     editor canvas are deliberately outside these surface selectors. */
  html[data-fortune-theme] body.app-editor :is(.create-main, #images-view, #studio-output-slot, #studio-output-slot > #image-results-panel, .video-studio-rail) {
    background: var(--ui-bg) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-editor :is(.image-main-composer, .vs-composer, .vs-connector, .video-studio-menu) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: var(--fortune-surface-shadow) !important;
  }
  html[data-fortune-theme] body.app-editor :is(.image-create-form .image-presets .starter-grid button, .image-details-fields input, .image-context-tray, .vs-context-tray, .selected-image-wrap, .vs-nav button:first-child, .vs-connector-mark, .vs-connector > a, .vs-connector > button) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-editor :is(.studio-welcome h2, .vs-hero h1, .vs-preset-meta strong, #brief-product, #image-prompt, #video-prompt, .image-create-form #image-drop, .image-create-form .format-option select, .image-details-title, .vs-model, .vs-attach) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-editor :is(#brief-product, #image-prompt, #video-prompt) { background: transparent !important; }
  html[data-fortune-theme] body.app-editor :is(#image-prompt, #video-prompt)::placeholder { color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.app-editor :is(.studio-eyebrow, .project-label input, .image-create-form .starter-grid small, .image-product-field > span, .image-context-tray :is(button, a), .image-context-tray small, .image-reference-detail #image-reference-name, .image-reference-detail button, #image-detail-count, .image-brief-actions button, .image-generation-feedback, #studio-output-slot #image-empty > p:last-of-type, .image-brief-review dt, .image-review-note, .vs-brand > span:last-child:not(.fortune-home-logo), .vs-model-spec, .vs-context-tray button, .vs-approval, .vs-provider-state, .vs-generation-status, .vs-categories button, .vs-preset-meta small, .vs-preset-description, .vs-panel-heading p, .vs-recent-heading, #video-studio-recents p, #video-studio-recents button, .vs-rail-footer a, .vs-connector p, .vs-connector small) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-editor :is(.image-reference-detail, .vs-reference-detail, .image-create-form .starter-grid button[aria-pressed="true"], .vs-categories button[aria-pressed="true"], .vs-nav .active) {
    background: var(--fortune-surface-active) !important;
    color: var(--fortune-surface-active-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.app-editor :is(.image-reference-detail strong, .image-review-format, .image-generation-feedback #image-signin a, .generator-tabs a.active, .vs-rail-footer span) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-editor .generator-tabs a.active::after { background: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.app-editor :is(.generator-tabs a, .image-context-tray, .vs-context-tray, .create-switcher, .image-product-field, .vs-rail-footer, .vs-provider-state, .vs-preset-card img) { border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-editor :is(.generator-tabs a, .create-sidebar .workspace-picker > label, .create-sidebar .add-workspace, .create-sidebar .rail-soon, .workspace-sidebar #workspace-search-empty) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-editor :is(.create-sidebar .workspace-select-wrap select, .create-sidebar .workspace-select-wrap select option) { background: var(--ui-panel) !important; color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-editor :is(.image-create-form #generate-image, #generate-video, #new-ad) {
    background: var(--ui-action) !important;
    color: var(--ui-action-text) !important;
    border-color: var(--ui-action) !important;
  }
  html[data-fortune-theme] body.app-editor .vs-fort-mark { background: var(--ui-action) !important; color: var(--ui-action-text) !important; }
  html[data-fortune-theme] body.app-editor :is(#generate-image:disabled, #generate-video:disabled) { background: var(--ui-raised) !important; color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.app-editor :is(.image-context-tray :is(button, a):hover, .image-brief-actions button:hover, .image-create-form #image-drop:hover, .vs-context-tray button:hover, .vs-nav :is(button, a):hover, #video-studio-recents button:hover, .vs-attach:hover) { background: var(--ui-hover) !important; color: var(--ui-text) !important; }

  /* Script & Voice uses separate writing and voice panels and light dialogs. */
  html[data-fortune-theme] body.split-studio :is(.writing-panel, .fort-chat-header, .voice-topbar, .fort-identity h1, .chat-compose-area, .mobile-tabs) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    color-scheme: var(--fortune-surface-scheme) !important;
    box-shadow: none !important;
  }
  html[data-fortune-theme] body.split-studio .voice-panel { background: var(--ui-bg) !important; }
  html[data-fortune-theme] body.split-studio :is(.script-document-card, .starter-prompts button, .chat-composer, .custom-voice-panel, .voice-editor-surface, .audio-result, .recent-card, .quiet-button, .voice-topbar .quiet-button, .light-dialog .quiet-button, .duration-section, .duration-options button, .review-notes) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    box-shadow: none !important;
  }
  html[data-fortune-theme] body.split-studio :is(dialog, .light-dialog) {
    --text: var(--ui-text) !important;
    --muted: var(--ui-muted) !important;
    --line: var(--ui-line) !important;
    --gold: var(--fortune-surface-accent) !important;
    --dim: var(--ui-dim) !important;
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    color-scheme: var(--fortune-surface-scheme) !important;
    box-shadow: var(--fortune-surface-shadow) !important;
  }
  html[data-fortune-theme] body.split-studio :is(.field input, .field textarea, .field select, .pronunciation-row input, .custom-voice-panel input, .light-dialog .field input, .light-dialog .field textarea, .light-dialog .field select) {
    background: var(--ui-inset) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
  }
  html[data-fortune-theme] body.split-studio :is(.chat-composer textarea, .narration-editor, .script-editor, .project-title input) { background: transparent !important; color: var(--ui-text) !important; }
  html[data-fortune-theme] body.split-studio :is(input, textarea)::placeholder { color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.split-studio .chat-bubble.assistant { background: var(--ui-raised) !important; color: var(--ui-text) !important; }
  html[data-fortune-theme] body.split-studio .chat-bubble.user { background: var(--ui-action) !important; color: var(--ui-action-text) !important; }
  html[data-fortune-theme] body.split-studio :is(.featured-voice strong, .voice-gallery h3, .light-icon-button, .review-notes strong, .mobile-tabs button[aria-selected="true"]) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.split-studio :is(.chat-intro, .script-document-card small, .script-document-card > span:last-child, .chat-compose-footer, .chat-compose-footer .text-button, .connection-banner, .voice-title span, .voice-workspace-heading p:not(.eyebrow), #save-state, .voice-gallery-heading a, .featured-voice small, .custom-voice-panel label, .custom-voice-toggle, .field, .range-labels, .pronunciation-details summary, .approval-box > label, .generation-cost, .writing-panel .status-line, .audio-empty, .audio-empty p, .recent-section header p, .recent-card p, .studio-footer, .light-dialog .field, .light-dialog .helper, .output-tabs button, .mobile-tabs button, .duration-heading > span) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.split-studio :is(.script-file-icon, .move-to-voice, .sign-in, .speed-heading output, .editor-footer .quiet-button, .hook-card .hook-number, .shot-card > span, .timing-row > span) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.split-studio :is(.script-file-icon, .output-tabs button[aria-selected="true"], .duration-options button[aria-pressed="true"]) { background: var(--fortune-surface-active) !important; color: var(--fortune-surface-active-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.split-studio :is(.send-script, .primary-button, .light-dialog .primary-button) { background: var(--ui-action) !important; color: var(--ui-action-text) !important; border-color: var(--ui-action) !important; }
  html[data-fortune-theme] body.split-studio .send-script:disabled { background: var(--ui-raised) !important; color: var(--ui-dim) !important; }
  html[data-fortune-theme] body.split-studio :is(.script-document-card:hover, .starter-prompts button:hover, .quiet-button:hover, .voice-topbar .quiet-button:hover, .light-dialog .quiet-button:hover, .light-dialog .icon-button:hover, .light-icon-button:hover, .icon-button:hover, .recent-card:hover, .saved-project:hover) { background: var(--ui-hover) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.split-studio :is(.recovery-box, .writing-panel .recovery-box) { background: var(--fortune-surface-active) !important; color: var(--fortune-surface-active-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.split-studio :is(.writing-panel .recovery-box strong, .writing-panel .recovery-box p, .writing-panel .recovery-box button) { color: var(--fortune-surface-active-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.split-studio :is(.status-line.error, .writing-panel .status-line.error) { color: var(--ui-error) !important; }
  html[data-fortune-theme] body.split-studio :is(.audio-empty, .audio-result, .hook-card, .shot-card, .reference-trigger, .video-reference-drop, .mobile-tabs button[aria-selected="true"]) { border-color: var(--ui-line) !important; }

  /* The marketing artwork keeps its colors while its surrounding UI changes. */
  html[data-fortune-theme] body.fortune-landing :is(.button-primary:hover, .button-tonal:hover, .hero-explore:hover) { background: var(--fortune-surface-hover) !important; color: var(--fortune-surface-text) !important; }
  html[data-fortune-theme] body.fortune-landing :is(.work-tag, .product-visual, .director-visual, .studio-visual, .tracker-visual, .mini-reference, .mini-prompt, .script-sheet, .tracker-metrics, .tracker-question, .tracker-period > span:last-child) {
    background: var(--fortune-surface-inset) !important;
    color: var(--fortune-surface-text) !important;
    border-color: var(--fortune-surface-line) !important;
  }
  html[data-fortune-theme] body.fortune-landing :is(.visual-topline, .mini-reference, .mini-prompt, .script-sheet, .tracker-metrics, .tracker-question) { background: var(--fortune-surface-panel) !important; }
  html[data-fortune-theme] body.fortune-landing .script-sheet { box-shadow: 5px 6px 0 var(--fortune-surface-line) !important; }
  html[data-fortune-theme] body.fortune-landing :is(.tag-muted, .interaction-caption, .product-index a, .product-index a span, .visual-topline small, .mini-reference > span, .script-line span, .tracker-metrics span, .preview-chart > span, .use-case-tabs > button, .use-case-tabs > button small, .footer-column h3) { color: var(--fortune-surface-muted) !important; }
  html[data-fortune-theme] body.fortune-landing :is(.product-index a.is-active, .use-case-tabs > button[aria-selected="true"]) { color: var(--fortune-surface-text) !important; }
  html[data-fortune-theme] body.fortune-landing .script-line i { background: var(--fortune-surface-line) !important; }
  html[data-fortune-theme] body.fortune-landing .preview-chart { background: repeating-linear-gradient(to bottom, transparent 0 31px, var(--fortune-surface-line) 32px 33px) !important; }
  html[data-fortune-theme="dark"] body.fortune-landing .footer-landscape { background: linear-gradient(var(--fortune-surface-bg), #31201e 25%, #793d2b 63%, #ba6246) !important; }

  /* Sign-in and legal pages were previously forced to light by the design layer. */
  html[data-fortune-theme] body.fortune-signin .signin-card { background: var(--ui-panel) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-signin :is(.signin-card p, .signin-note, #email-fields legend, #email-fields label) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.fortune-signin :is(#email-fields input, .fortune-account-panel) { background: var(--ui-inset) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-signin .signin-option { background: var(--ui-action) !important; color: var(--ui-action-text) !important; border-color: var(--ui-action) !important; }
  html[data-fortune-theme] body.fortune-signin .fortune-account-panel button { color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-legal :is(h1, h2, h3, strong, label, .brand) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.fortune-legal :is(p, li, small, .muted, .date, footer) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.fortune-legal :is(header, footer, section, article) { border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-legal :is(article, section, .contents, .deletion) { background: var(--ui-inset) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-legal :is(#message, .tag) { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.fortune-legal :is(main, footer) a { color: var(--fortune-surface-accent) !important; }
  html[data-fortune-theme] body.fortune-legal :is(input, textarea, select) { background: var(--ui-panel) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.fortune-legal main button { background: var(--ui-action) !important; color: var(--ui-action-text) !important; }

  html[data-fortune-theme] body.app-dev :is(.message.user, .message-action, .history-baseline, .check-row, .file-change pre, .setup-note, .view-tabs span, .run-progress, .device-options button.active) { background: var(--ui-inset) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-dev :is(.composer textarea, .page-picker select, .empty-panel h3) { color: var(--ui-text) !important; }
  html[data-fortune-theme] body.app-dev .page-picker select { background: var(--ui-inset) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] body.app-dev :is(.message-label, .message-status, .history-card small, .history-baseline small, .history-card .badge, .dialog-close, .setup-row strong, .device-options button) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.app-dev .composer textarea::placeholder { color: var(--ui-dim) !important; }

  /* Native dialog/audio form controls inherit the same resolved scheme. */
  html[data-fortune-theme] :is(body.fortune-ui, body.split-studio) :is(dialog, .library-dialog) {
    background: var(--ui-panel) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-line) !important;
    color-scheme: var(--fortune-surface-scheme) !important;
  }
  html[data-fortune-theme] :is(body.fortune-ui, body.split-studio) dialog::backdrop { background: var(--fortune-surface-overlay) !important; }
  html[data-fortune-theme] :is(body.fortune-ui, body.split-studio) :is(dialog p, dialog small) { color: var(--ui-muted) !important; }
  html[data-fortune-theme] body.fortune-ui dialog :is(input:not([type="checkbox"]):not([type="range"]):not([type="color"]):not([type="file"]), textarea, select) { background: var(--ui-inset) !important; color: var(--ui-text) !important; border-color: var(--ui-line) !important; }
  html[data-fortune-theme] :is(body.fortune-ui, body.split-studio) :is(.chat-composer, .ff-composer, .image-main-composer, .vs-composer):focus-within {
    border-color: var(--fortune-surface-accent) !important;
    box-shadow: 0 0 0 2px var(--fortune-surface-active) !important;
  }
}
