/* Palettes live in theme-config.js. Rules here only consume semantic tokens. */
html { background-color: var(--background); color: var(--foreground); }
html.dark { color-scheme: dark; }
body { background-color: var(--background); color: var(--foreground); }
html.radar-theme-switching, html.radar-theme-switching body,
html.radar-theme-switching body *:not(video):not(canvas):not(iframe) {
  transition-property: background-color, color, border-color, box-shadow, fill, stroke;
  transition-duration: 180ms;
  transition-timing-function: ease;
}
.radar-theme-control {
  display: inline-flex; position: relative; align-items: center; gap: 6px;
  flex: 0 0 auto; min-width: 0; min-height: 34px; padding: 0 8px;
  color: var(--foreground); background: var(--card); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow-sm); cursor: pointer;
  animation: radar-theme-enter 180ms ease both;
  transition: transform 140ms ease, border-color 140ms ease, background-color 180ms ease;
}
.radar-theme-control:hover { transform: scale(1.025); border-color: var(--primary-border); background: var(--surface-subtle); }
.radar-theme-control:active { transform: scale(.98); }
.radar-theme-control:focus-within { outline: 2px solid var(--ring); outline-offset: 2px; }
.radar-theme-control:has(select:disabled) { opacity: .5; cursor: not-allowed; transform: none; }
.radar-theme-control .radar-theme-icon { display: inline-flex; color: var(--primary); pointer-events: none; }
.radar-theme-control select {
  appearance: auto; display: block; width: auto; min-width: 82px; height: 32px;
  margin: 0; padding: 0 2px; background: transparent; color: var(--foreground);
  border: 0; border-radius: 6px; outline: none; box-shadow: none;
  font: inherit; font-size: 12px; line-height: 1.3; cursor: pointer;
}
.radar-theme-control select:disabled { cursor: not-allowed; }
.radar-theme-control option { color: var(--popover-foreground); background: var(--popover); }
.radar-theme-page-controls { display: flex; justify-content: flex-end; padding: 12px 18px; position: fixed; top: 0; right: 0; z-index: 100; }
.radar-theme-page-controls:empty { display: none; }
.ak-reader iframe, .av-rich-frame, .radar-report-preview iframe {
  background: var(--background); transition: opacity 180ms ease;
}
@keyframes radar-theme-enter { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  html.radar-theme-switching, html.radar-theme-switching body,
  html.radar-theme-switching body *:not(video):not(canvas):not(iframe),
  .radar-theme-control { transition: none !important; animation: none !important; }
  .ak-reader iframe, .av-rich-frame, .radar-report-preview iframe { transition: none !important; }
  .radar-theme-control:hover, .radar-theme-control:active { transform: none; }
}
@media print {
  .radar-theme-control, .radar-theme-page-controls { display: none !important; }
  html, body { background: var(--print-card) !important; color: var(--print-foreground) !important; }
}

/* In-page theme menu 86: no browser/OS select popup, bounded to the viewport. */
.radar-theme-control{padding:0;animation:none}
.radar-theme-trigger{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:34px;padding:0 9px;border:0;background:transparent;color:inherit;font:inherit;font-size:12px;white-space:nowrap;cursor:pointer;border-radius:inherit}
.radar-theme-control:has(button:disabled){opacity:.5;cursor:not-allowed;transform:none}
.radar-theme-trigger:disabled{cursor:not-allowed}
.radar-theme-trigger[aria-expanded=true]{background:var(--surface-inset);color:var(--primary)}
.radar-theme-trigger:focus-visible{outline:2px solid var(--ring);outline-offset:2px}
.radar-theme-chevron{display:inline-flex;transition:transform 160ms ease}
.radar-theme-trigger[aria-expanded=true] .radar-theme-chevron{transform:rotate(180deg)}
.radar-theme-menu{position:fixed;z-index:3100;box-sizing:border-box;padding:6px;overflow-y:auto;overscroll-behavior:contain;background:var(--popover);color:var(--popover-foreground);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-md);animation:radar-theme-enter 140ms ease both}
.radar-theme-menu[hidden]{display:none!important}
.radar-theme-menu button{display:flex;align-items:center;width:100%;min-height:38px;padding:8px 12px;border:0;border-radius:7px;background:transparent;color:inherit;font:inherit;font-size:13px;cursor:pointer;text-align:left;transition:background-color 140ms ease,transform 140ms ease}
.radar-theme-menu button:hover,.radar-theme-menu button:focus-visible{background:var(--surface-inset);color:var(--primary);outline:2px solid var(--ring);outline-offset:-2px}
.radar-theme-menu button:active{transform:scale(.98)}
.radar-theme-menu button[aria-checked=true]{background:var(--primary-soft);color:var(--primary);font-weight:700}
@media(prefers-reduced-motion:reduce){.radar-theme-menu,.radar-theme-menu button,.radar-theme-chevron{animation:none!important;transition:none!important}.radar-theme-menu button:active{transform:none}}
@media print{.radar-theme-menu{display:none!important}}

