.portfolio-theme-host { position: relative; }

.portfolio-theme {
  position: absolute;
  inset-block-start: var(--portfolio-theme-y, 0);
  inset-inline-end: var(--portfolio-theme-end, 0);
  z-index: 5;
}

.portfolio-theme-floating {
  position: fixed;
  inset-block-start: max(12px, env(safe-area-inset-top));
  inset-inline-end: max(12px, env(safe-area-inset-right));
}

.portfolio-theme-in-panel { position: static; margin-inline-start: auto; }
.portfolio-theme-in-pane {
  inset-block-start: clamp(1.25rem, 4vw, 3.5rem);
  inset-inline-end: clamp(1.25rem, 4vw, 3.5rem);
}

html[data-portfolio-site] [data-portfolio-theme-duplicate] { visibility: hidden; }

html[data-portfolio-site] :is(.portfolio-theme, .theme-toggle) {
  --portfolio-theme-ink: light-dark(#344154, #c5d0de);
  box-sizing: border-box;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  color: var(--portfolio-theme-ink);
  background: color-mix(in srgb, var(--portfolio-theme-ink) 4%, transparent);
  border: 1px solid color-mix(in srgb, var(--portfolio-theme-ink) 23%, transparent);
  border-radius: 999px;
}

html[data-portfolio-site] :is(.portfolio-theme, .theme-toggle) :is(.portfolio-theme-button, .theme-toggle-btn) {
  box-sizing: border-box;
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  cursor: pointer;
  color: var(--portfolio-theme-ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

html[data-portfolio-site] :is(.portfolio-theme, .theme-toggle) :is(.portfolio-theme-button, .theme-toggle-btn) svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
}

html[data-portfolio-site] :is(.portfolio-theme, .theme-toggle) :is(.portfolio-theme-button, .theme-toggle-btn):hover,
html[data-portfolio-site] :is(.portfolio-theme, .theme-toggle) :is(.portfolio-theme-button, .theme-toggle-btn)[aria-pressed="true"] {
  color: light-dark(#152335, #f5f8fc);
  background: color-mix(in srgb, var(--portfolio-theme-ink) 16%, transparent);
}

.portfolio-theme .portfolio-theme-button:focus-visible {
  outline: 2px solid light-dark(#1765b3, #9ac6ff);
  outline-offset: 2px;
}

@media (max-width: 800px) {
  html[data-portfolio-site] [data-portfolio-theme-duplicate] { display: none !important; }
  html[data-portfolio-site="cognizetrade"] .access-theme:has([data-portfolio-theme-duplicate]) { display: none; }
}

html[data-portfolio-site="cognizetrade"][data-theme="light"] .access-layout .workspace-intro,
html[data-portfolio-site="capmandate"][data-theme="light"] .mandate-access .mandate-access-overview {
  color: #1c3045;
  background: radial-gradient(ellipse at 10% 65%, #d9eaf3, transparent 76%), #eef4f9;
  border-color: #c3d3e1;
}

html[data-portfolio-site="cognizetrade"] .access-layout .access-panel {
  background-color: var(--ct-surface);
}

html[data-portfolio-site="capmandate"] .mandate-access .mandate-access-form {
  background-color: var(--bg-elev);
}

html[data-portfolio-site="cognizetrade"][data-theme="light"] .workspace-intro :is(.workspace-label, .mobile-story-accent),
html[data-portfolio-site="capmandate"][data-theme="light"] .mandate-access-overview :is(.mandate-brand strong, .mandate-story h2 span, .mandate-coverage dt) {
  color: #205a76;
}

html[data-portfolio-site="cognizetrade"][data-theme="light"] .workspace-intro .workspace-description,
html[data-portfolio-site="capmandate"][data-theme="light"] .mandate-access-overview :is(.mandate-source, .mandate-coverage dd) {
  color: #405b71;
}

html[data-portfolio-site="capmandate"][data-theme="light"] .mandate-access-overview :is(.mandate-coverage, .mandate-coverage div) {
  border-color: #c3d3e1;
}

html[data-portfolio-palette="workspace"][data-theme="light"] {
  --theme-page: #f5f7fa;
  --theme-story: #e9f2f5;
  --theme-panel: #ffffff;
  --theme-raised: #edf2f7;
  --theme-ink: #15273b;
  --theme-muted: #4c6077;
  --theme-line: #c5d1de;
  --theme-accent: #146555;
  --bg: var(--theme-page);
  --bg-elev: var(--theme-panel);
  --bg-row: #f0f4f8;
  --bg-deep: #edf2f7;
  --bg-input: var(--theme-panel);
  --border: var(--theme-line);
  --border-strong: #aebed0;
  --border-hover: #819ab1;
  --text: var(--theme-ink);
  --muted: var(--theme-muted);
  --faint: #5a6e84;
  --label: #334e66;
  --buy: #087441;
  --sell: #b52538;
  --warn: #865c05;
  --accent: #146780;
  --chip: #edf2f7;
  --panel: var(--theme-panel);
  --btn-face: #e8f1f6;
  --btn-primary: #d8edf3;
  --btn-primary-border: #9bc4d0;
  --chip-on-bg: #d8edf3;
  --chip-on-border: #9bc4d0;
  --row-odd: var(--theme-panel);
  --row-even: #f0f4f9;
  --row-hover: #e2edf7;
  --workspace-bg: var(--theme-page);
  --surface: var(--theme-panel);
  --surface-raised: var(--theme-raised);
  --ink: var(--theme-ink);
  --line: var(--theme-line);
  --scroll-track: var(--theme-page);
  --scroll-thumb: #9baec2;
  --scroll-thumb-hover: #758ca4;
  scrollbar-color: #9baec2 var(--theme-page);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(body, .app-shell, .main-content, .login-layout, .login-page, .sign-in, .min-h-screen.bg-slate-950) {
  background-color: var(--theme-page);
  color: var(--theme-ink);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-overview, .sign-in-story, .login-story) {
  color: var(--theme-ink);
  background: var(--theme-story);
  border-color: var(--theme-line);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-access, .sign-in-access) {
  color: var(--theme-ink);
  background: var(--theme-page);
  border-color: var(--theme-line);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-overview, .sign-in-story, .login-story, .login-access, .sign-in-access) :is(h1, h2, .story-title, .brand, .sign-in-brand, .wordmark, strong, form label) {
  color: var(--theme-ink);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-overview, .sign-in-story, .login-story) :is(h1 span, .story-title span, .wordmark .accent) {
  color: var(--theme-accent);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-intro, .story-description, .story-sources, .login-source, .login-sources, .sign-in-footnote, .login-story-body > p, .story-title + p, .sign-in-intro > p, .login-features, .login-features span, .story-features li, .sign-in-capabilities p, .workspace-status, .sign-in-status) {
  color: var(--theme-muted);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.sidebar, .topbar, .card, .card-pad, .panel, .field, .input) {
  color: var(--theme-ink);
  background-color: var(--theme-panel);
  border-color: var(--theme-line);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.nav-item, .workspace-label, .workspace-label strong, .workspace-label div > span, .nav-group-label, .brand-caption, .label, .section-title, .th, .td, .auth-copy) {
  color: var(--theme-muted);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.nav-item-active, .nav-item:hover, .btn, .btn-secondary, .toggle-btn, .seg, .seg-btn-active, .tab-btn-active) {
  color: var(--theme-ink);
  background-color: var(--theme-raised);
  border-color: var(--theme-line);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.bg-slate-950, .bg-slate-900, .bg-ink-950, .bg-ink-900) { background-color: var(--theme-panel); }
html[data-portfolio-palette="workspace"][data-theme="light"] :is(.bg-slate-800, .bg-ink-800, .bg-ink-700) { background-color: var(--theme-raised); }
html[data-portfolio-palette="workspace"][data-theme="light"] :is(.border-slate-800, .border-slate-700, .border-ink-800, .border-ink-700) { border-color: var(--theme-line); }
html[data-portfolio-palette="workspace"][data-theme="light"] :is(.text-white, .text-slate-100, .text-slate-200, .text-slate-300):not(.btn-primary) { color: var(--theme-ink); }
html[data-portfolio-palette="workspace"][data-theme="light"] :is(.text-slate-400, .text-slate-500) { color: var(--theme-muted); }
html[data-portfolio-palette="workspace"][data-theme="light"] :is(.text-teal-200, .text-teal-300, .text-teal-400, .text-emerald-300, .text-emerald-400):not([class*="bg-teal-9"]) { color: var(--theme-accent); }

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-page, .login-layout, .sign-in) input:not([type="checkbox"]) {
  color-scheme: light;
  color: var(--theme-ink);
  background: var(--theme-panel);
  border-color: var(--theme-line);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.login-page, .login-layout, .sign-in) input:focus {
  border-color: var(--theme-accent);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.sign-in-brand, .wordmark, .login-story > :first-child) :is(.text-white, .text-slate-100) {
  color: var(--theme-ink);
}

html[data-portfolio-palette="workspace"][data-theme="light"] :is(.btn-primary, .sign-in-submit, .sign-in-button, .login-submit) {
  background: #176955;
  color: #fff;
  border-color: #176955;
}

html[data-portfolio-site="claired"][data-theme="dark"] main.auth-page {
  background: #0a0e14;
  color: #e3eaf2;
}

html[data-portfolio-site="mindscale"][data-theme="dark"] {
  --ink: #edf1fa;
  --ink-soft: #ccd6e7;
  --muted: #aebbd0;
  --subtle: #a7b4c9;
  --line: #293852;
  --line-strong: #435675;
  --paper: #0d1425;
  --surface: #141e33;
  --brand: #9bb0ff;
}
