/* Appearance is opt-in at the BCOS document root; legacy brand/team palette primitives stay intact. */
:root[data-bcos-theme="dark"] {
  --bcos-color-canvas:#061528; --bcos-color-surface:#0b2548; --bcos-color-surface-raised:#123558;
  --bcos-color-text:#f1f7ff; --bcos-color-text-muted:#b6c8dc; --bcos-color-border:#385672;
  --bcos-color-field-border:#7b99b7; --bcos-color-accent:#79c6ff; --bcos-color-accent-text:#061528;
  --bcos-color-accent-hover:#9ed7ff; --bcos-color-focus:#9bd8ff; --bcos-color-hover:#1d466d;
  --bcos-color-success:#63db9a; --bcos-color-success-surface:#103b2d;
  --bcos-color-warning:#ffd079; --bcos-color-warning-surface:#443318;
  --bcos-color-danger:#ffb4ab; --bcos-color-danger-surface:#4a2026;
  --bcos-color-disabled:#91a5b9; --bcos-color-disabled-surface:#18324c;
  --bcos-color-chart-grid:#7b99b7; --bcos-color-chart-label:#b6c8dc; --bcos-color-chart-series:#79c6ff;
  --bcos-color-chart-fill:rgba(121,198,255,.18);
}
:root[data-bcos-theme="dark"] { --bcos-shell-canvas:var(--bcos-color-canvas); }
:root[data-bcos-theme="dark"] body:is(.bcos-page,.bcos-home-body,.bcos-evaluation-mode-body,.bcos-application-shell-active),
:root[data-bcos-theme="dark"] body.bcos-page :is(#page,.site,.site-content,.content-area,.site-main,.entry-content) {
  background:var(--bcos-color-canvas)!important; color:var(--bcos-color-text);
}

/* Shared shell chrome; active state keeps its existing aria-current and visible filled shape. */
:root[data-bcos-theme="dark"] body .bcos-person-os-shell {
  background:var(--bcos-color-surface-raised)!important; color:var(--bcos-color-text)!important;
  border-color:var(--bcos-color-border)!important;
}
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__head :is(span,strong,em) { color:var(--bcos-color-text)!important; }
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__mode,
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__modes button,
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__menu a {
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important;
  border-color:var(--bcos-color-field-border)!important;
}
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__mode:is(.is-active,[aria-current="page"]),
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__modes button.is-active {
  background:var(--bcos-color-accent)!important; color:var(--bcos-color-accent-text)!important;
}
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__mode:hover { background:var(--bcos-color-hover)!important; color:var(--bcos-color-text)!important; }
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__menu { background:var(--bcos-color-surface)!important; }
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__menu small,
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__group-label { color:var(--bcos-color-text-muted)!important; opacity:1; }
:root[data-bcos-theme="dark"] body .bcos-person-os-shell__menu a:hover { background:var(--bcos-color-hover)!important; }