/* Selection contract: solid tabs/chips, softer content cards, and native marks.
   Scope to actual selection controls: status badges, running jobs and open panes
   intentionally keep their own state styling. Inset marks never change layout. */
html[data-theme] :is(
  .nav-btn, .platform-nav-item, .view-mode-btn, .segmented-btn, .studio-tab,
  .creator-segment-btn, .tracking-status-chip, .draft-view-tab, .creator-pill-btn,
  .video-plat-tab, .settings-nav a, .settings-tab, .release-filter button,
  .cos-tabs button, .cw-stage-tabs button, .ctx-tabs button, .comment-tools button,
  .topics-status-filters button, .lh-tabs button, .lh-window button,
  .ve-shell-tabs button, .vk-tabs button, .vk-source-tabs button, .ml-tabs button,
  .daily-categories button, .em-source-tabs button, .gh-views button,
  .rk-tabs button, .rt-tabs button, .vmf-quick button,
  .hot-tabs [aria-selected], .hot-categories [aria-selected],
  button[aria-pressed], [role="tab"], [role="radio"], [role="menuitemradio"]
) {
  background-color: var(--control-bg);
  color: var(--control-foreground);
  border-color: var(--control-border);
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease,
    box-shadow 180ms ease, transform 140ms ease;
}
html[data-theme] :is(
  .nav-btn, .platform-nav-item, .view-mode-btn, .segmented-btn, .studio-tab,
  .creator-segment-btn, .tracking-status-chip, .draft-view-tab, .creator-pill-btn,
  .video-plat-tab, .settings-nav a, .settings-tab, .release-filter button,
  .cos-tabs button, .cw-stage-tabs button, .ctx-tabs button, .comment-tools button,
  .topics-status-filters button, .lh-tabs button, .lh-window button,
  .ve-shell-tabs button, .vk-tabs button, .vk-source-tabs button, .ml-tabs button,
  .daily-categories button, .em-source-tabs button, .gh-views button,
  .rk-tabs button, .rt-tabs button, .vmf-quick button,
  .hot-tabs [aria-selected], .hot-categories [aria-selected],
  button[aria-pressed], [role="tab"], [role="radio"], [role="menuitemradio"]
):hover:not(:disabled):not([disabled]):not([aria-disabled="true"]):not([aria-busy="true"]):not(.is-loading):not(.loading) {
  background-color: var(--control-hover);
  border-color: var(--selection-border);
  transform: scale(1.012);
}
html[data-theme] :is(
  .nav-btn.active, .nav-btn[aria-current="page"], .platform-nav-item.active,
  .view-mode-btn.active, .segmented-btn.active, .studio-tab.active,
  .creator-segment-btn.active, .tracking-status-chip.active, .draft-view-tab.active,
  .creator-pill-btn.active, .video-plat-tab.active, .settings-nav a.active,
  .release-filter button.active, .cos-tabs button.active, .ctx-tabs button.active,
  .comment-tools button.active, .topics-status-filters button.active,
  .lh-tabs button.is-active, .lh-window button.is-active,
  button[aria-pressed="true"], [role="tab"][aria-selected="true"],
  .settings-tab[aria-selected="true"], .ve-shell-tabs [aria-selected="true"],
  .vk-tabs [aria-selected="true"], .vk-source-tabs [aria-selected="true"],
  .ml-tabs [aria-selected="true"], .hot-tabs [aria-selected="true"],
  .hot-categories [aria-selected="true"], .rt-tabs [aria-selected="true"],
  .rk-tabs [aria-selected="true"], [role="radio"][aria-checked="true"],
  [role="menuitemradio"][aria-checked="true"]
):not(:disabled):not([disabled]):not([aria-disabled="true"]):not([aria-busy="true"]):not(.is-loading):not(.loading) {
  background-color: var(--selection-bg);
  color: var(--selection-foreground);
  border-color: var(--selection-border);
  box-shadow: inset 0 -3px 0 var(--selection-border);
  font-weight: 750;
}
html[data-theme] :is(
  .nav-btn.active, .nav-btn[aria-current="page"], .platform-nav-item.active,
  .view-mode-btn.active, .segmented-btn.active, .studio-tab.active,
  .creator-segment-btn.active, .tracking-status-chip.active, .draft-view-tab.active,
  .creator-pill-btn.active, .video-plat-tab.active, .settings-nav a.active,
  .release-filter button.active, .cos-tabs button.active, .ctx-tabs button.active,
  .comment-tools button.active, .topics-status-filters button.active,
  .lh-tabs button.is-active, .lh-window button.is-active,
  button[aria-pressed="true"], [role="tab"][aria-selected="true"],
  .settings-tab[aria-selected="true"], .ve-shell-tabs [aria-selected="true"],
  .vk-tabs [aria-selected="true"], .vk-source-tabs [aria-selected="true"],
  .ml-tabs [aria-selected="true"], .hot-tabs [aria-selected="true"],
  .hot-categories [aria-selected="true"], .rt-tabs [aria-selected="true"],
  .rk-tabs [aria-selected="true"], [role="radio"][aria-checked="true"],
  [role="menuitemradio"][aria-checked="true"]
):hover:not(:disabled):not([disabled]):not([aria-disabled="true"]):not([aria-busy="true"]):not(.is-loading):not(.loading) {
  background-color: var(--selection-hover);
  color: var(--selection-foreground);
}
/* Existing badge/subtitle rules are later in component stylesheets; keep them
   legible on the solid selected background without recolouring platform logos. */
