/* v23 — dark-mode final surface audit
   Loaded last. This file intentionally affects ONLY html[data-theme="dark"]. */
html[data-theme="dark"]{
  --v23-surface:#101a35;
  --v23-surface-2:#141f3d;
  --v23-surface-3:#1a2850;
  --v23-line:rgba(139,155,217,.16);
  --v23-line-strong:rgba(126,144,255,.34);
  --v23-text:#eef3ff;
  --v23-copy:#a4b0ca;
  --v23-muted:#8190b0;
  --v23-blue:#7f91ff;
  --v23-violet:#9b82ff;
}

/* ---- Global interactive primitives in dark mode ---- */
html[data-theme="dark"] main button,
html[data-theme="dark"] main [role="button"],
html[data-theme="dark"] .site-header button,
html[data-theme="dark"] .site-footer button{
  -webkit-tap-highlight-color:transparent;
}
html[data-theme="dark"] main input,
html[data-theme="dark"] main textarea,
html[data-theme="dark"] main select{
  color:var(--v23-text)!important;
  background:linear-gradient(180deg,rgba(20,31,59,.98),rgba(14,23,45,.98))!important;
  border-color:var(--v23-line)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] main input::placeholder,
html[data-theme="dark"] main textarea::placeholder{color:#71809f!important}

/* Header / CTA: no white mode leakage. */
html[data-theme="dark"] .site-header .button-light,
html[data-theme="dark"] .mobile-menu a:last-child,
html[data-theme="dark"] .final-cta .button-light,
html[data-theme="dark"] .cta-shell .button-light{
  color:#eaf0ff!important;
  background:linear-gradient(180deg,#182542,#111b35)!important;
  border:1px solid var(--v23-line)!important;
  box-shadow:0 12px 28px rgba(0,0,0,.19),inset 0 1px rgba(255,255,255,.04)!important;
}
html[data-theme="dark"] .site-header .button-light:hover,
html[data-theme="dark"] .mobile-menu a:last-child:hover,
html[data-theme="dark"] .final-cta .button-light:hover,
html[data-theme="dark"] .cta-shell .button-light:hover{
  color:#fff!important;
  background:linear-gradient(180deg,#21315d,#18264a)!important;
  border-color:var(--v23-line-strong)!important;
}

/* Generic small badges / keyboard hints / chips */
html[data-theme="dark"] .instrument-workbench-footer kbd,
html[data-theme="dark"] .instrument-workbench-footer-v11 kbd,
html[data-theme="dark"] .lab-chip,
html[data-theme="dark"] .keyword-cloud span,
html[data-theme="dark"] .instrument-v11 .map-float,
html[data-theme="dark"] .instrument-v11 .code-node,
html[data-theme="dark"] .institution-inline-meta span,
html[data-theme="dark"] .contact-email button,
html[data-theme="dark"] .contact-copy-action{
  color:#cbd6f1!important;
  background:linear-gradient(180deg,#1a2749,#131d37)!important;
  border-color:var(--v23-line)!important;
  box-shadow:0 9px 22px rgba(0,0,0,.14)!important;
}
html[data-theme="dark"] .contact-copy-action:hover,
html[data-theme="dark"] .contact-email button:hover{
  color:#fff!important;
  background:linear-gradient(180deg,#22335f,#18264a)!important;
  border-color:var(--v23-line-strong)!important;
}

/* ---- Research continuity ---- */
html[data-theme="dark"] .continuity-v10 .context-play,
html[data-theme="dark"] .continuity-v10 .context-scenarios button,
html[data-theme="dark"] .continuity-v10 .asset,
html[data-theme="dark"] .continuity-v10 .flow-label,
html[data-theme="dark"] .continuity-v10 .audit-next{
  color:var(--v23-copy)!important;
  background:linear-gradient(180deg,#151f3d,#10192f)!important;
  border-color:var(--v23-line)!important;
}
html[data-theme="dark"] .continuity-v10 .context-play:hover,
html[data-theme="dark"] .continuity-v10 .context-scenarios button:hover,
html[data-theme="dark"] .continuity-v10 .asset:hover,
html[data-theme="dark"] .continuity-v10 .flow-label:hover{
  color:#fff!important;
  background:linear-gradient(180deg,#1c2a50,#14203e)!important;
  border-color:rgba(127,145,255,.26)!important;
}
html[data-theme="dark"] .continuity-v10 .context-scenarios button.active,
html[data-theme="dark"] .continuity-v10 .asset.active,
html[data-theme="dark"] .continuity-v10 .flow-label.active{
  color:#f3f6ff!important;
  background:linear-gradient(180deg,#263867,#1b2950)!important;
  border-color:rgba(126,144,255,.40)!important;
  box-shadow:0 16px 38px rgba(50,68,161,.20)!important;
}
html[data-theme="dark"] .continuity-v10 .audit-next{
  color:#fff!important;
  background:linear-gradient(135deg,#5e72ef,#8069ee)!important;
  border-color:transparent!important;
  box-shadow:0 12px 28px rgba(74,90,216,.22)!important;
}
html[data-theme="dark"] .continuity-v10 .context-tooltip,
html[data-theme="dark"] .continuity-v10 .context-packet,
html[data-theme="dark"] .continuity-v10 .flow-mini-console,
html[data-theme="dark"] .continuity-v10 .audit-focus{
  color:var(--v23-copy)!important;
  background:linear-gradient(180deg,rgba(22,32,59,.98),rgba(15,24,46,.98))!important;
  border-color:var(--v23-line)!important;
}

/* ---- Institutions ---- */
html[data-theme="dark"] .organization-v15 .institution-pane-head button,
html[data-theme="dark"] .organization-v15 .academic-label,
html[data-theme="dark"] .organization-v15 .engineering-layer{
  background:linear-gradient(180deg,#172343,#111a34)!important;
  border-color:var(--v23-line)!important;
  color:var(--v23-copy)!important;
}
html[data-theme="dark"] .organization-v15 .institution-pane-head button:hover{
  color:#fff!important;
  background:linear-gradient(180deg,#21315b,#182544)!important;
  border-color:var(--v23-line-strong)!important;
}

/* ---- Core workbench: catch ALL runtime-generated light controls ---- */
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 button:not(.lab-run),
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 [role="button"],
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .lab-chip,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .metric-card,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .lab-panel,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .topic-list button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .transcript-list button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .review-issue-premium button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .reviewer-roles button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .scenario-switch button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .sim-actions button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .evidence-toggles button,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .coding-add{
  background:linear-gradient(180deg,#151f3c,#10192f)!important;
  border-color:var(--v23-line)!important;
  color:#a9b5ce!important;
  box-shadow:none!important;
}
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 button:not(.lab-run):hover,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 [role="button"]:hover{
  color:#f5f7ff!important;
  background:linear-gradient(180deg,#1e2d55,#162343)!important;
  border-color:rgba(127,145,255,.25)!important;
}
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 button.active,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 [aria-selected="true"],
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .topic-list button.active,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .transcript-list button.active,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .reviewer-roles button.active,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .scenario-switch button.active,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .evidence-toggles button.active{
  color:#fff!important;
  background:linear-gradient(135deg,#5367db,#745de1)!important;
  border-color:rgba(138,153,255,.40)!important;
  box-shadow:0 10px 26px rgba(65,82,199,.19)!important;
}
/* Primary operation button remains brand-filled. */
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .lab-run,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 button[data-run],
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .primary-action{
  color:#fff!important;
  background:linear-gradient(135deg,#6275ef,#8269ef)!important;
  border-color:transparent!important;
  box-shadow:0 12px 28px rgba(74,90,216,.24)!important;
}
/* Dynamic document / quote surfaces must stay dark. */
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 blockquote,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .review-doc-premium,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .doc-stream,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .category-stack article,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .state-list>div,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .review-impact-v2,
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 .review-impact-v2 article{
  color:var(--v23-copy)!important;
  background:linear-gradient(180deg,#151f3c,#10192f)!important;
  border-color:var(--v23-line)!important;
}
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 mark{
  color:#dce5ff!important;
  background:rgba(101,119,237,.16)!important;
  border-color:rgba(127,145,255,.24)!important;
}
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 mark.issue{
  color:#f1c7a8!important;background:rgba(191,114,72,.14)!important;
}
html[data-theme="dark"] .instrument-v11 .instrument-stage-v11 mark.resolved{
  color:#aee1d1!important;background:rgba(65,154,126,.13)!important;
}

/* Workbench top controls and footer — never white. */
html[data-theme="dark"] .workbench-controls-v11 button,
html[data-theme="dark"] .instrument-workbench-footer-v11 kbd,
html[data-theme="dark"] .instrument-workbench-footer-v11 button{
  color:#aeb9d2!important;
  background:linear-gradient(180deg,#172341,#111a33)!important;
  border-color:var(--v23-line)!important;
}
html[data-theme="dark"] .workbench-controls-v11 button.active{
  color:#fff!important;
  background:linear-gradient(180deg,#253865,#1b294e)!important;
  border-color:rgba(126,144,255,.38)!important;
}
html[data-theme="dark"] .workbench-controls-v11 [data-workbench-auto][aria-pressed="true"]{
  color:#d5fff2!important;
  background:linear-gradient(180deg,#173c38,#112d2b)!important;
  border-color:rgba(83,197,164,.25)!important;
}

/* ---- Contact ---- */
html[data-theme="dark"] .contact-channels button,
html[data-theme="dark"] .contact-email,
html[data-theme="dark"] .contact-copy-action{
  color:var(--v23-copy)!important;
  background:linear-gradient(180deg,#151f3c,#10192f)!important;
  border-color:var(--v23-line)!important;
}
html[data-theme="dark"] .contact-channels button:hover,
html[data-theme="dark"] .contact-copy-action:hover{
  color:#fff!important;
  background:linear-gradient(180deg,#1e2d55,#162343)!important;
  border-color:rgba(127,145,255,.28)!important;
}
html[data-theme="dark"] .contact-submit,
html[data-theme="dark"] .contact-form .button-primary{
  color:#fff!important;
  background:linear-gradient(135deg,#5e72ef,#8069ee)!important;
  border-color:transparent!important;
}

/* ---- Footer ---- */
html[data-theme="dark"] .site-footer{background:#070c19!important}
html[data-theme="dark"] .footer-links a:hover{color:#fff!important}

/* Make theme transitions feel intentional rather than flashing. */
@media (prefers-reduced-motion:no-preference){
  html[data-theme="dark"] main button,
  html[data-theme="dark"] main input,
  html[data-theme="dark"] main textarea,
  html[data-theme="dark"] main select,
  html[data-theme="dark"] .instrument-v11 .metric-card,
  html[data-theme="dark"] .instrument-v11 .lab-panel{
    transition:background .22s ease,border-color .22s ease,color .22s ease,box-shadow .22s ease,transform .22s ease!important;
  }
}
