.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;
  touch-action: manipulation;
  color: var(--portfolio-theme-ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

html[data-portfolio-site="mindscale"] .site-header .portfolio-theme {
  --portfolio-theme-ink: #e4edff;
  background: #101b34;
  border-color: #617698;
}

html[data-portfolio-site="mindscale"] .site-header .portfolio-theme .portfolio-theme-button:is(:hover, [aria-pressed="true"]) {
  color: #fff;
  background: #3c547d;
}

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:is([data-portfolio-site="hypothesislens"], [data-portfolio-site="alphaq-public"], [data-portfolio-site="claired"], [data-portfolio-site="insidertrigger"])[data-mobile-sign-in] {
    --portfolio-login-page: light-dark(#f5f7fa, #0b1424);
    --portfolio-login-story: light-dark(#e9f2f5, #142131);
    --portfolio-login-divider: light-dark(#c5d1de, #304154);
    --portfolio-login-top: 24px;

    .auth-page:has(.mobile-sign-in-story) {
      background: var(--portfolio-login-page);
    }

    .auth-page > .auth-card:has(> .mobile-sign-in-story) {
      background: transparent;
      box-shadow: none !important;
    }

    .mobile-sign-in-story {
      position: relative;
      margin-block: calc(-1 * var(--portfolio-login-top)) 2rem;
      padding-block: var(--portfolio-login-top) 1.5rem;
      background: var(--portfolio-login-story);
      box-shadow: 0 0 0 100vmax var(--portfolio-login-story);
      clip-path: inset(0 -100vmax);
    }

    .mobile-sign-in-story::after {
      position: absolute;
      inset: auto 0 0;
      height: 1px;
      background: var(--portfolio-login-divider);
      box-shadow: 0 0 0 100vmax var(--portfolio-login-divider);
      clip-path: inset(0 -100vmax);
      pointer-events: none;
      content: "";
    }
  }

  /* The mobile sign-in form is the page. Use the document scrollport so the
     browser can handle its normal pull-to-refresh gesture. */
  html:is([data-portfolio-site="hypothesislens"], [data-portfolio-site="alphaq-public"])[data-mobile-sign-in="dialog"] {
    --portfolio-login-top: max(24px, env(safe-area-inset-top));
    overflow: visible;
    overscroll-behavior-y: auto;
    background: var(--portfolio-login-page);

    body {
      overflow: visible;
      overscroll-behavior-y: auto;
      background: transparent;
    }

    #root, #root :has(.user-settings-popover[data-mobile-sign-in-panel]) {
      display: contents !important;
    }

    :is(#root, #root :has(.user-settings-popover[data-mobile-sign-in-panel]))
      > :not(.user-settings-popover[data-mobile-sign-in-panel], :has(.user-settings-popover[data-mobile-sign-in-panel])) {
      display: none !important;
    }

    #root .user-settings-popover[data-mobile-sign-in-panel] {
      box-sizing: border-box;
      position: relative !important;
      inset: auto !important;
      min-height: 100dvh;
      overflow: visible !important;
      overscroll-behavior-y: auto;
      touch-action: pan-y pinch-zoom;
      transform: none !important;
      background: var(--portfolio-login-page);
      color: light-dark(#15273b, #edf3fc);
    }
  }

  html[data-portfolio-site="hypothesislens"][data-mobile-sign-in="dialog"] [data-mobile-sign-in-panel] .user-settings-header {
    border-block-end: 0;
    padding-block-end: 0;
  }

  html[data-portfolio-site="claired"] main.auth-page p.auth-help {
    display: none;
  }

  html[data-portfolio-site="insidertrigger"][data-theme="light"][data-mobile-sign-in="standalone"] {
    body, .app-shell.on-auth, .auth-page {
      background: var(--portfolio-login-page);
      color: #15273b;
    }

    .auth-page :is(.auth-card, .reference-login-anchor, .reference-login-dropdown, .reference-login-card) {
      border: 0;
      background: transparent;
      box-shadow: none;
    }

    .mobile-sign-in-story h1 span { color: #146555; }
    .mobile-sign-in-story p { color: #4c6077; }

    .auth-page .auth-card :is(.reference-login-title, .mobile-login-heading, .reference-login-title--compact) {
      color: #15273b;
      font-family: inherit;
      font-size: clamp(1.45rem, 4vw, 1.7rem);
      letter-spacing: -.025em;
    }

    .auth-page .reference-login-card input:not([type="checkbox"]) {
      background: #fff;
      color: #15273b;
      border-color: #c5d1de;
    }

    .auth-page .auth-card form button[type="submit"] {
      background: #176955;
      border-color: #176955;
      color: #fff;
    }

    .auth-page .auth-card form button[type="submit"]:hover:not(:disabled) {
      background: #115140;
    }
  }
}

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;
}