html[data-theme] :is(.nav-btn.active, .nav-btn[aria-current="page"], .platform-nav-item.active,
  .creator-segment-btn.active, .creator-pill-btn.active, .video-plat-tab.active,
  .view-mode-btn.active, .segmented-btn.active) :is(
  small, .nav-count, .plat-badge, .seg-badge, .rail-count, .creator-pill-platform,
  .creator-pill-count, .platform-count, .count
) { color: var(--selection-muted); background-color: transparent; }
html[data-theme] :is(.nav-btn.active, .nav-btn[aria-current="page"]) .nav-dot {
  background-color: var(--selection-muted); color: var(--selection-foreground);
}

/* Mixed-content results remain readable, while an inset leading stripe and
   double-width inner boundary identify selection independently of fill colour. */
html[data-theme] :is(
  .feed-card.active, .video-card-item.selected, .creator-row.selected,
  .hw-card.selected, .hot-card.selected, .keyword-topics .keyword-video-card.selected,
  .cw-asset.is-selected, .lh-account.is-selected, .lh-daily tr.is-selected,
  .ml-table tr[aria-selected="true"], .rt-row[aria-pressed="true"],
  button.vk-record.is-selected, .pv-run-list button[aria-pressed="true"],
  .ve-task-choice[aria-pressed="true"],
  .pv-provider-choice:has(input:checked:not(:disabled)),
  .ve-source-option:has(input:checked:not(:disabled)),
  .pi-choice:has(input:checked:not(:disabled))
):not(:disabled):not([disabled]):not([aria-disabled="true"]):not([aria-busy="true"]):not(.is-loading):not(.loading) {
  background-color: var(--selection-surface);
  color: var(--selection-surface-foreground);
  border-color: var(--selection-border);
  box-shadow: inset 4px 0 0 var(--selection-border), inset 0 0 0 2px var(--selection-border);
}
html[data-theme] :is(.creator-row.selected .creator-name-text, .feed-card.active .feed-card-title,
  .video-card-item.selected .video-card-title, .cw-asset.is-selected > strong,
  .lh-account.is-selected > strong) { color: var(--selection-surface-foreground); font-weight: 750; }
html[data-theme] :is(.lh-daily tr.is-selected, .ml-table tr[aria-selected="true"]) > td {
  background-color: var(--selection-surface); color: var(--selection-surface-foreground);
}
html[data-theme] input:is([type="checkbox"], [type="radio"]) {
  accent-color: var(--selection-bg);
}
html[data-theme] :is(.schedule-switch input:checked + .schedule-switch-slider,
  [role="switch"][aria-checked="true"]):not([aria-disabled="true"]) {
  background-color: var(--selection-bg); border-color: var(--selection-border);
}
html[data-theme] :is(.nav-btn, .platform-nav-item, .view-mode-btn, .segmented-btn,
  .studio-tab, .creator-segment-btn, .draft-view-tab, .creator-pill-btn, .video-plat-tab,
  .settings-tab, .settings-nav a, .cos-tabs button, .cw-stage-tabs button,
  button[aria-pressed], [role="tab"], [role="radio"], [role="menuitemradio"],
  input[type="checkbox"], input[type="radio"]):focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
