.app-header .header-right { display:flex; flex-direction:row; align-items:center; gap:12px; max-width:min(50vw,380px); }
.app-header #header-key-pill { min-width:0; flex:1; }
.theme-picker { position:relative; flex-shrink:0; z-index:40; }
.entry-shell { position:relative; }
.entry-shell > .theme-picker { position:absolute; right:0; top:max(32px,env(safe-area-inset-top)); }
.entry-brand { max-width:calc(100% - 86px); }
.theme-toggle { display:flex; align-items:center; justify-content:center; gap:6px; min-width:44px; min-height:44px; padding:8px; background:#ffffffb8; color:#355b8b; border:1px solid #bdcfe5; border-radius:10px; cursor:pointer; font:500 12px 'Plus Jakarta Sans',sans-serif; }
.theme-options { position:absolute; right:0; top:calc(100% + 8px); width:220px; padding:6px; border:1px solid #bdcfe5; border-radius:12px; background:#f8fbff; color:#263e5c; box-shadow:0 12px 32px #152b4b24; }
.theme-options[hidden] { display:none; }
.theme-options button { width:100%; min-height:48px; display:flex; align-items:center; gap:10px; padding:10px; border:0; border-radius:7px; background:transparent; color:inherit; cursor:pointer; font:500 13px 'Plus Jakarta Sans',sans-serif; text-align:left; }
.theme-options button[aria-checked="true"], .theme-options button:hover { background:#e3edfa; }
.theme-check { margin-left:auto; font-size:10px; }
@media(prefers-reduced-motion:no-preference) {
 html.theme-switching,
 html.theme-switching :is(body,.app-header,.brand-name,.pro-card,.mode-card,.mode-detail,.account-card,.connection-card,.client-health-item,.live-monitor,#live-stats-wrap,.majestic-num,.monitor-device,.monitor-progress,.target-queue-step,.queue-step-index,.queue-step-caption,.random-dice-btn,.dice-pip-btn,.theme-toggle,.theme-options,input,textarea,button,h1,h2,h3,p,span,small,a,dialog) {
  transition:background-color 280ms ease,color 280ms ease,border-color 280ms ease,box-shadow 280ms ease!important;
 }
}
.theme-picker button:focus-visible { outline:2px solid #719edd; outline-offset:2px; }
@media(min-width:900px) { .entry-shell > .theme-picker { top:64px; } }
@media(max-width:600px) { .theme-toggle span { display:none; } .app-header .header-right { gap:7px; max-width:58vw; } .app-header #header-key-pill { min-width:0; font-size:10px; } }
html[data-theme="dark"] { color-scheme:dark; --bg:#243449; --surface:#30445e; --ink:#e1ebfa; --muted:#c0cee0; --line:#506782; --soft:#384f6c; --focus:#91b9f3; --lavender:#2c3954; --blue:#243e60; --nav:#121e30; }
html[data-theme="dark"], html[data-theme="dark"] body { background-color:#243449!important; color:#e1ebfa; }
html[data-theme="dark"] body { background-image:radial-gradient(ellipse at 10% 0%,#6e9bd32b,transparent 55%),url('./canvas.svg?v=rich3')!important; background-size:100% 720px,320px; background-repeat:no-repeat,repeat; }
html[data-theme="dark"] :is(.pro-card,dialog,.mode-card,.account-card,.connection-card,.history-empty,.mobile-console-page .control-workspace > .pro-card) { background:#30445e!important; border-color:#506782!important; color:#e1ebfa; box-shadow:inset 0 1px 0 #ffffff0b,0 8px 24px #14263b16; }
html[data-theme="dark"] :is(input,textarea,.seq-big-input,.key-input,.mobile-console-page .control-workspace .seq-big-input) { background:#293d56!important; color:#e1ebfa!important; border-color:#617d9f; }
html[data-theme="dark"] :is(input,textarea)::placeholder { color:#91a6c1!important; }
html[data-theme="dark"] :is(.client-health-item,.random-dice-btn,.dice-pip-btn,.dice-picker-card,.target-queue-step,.monitor-device,.connection-result,.server-feedback) { background:#384f6c!important; border-color:#58728f!important; color:#deebfc!important; }
html[data-theme="dark"] :is(.random-dice-btn.active-random,.dice-pip-btn.active,.target-queue-step.is-next,.mode-card[aria-pressed="true"]) { background:linear-gradient(135deg,#4b709c,#3e5c82)!important; border-color:#8eb5ee!important; color:#fff!important; }
html[data-theme="dark"] :is(.mobile-workspace #live-stats-wrap,.live-monitor) { background:linear-gradient(135deg,#415f80,#334c6a)!important; border-color:#58728f!important; color:#e1ebfa!important; }
html[data-theme="dark"] :is(h1,h2,h3,.brand-name,.hero-die-val-big,.random-btn-title,.input-guide strong,.monitor-device strong,.owner-link,.activation-label) { color:#e1ebfa!important; }
html[data-theme="dark"] :is(.muted,.activate-subtitle,.key-hint,.entry-support p,.owner-link small,.entry-eyebrow,.random-btn-sub,.console-random-label,.sequence-pair-label,.input-guide p,.target-help summary,.monitor-count,.majestic-header,.monitor-device-caption,.queue-step-caption,.header-device,#header-last-active,.client-health-label,.connection-hint,.connection-eyebrow,.console-mode-link,.target-validation,.mobile-console-page .live-monitor #stats-title) { color:#c0cee0!important; }
html[data-theme="dark"] .majestic-num { color:#bed8fa!important; }
html[data-theme="dark"] .next-target .majestic-num { color:#91bfff!important; }
html[data-theme="dark"] :is(.entry-support,.owner-link + .owner-link,.header-status-row,.app-header,td,th,.monitor-progress,.current-roll) { border-color:#506782!important; }
html[data-theme="dark"] :is(.theme-toggle,.theme-options) { background:#30445e; color:#deebfc; border-color:#617d9f; }
html[data-theme="dark"] .theme-options button:is(:hover,[aria-checked="true"]) { background:#456386; }
html[data-theme="dark"] .target-validation[data-state="error"] { color:#ffa4af!important; }
html[data-theme="dark"] .target-validation[data-state="valid"] { color:#9ed9b2!important; }
html[data-theme="dark"] :is(.field-error,.activate-error) { color:#ffa4af!important; }
html[data-theme="dark"] .brand-mark img,html[data-theme="dark"] .entry-brand img { content:url('./logo-dark.svg?v=1'); filter:none; }
html[data-theme="dark"] .navigation a:not([aria-current="page"]) { color:#c6d5e9; }
html[data-theme="dark"] :is(.primary,.apply-target-btn,.activate-btn) { background:#426fa9; color:#fff; }
html[data-theme="dark"] .apply-target-btn[data-feedback="success"] { background:#267449; }
html[data-theme="dark"] .apply-target-btn[data-feedback="error"] { background:#a72d3a; }
html[data-theme="dark"] .apply-target-btn[data-feedback="waiting"] { background:#dbba70; color:#302612; }
html[data-theme="dark"] :is(.mode-card-title,.mode-range,.hero-die-meta,.monitor-device-action) { color:#d8e7fa; }
html[data-theme="dark"] :is(.mode-card-description,.dice-picker-header,.mode-detail-description) { color:#c0cee0; }
html[data-theme="dark"] :is(.monitor-progress,.monitor-progress strong) { color:#b8cce5; }
html[data-theme="dark"] .mode-page .mode-list .mode-card.selected { background:linear-gradient(135deg,#4b709c,#3e5c82)!important; border-color:#8eb5ee!important; }
html[data-theme="dark"] .mode-selection { background:#384f6c; border-color:#6783a6; }
html[data-theme="dark"] .seq-big-input[aria-invalid="true"] { border-color:#f08b9b!important; }
@media(min-width:1024px) { html[data-theme="dark"] .navigation::before { background:#496d97; } }
@media(prefers-contrast:more) { html[data-theme="dark"] body { background-image:none!important; } }

/* Shared dark surfaces and action colors: never use the text token as a button fill. */
html[data-theme="dark"] .target-delivery { background:#293f5a; border-color:#6783a6; color:#deebfa; }
html[data-theme="dark"] .delivery-steps [data-done="true"] { color:#b4e4c4; }
html[data-theme="dark"] .target-delivery[data-state="received"] { background:#294b40; border-color:#6a9b81; color:#d8f0e2; }
html[data-theme="dark"] .target-delivery[data-state="error"] { background:#533540; border-color:#c98997; color:#ffdce2; }
html[data-theme="dark"] .key-expiry-warning { background:#4b432f; border-color:#aa925d; color:#ffebbc; }
html[data-theme="dark"] .key-expiry-warning[data-urgent="true"] { background:#533c30; border-color:#b88d70; color:#ffe2ce; }
html[data-theme="dark"] :is(.key-expiry-warning,.target-delivery) p { color:inherit!important; }
.devices-page .connection-card .client-health-grid { align-items:stretch; gap:12px; }
.devices-page .connection-card .client-health-item {
 padding:14px; border:1px solid var(--line); border-radius:10px;
 min-width:0; height:auto; background:var(--soft); overflow-wrap:anywhere;
}
.devices-page .connection-card .client-health-item p { margin:6px 0 0; line-height:1.6; }
.devices-page .connection-card .client-health-label { line-height:1.5; }
.devices-page .connection-card .client-health-item strong { margin-top:6px; line-height:1.5; }
html[data-theme="dark"] .devices-page .connection-card .client-health-item {
 border:1px solid #718ba9!important; background:#354c67!important; padding:14px;
}
html[data-theme="dark"] {
 --night-panel:#30445e;
 --night-raised:#384f6c;
 --night-action:#426fa9;
 --night-text:#f0f5fd;
 --night-muted:#ced9e8;
 --ink:var(--night-text);
 --muted:var(--night-muted);
}
html[data-theme="dark"] :is(.connection-primary,.connection-copy,.primary,.activate-btn,.guide-tab-btn.active) {
 background:var(--night-action)!important; color:#fff!important; border-color:#82a9db!important;
}
html[data-theme="dark"] :is(.connection-primary,.connection-copy,.primary,.activate-btn):hover:not(:disabled) { background:#365f93!important; }
html[data-theme="dark"] .connection-copy[data-copied="true"] { background:#276347!important; color:#fff!important; }
html[data-theme="dark"] :is(.secondary,.guide-tab-btn,.icon-button,.reset-pill-btn) { background:#384f6c; color:var(--night-text); border-color:#6783a6; }
html[data-theme="dark"] :is(.connection-message,.connection-result-heading,.target-help summary,.target-queue-heading,.target-queue-heading span,.queue-step-caption,.client-health-item p,.connection-badge) { color:var(--night-muted)!important; }
html[data-theme="dark"] .target-validation[data-state="valid"] { color:#b4e4c4!important; }
html[data-theme="dark"] .target-validation[data-state="error"] { color:#ffb4bd!important; }
html[data-theme="dark"] .target-validation[data-state="incomplete"] { color:var(--night-muted)!important; }
html[data-theme="dark"] .target-queue-step .queue-step-index { background:#263d57; color:#e4eefb; }
html[data-theme="dark"] .target-queue-step.is-next .queue-step-index { background:#d7e7fb; color:#233e60; }
html[data-theme="dark"] .target-queue-step.is-passed .queue-step-index { background:#314963; color:#dce9f8; }
html[data-theme="dark"] .target-queue-step.is-next { box-shadow:inset 0 1px 0 #ffffff24,0 3px 12px #14263b24; }
html[data-theme="dark"] .mode-page .mode-card.selected .mode-selection { background:#d7e7fb; color:#233e60; border-color:#d7e7fb; }
html[data-theme="dark"] :is(.history-landed,.license-status) { color:#b4e4c4; }
html[data-theme="dark"] :is(.logout-action,.text-button[data-action="clear-logs"]) { color:#ffb4bd; }
html[data-theme="dark"] .toast { background:#e1ecfa; color:#203750; border-color:#b3cbe8; }
html[data-theme="dark"] .monitor-device-icon { color:#cee3ff; border-color:#86a5ca; }
html[data-theme="dark"] .control-workspace .target-queue .queue-step-caption { color:#e6effa!important; }
html[data-theme="dark"] .control-workspace .target-validation[data-state="valid"] { color:#b4e4c4!important; }
html[data-theme="dark"] .control-workspace .target-validation[data-state="error"] { color:#ffb4bd!important; }
html[data-theme="dark"] .console-page .control-workspace .apply-target-btn { background:#426fa9!important; color:#fff!important; }
html[data-theme="dark"] .console-page .control-workspace .apply-target-btn[data-feedback="success"] { background:#276347!important; }
html[data-theme="dark"] .console-page .control-workspace .apply-target-btn[data-feedback="error"] { background:#a72d3a!important; }
html[data-theme="dark"] .console-page .control-workspace .apply-target-btn[data-feedback="waiting"] { background:#dbba70!important; color:#302612!important; }
@media(max-width:1023px) {
 html[data-theme="dark"] .mobile-console-page .mobile-workspace {
  border:1px solid #6783a6; border-radius:20px; overflow:hidden; background:#30445e;
 }
 html[data-theme="dark"] .mobile-console-page .control-workspace #live-stats-wrap {
  border:0!important; border-radius:0;
 }
 html[data-theme="dark"] .mobile-console-page .control-workspace #live-stats-wrap::before { content:none; }
 html[data-theme="dark"] .mobile-console-page .control-workspace > .pro-card {
  border:0!important; border-top:1px solid #6783a6!important; border-radius:0; box-shadow:none;
 }
 /* The monitor belongs to its outer surface; avoid a second colored card inside it. */
 html[data-theme="dark"] .mobile-console-page .control-workspace #live-stats-wrap .live-monitor {
  background:transparent!important; border:0!important; box-shadow:none;
 }
 html[data-theme="dark"] .mobile-console-page .control-workspace #live-stats-wrap { background:#385473!important; border-color:#6783a6!important; }
 html[data-theme="dark"] .mobile-console-page .control-workspace .dice-picker-card { background:transparent!important; }
 html[data-theme="dark"] .navigation { background:#2c4562ed; border-color:#7895b8; }
 html[data-theme="dark"] .navigation a[aria-current="page"],html[data-theme="dark"] .navigation.is-dragging a.is-drag-target { color:#233e60; }
}