/* Explicit shared surfaces and native form primitives; no blanket recoloring of arbitrary legacy widgets. */
:root[data-bcos-theme="dark"] body .bcos-theme-surface {
  box-sizing:border-box; min-width:0; margin-block:12px; padding:16px;
  border:1px solid var(--bcos-color-border); border-radius:14px;
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important;
}
:root[data-bcos-theme="dark"] body .bcos-theme-surface :is(h1,h2,h3,p,label,output) { color:inherit; }
:root[data-bcos-theme="dark"] .bcos-theme-surface form { display:flex; flex-wrap:wrap; gap:10px; }
:root[data-bcos-theme="dark"] .bcos-theme-surface label,:root[data-bcos-theme="dark"] .bcos-theme-surface form>p { flex:1 0 100%; min-width:0; }
:root[data-bcos-theme="dark"] .bcos-theme-surface label { display:grid; gap:6px; }
:root[data-bcos-theme="dark"] .bcos-theme-surface label:has(input[type="checkbox"]) { display:flex; align-items:center; }
:root[data-bcos-theme="dark"] body :is(.bcos-theme-control select,.bcos-theme-surface :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea)) {
  box-sizing:border-box; min-width:0; max-width:100%; min-height:44px; padding:8px 10px;
  border:1px solid var(--bcos-color-field-border)!important; border-radius:8px;
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important;
  color-scheme:inherit!important; font:inherit;
}
:root[data-bcos-theme="dark"] body .bcos-theme-surface :is(input,select,textarea) { accent-color:var(--bcos-color-accent); }
:root[data-bcos-theme="dark"] body .bcos-theme-surface button {
  max-width:100%; min-height:44px; padding:8px 12px; border:1px solid var(--bcos-color-accent); border-radius:8px;
  background:var(--bcos-color-accent); color:var(--bcos-color-accent-text); font:inherit;
  white-space:normal; overflow-wrap:anywhere; cursor:pointer;
}
:root[data-bcos-theme="dark"] body .bcos-theme-surface button:hover:not(:disabled) { background:var(--bcos-color-accent-hover); }
:root[data-bcos-theme="dark"] body .bcos-theme-surface :is(button,input,select,textarea):disabled {
  background:var(--bcos-color-disabled-surface)!important; color:var(--bcos-color-disabled)!important; cursor:default;
}
:root[data-bcos-theme="dark"] body .bcos-theme-surface [aria-invalid="true"] { border-color:var(--bcos-color-danger)!important; }
:root[data-bcos-theme="dark"] body .bcos-theme-surface .bcos-theme-error { color:var(--bcos-color-danger)!important; }
:root[data-bcos-theme="dark"] body .bcos-theme-surface .bcos-theme-success { color:var(--bcos-color-success)!important; }
:root[data-bcos-theme="dark"] body :is(.bcos-theme-control select,.bcos-theme-surface button,.bcos-theme-surface input,.bcos-theme-surface select,.bcos-theme-surface textarea,.bcos-person-os-shell a,.bcos-person-os-shell button,.bcos-person-os-shell summary,.bcos-workbench-dialog button,.bcos-roster-evaluation button,.bcos-player-quick-profile__evaluate,.bcos-idp-session-roster-panel__live-evaluation):focus-visible {
  outline:2px solid var(--bcos-color-focus)!important; outline-offset:3px;
  box-shadow:0 0 0 2px var(--bcos-color-surface)!important;
}

/* Real shared timeline card, including date/details text rather than only its outer panel. */
:root[data-bcos-theme="dark"] body .bcos-universal-timeline-card {
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important; border-color:var(--bcos-color-border)!important;
}
/* Muted cards remain readable and actionable; Past/status/borders retain the state cues. */
:root[data-bcos-theme="dark"] body .bcos-universal-timeline-card.is-muted { opacity:1; }
:root[data-bcos-theme="dark"] body .bcos-universal-timeline-card :is(h3,p,.bcos-universal-timeline-card__title-text,.bcos-universal-timeline-card__date strong,.bcos-universal-timeline-card__date b,.bcos-universal-timeline-card__date span) { color:var(--bcos-color-text)!important; }
:root[data-bcos-theme="dark"] body .bcos-universal-timeline-card__date { border-color:var(--bcos-color-border)!important; }
:root[data-bcos-theme="dark"] body .bcos-universal-timeline-card__mode { color:var(--bcos-color-accent)!important; }

/* Root attributes also cover body portals. Keep the established focus/escape owner unchanged. */
:root[data-bcos-theme="dark"] body :is(.bcos-workbench-dialog,.bcos-roster-evaluation>section) {
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important; border-color:var(--bcos-color-border)!important;
}
:root[data-bcos-theme="dark"] body .bcos-workbench-dialog>header,
:root[data-bcos-theme="dark"] body .bcos-roster-evaluation>section>header { display:flex!important; }
:root[data-bcos-theme="dark"] body :is(.bcos-workbench-dialog,.bcos-roster-evaluation)>header,
:root[data-bcos-theme="dark"] body .bcos-roster-evaluation>section>header {
  background:var(--bcos-color-surface-raised)!important; color:var(--bcos-color-text)!important;
}
:root[data-bcos-theme="dark"] body .bcos-workbench-dialog>header button,
:root[data-bcos-theme="dark"] body .bcos-roster-evaluation>section>header button {
  background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important; border-color:var(--bcos-color-field-border)!important;
}
:root[data-bcos-theme="dark"] body :is(.bcos-workbench-dialog,.bcos-roster-evaluation,.bcos-roster-evaluation-inline) iframe { background:var(--bcos-color-canvas)!important; }