html[data-theme] :is(.pv-provider-choice, .ve-source-option, .pi-choice):has(input:focus-visible) {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
html[data-theme] :is(button[aria-pressed], [role="tab"], [role="radio"],
  [role="menuitemradio"], .settings-tab, .segmented-btn, .creator-pill-btn,
  .video-plat-tab):is(:disabled, [disabled], [aria-disabled="true"]) {
  background-color: var(--muted); color: var(--muted-foreground);
  border-color: var(--border); box-shadow: none; opacity: .65;
  cursor: not-allowed; transform: none;
}
html[data-theme] :is(.pv-provider-choice, .ve-source-option, .pi-choice):has(input:disabled) {
  background-color: var(--muted); color: var(--muted-foreground);
  border-color: var(--border); border-style: dashed; box-shadow: none; cursor: not-allowed;
}
/* Lucide Check; only text-only menu choices receive the additional icon. */
html[data-theme] .radar-theme-menu button::after {
  content: ''; flex: 0 0 16px; width: 16px; height: 16px; margin-inline-start: auto;
  background-color: currentColor; opacity: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='m20 6-11 11-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='m20 6-11 11-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
html[data-theme] .radar-theme-menu button[aria-checked="true"]::after { opacity: 1; }

/* Apple-inspired surfaces: neutral hierarchy and modest depth, never a new
   layout, large blurred pane or animated filter. Existing density is retained. */
html[data-theme="apple"] :is(.cos-card, .cos-home-card, .feed-card, .settings-card,
  .settings-section, .cos-project, .cw-project-card, .cw-media-card,
  .video-card-item, .creator-row, .pv-panel, .ve-panel, .ml-panel) {
  background-color: var(--card); color: var(--card-foreground);
  border-color: var(--border); border-radius: 12px; box-shadow: var(--shadow-sm);
}
html[data-theme="apple"] :is(.cos-quick-capture, .cos-kanban section, .cos-inbox,
  .cos-metric-grid > div) { background-color: var(--surface-subtle); border-color: var(--border); }
html[data-theme="apple"] :is(.feed-card.active, .video-card-item.selected,
  .creator-row.selected, .cw-asset.is-selected) {
  background-color: var(--selection-surface); color: var(--selection-surface-foreground);
  border-color: var(--selection-border);
  box-shadow: inset 4px 0 0 var(--selection-border), inset 0 0 0 2px var(--selection-border), var(--shadow-sm);
}
html[data-theme="apple"] body { background: var(--background); }
html[data-theme="apple"] :is(.top-header, .side-nav) {
  background: color-mix(in srgb, var(--card) 86%, transparent);
  border-color: var(--border);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  backdrop-filter: blur(18px) saturate(125%);
}
html[data-theme="apple"] .taskbar {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 -1px 8px color-mix(in srgb, var(--foreground) 5%, transparent);
}
html[data-theme="apple"] :is(.icon-btn, .btn.ghost, .site-navigation-trigger) {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}
html[data-theme="apple"] :is(.icon-btn, .btn.ghost, .site-navigation-trigger):hover {
  background: var(--control-hover);
  border-color: var(--border-strong);
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] :is(button[aria-pressed], [role="tab"], [role="radio"],
    [role="menuitemradio"], .nav-btn, .platform-nav-item, .view-mode-btn,
    .segmented-btn, .studio-tab, .creator-segment-btn, .tracking-status-chip,
    .draft-view-tab, .creator-pill-btn, .video-plat-tab, .settings-nav a,
    .settings-tab, .release-filter button, .cos-tabs button, .cw-stage-tabs button,
    .ctx-tabs button, .comment-tools button, .topics-status-filters button,
    .lh-tabs button, .lh-window button, .ve-shell-tabs button, .vk-tabs button,
    .vk-source-tabs button, .ml-tabs button, .daily-categories button,
    .em-source-tabs button, .gh-views button, .rk-tabs button, .rt-tabs button,
    .vmf-quick button, .hot-tabs [aria-selected], .hot-categories [aria-selected]) {
    transition: none; animation: none; transform: none;
  }
}