/* Compatibility aliases for existing consumers; component-owned evaluation styles can use the same interface. */
:root[data-bcos-theme="dark"] body .bcos-evaluation-mode {
  --eval-ink:var(--bcos-color-text); --eval-muted:var(--bcos-color-text-muted); --eval-line:var(--bcos-color-border);
  --eval-panel:var(--bcos-color-surface); --eval-soft:var(--bcos-color-surface-raised); --eval-blue:var(--bcos-color-accent);
  --eval-green:var(--bcos-color-success); --eval-warn:var(--bcos-color-warning);
}
:root[data-bcos-theme="dark"] body.bcos-evaluation-mode-body :is(.bcos-evaluation-shell,.bcos-evaluation-shell__body,#bcos-evaluation-mode-root) {
  background:var(--bcos-color-canvas)!important; color:var(--bcos-color-text);
}
:root[data-bcos-theme="dark"] body .bcos-evaluation-panel:not(.bcos-player-evaluation__intro) { background:var(--bcos-color-surface)!important; color:var(--bcos-color-text)!important; }
:root[data-bcos-theme="dark"] body .bcos-skill-radar :is(span,strong,small,h3) { color:var(--bcos-color-text)!important; }
:root[data-bcos-theme="dark"] body .bcos-skill-radar svg>circle,
:root[data-bcos-theme="dark"] body .bcos-skill-radar svg>line { fill:none; stroke:var(--bcos-color-chart-grid)!important; stroke-width:1.5; }
:root[data-bcos-theme="dark"] body .bcos-skill-radar svg>polygon { fill:var(--bcos-color-chart-fill)!important; stroke:var(--bcos-color-chart-series)!important; }
:root[data-bcos-theme="dark"] body .bcos-skill-radar svg>text { fill:var(--bcos-color-chart-label)!important; }
:root[data-bcos-theme="dark"] body :is(.bcos-standings,.bcos-standings-dialog) {
  --standings-bg:var(--bcos-color-canvas); --standings-panel:var(--bcos-color-surface); --standings-ink:var(--bcos-color-text);
  --standings-muted:var(--bcos-color-text-muted); --standings-line:var(--bcos-color-field-border); --standings-accent:var(--bcos-color-accent);
  color-scheme:inherit!important;
}
@media(max-width:640px) {
  :root[data-bcos-theme="dark"] body .bcos-person-os-shell__head { grid-template-columns:minmax(0,1fr); gap:4px; text-align:center; }
  :root[data-bcos-theme="dark"] body .bcos-person-os-shell__head :is(span,strong,em) { grid-column:1; justify-self:center; white-space:normal; overflow:visible; overflow-wrap:anywhere; }
}
@media(forced-colors:active) {
  :root[data-bcos-theme="dark"] body :is(.bcos-theme-control select,.bcos-theme-surface button,.bcos-theme-surface input,.bcos-theme-surface select,.bcos-theme-surface textarea):focus-visible { outline-color:Highlight!important; box-shadow:none!important; }
}
@media print {
  :root[data-bcos-theme="dark"] {
    color-scheme:only light!important; --bcos-color-canvas:#fff; --bcos-color-surface:#fff; --bcos-color-surface-raised:#fff;
    --bcos-color-text:#10243a; --bcos-color-text-muted:#425c73; --bcos-color-border:#6d8195; --bcos-color-field-border:#6d8195;
    --bcos-color-accent:#075eaa; --bcos-color-accent-text:#fff; --bcos-color-accent-hover:#064d8b;
    --bcos-color-focus:#095ed0; --bcos-color-hover:#e5f1ff;
    --bcos-color-success:#146c43; --bcos-color-success-surface:#e8f6ee;
    --bcos-color-warning:#945600; --bcos-color-warning-surface:#fff3d4;
    --bcos-color-danger:#b42318; --bcos-color-danger-surface:#fff0ee;
    --bcos-color-disabled:#617487; --bcos-color-disabled-surface:#e8edf2;
    --bcos-color-chart-grid:#71869b; --bcos-color-chart-label:#425c73; --bcos-color-chart-series:#075eaa; --bcos-color-chart-fill:rgba(7,94,170,.18);
  }
}
