/* NEXO deliberately defines no replacement tokens: every existing paint value
   remains the literal fallback in its original rule. Themes only change paint. */
:root[data-theme="dark"] {
  color-scheme:dark;
  --theme-app-rgb:0,0,0;
  --theme-surface-base-rgb:7,7,8;
  --theme-surface-card-rgb:12,12,14;
  --theme-surface-elevated-rgb:17,17,19;
  --theme-surface-interactive-rgb:28,28,31;
  --theme-surface-hover-rgb:43,43,47;
  --theme-surface-pressed-rgb:18,18,20;
  --theme-surface-disabled-rgb:19,19,21;
  --theme-input-rgb:19,19,22;
  --theme-border-subtle-rgb:69,69,74;
  --theme-border-strong-rgb:110,110,117;
  --theme-text-primary-rgb:244,244,246;
  --theme-text-secondary-rgb:192,192,199;
  --theme-text-muted-rgb:157,157,166;
  --theme-text-disabled-rgb:112,112,120;
  --theme-accent-rgb:175,175,182;
  --theme-accent-shadow-rgb:40,40,44;
  --theme-focus-rgb:89,173,255;
  --theme-primary-rgb:241,241,243;
  --theme-primary-hover-rgb:255,255,255;
  --theme-primary-pressed-rgb:210,210,214;
  --theme-on-primary-rgb:14,14,16;
  --theme-selection-rgb:35,35,39;
  --theme-decoration-rgb:30,30,33;
  --theme-functional:rgb(61,156,255);
  --theme-scrollbar-rgb:85,85,92;
}
:root[data-theme="grey"] {
  color-scheme:dark;
  --theme-app-rgb:56,65,77;
  --theme-surface-base-rgb:63,74,87;
  --theme-surface-card-rgb:74,87,103;
  --theme-surface-elevated-rgb:80,94,112;
  --theme-surface-interactive-rgb:96,112,130;
  --theme-surface-hover-rgb:113,131,152;
  --theme-surface-pressed-rgb:58,70,85;
  --theme-surface-disabled-rgb:66,78,93;
  --theme-input-rgb:63,77,94;
  --theme-border-subtle-rgb:149,167,187;
  --theme-border-strong-rgb:185,200,218;
  --theme-text-primary-rgb:255,255,255;
  --theme-text-secondary-rgb:232,239,247;
  --theme-text-muted-rgb:213,223,235;
  --theme-text-disabled-rgb:162,179,198;
  --theme-accent-rgb:115,195,255;
  --theme-accent-shadow-rgb:35,110,180;
  --theme-focus-rgb:156,215,255;
  --theme-primary-rgb:0,103,212;
  --theme-primary-hover-rgb:0,91,190;
  --theme-primary-pressed-rgb:0,76,165;
  --theme-on-primary-rgb:255,255,255;
  --theme-selection-rgb:79,107,139;
  --theme-decoration-rgb:112,132,156;
  --theme-scrollbar-rgb:161,178,197;
}
:root[data-theme="white"] {
  color-scheme:light;
  --theme-app-rgb:243,246,250;
  --theme-surface-base-rgb:248,250,253;
  --theme-surface-card-rgb:255,255,255;
  --theme-surface-elevated-rgb:255,255,255;
  --theme-surface-interactive-rgb:233,240,248;
  --theme-surface-hover-rgb:218,232,249;
  --theme-surface-pressed-rgb:204,220,241;
  --theme-surface-disabled-rgb:234,238,244;
  --theme-input-rgb:247,249,253;
  --theme-border-subtle-rgb:157,177,205;
  --theme-border-strong-rgb:117,142,178;
  --theme-text-primary-rgb:17,29,48;
  --theme-text-secondary-rgb:48,68,98;
  --theme-text-muted-rgb:74,94,122;
  --theme-text-disabled-rgb:125,141,164;
  --theme-accent-rgb:0,91,201;
  --theme-accent-shadow-rgb:58,113,177;
  --theme-focus-rgb:0,102,218;
  --theme-primary-rgb:0,103,221;
  --theme-primary-hover-rgb:0,86,191;
  --theme-primary-pressed-rgb:0,71,162;
  --theme-on-primary-rgb:255,255,255;
  --theme-selection-rgb:216,232,253;
  --theme-decoration-rgb:209,222,240;
  --theme-scrollbar-rgb:145,163,188;
}
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"],[data-theme="custom"]) {
  --theme-app:rgb(var(--theme-app-rgb));
  --theme-surface-base:rgb(var(--theme-surface-base-rgb));
  --theme-surface-card:rgb(var(--theme-surface-card-rgb));
  --theme-surface-elevated:rgb(var(--theme-surface-elevated-rgb));
  --theme-surface-interactive:rgb(var(--theme-surface-interactive-rgb));
  --theme-surface-hover:rgb(var(--theme-surface-hover-rgb));
  --theme-surface-pressed:rgb(var(--theme-surface-pressed-rgb));
  --theme-surface-disabled:rgb(var(--theme-surface-disabled-rgb));
  --theme-input:rgb(var(--theme-input-rgb));
  --theme-border-subtle:rgb(var(--theme-border-subtle-rgb));
  --theme-border-strong:rgb(var(--theme-border-strong-rgb));
  --theme-text-primary:rgb(var(--theme-text-primary-rgb));
  --theme-text-secondary:rgb(var(--theme-text-secondary-rgb));
  --theme-text-muted:rgb(var(--theme-text-muted-rgb));
  --theme-text-disabled:rgb(var(--theme-text-disabled-rgb));
  --theme-accent:rgb(var(--theme-accent-rgb));
  --theme-accent-shadow:rgb(var(--theme-accent-shadow-rgb));
  --theme-focus:rgb(var(--theme-focus-rgb));
  --theme-primary:rgb(var(--theme-primary-rgb));
  --theme-primary-hover:rgb(var(--theme-primary-hover-rgb));
  --theme-primary-pressed:rgb(var(--theme-primary-pressed-rgb));
  --theme-on-primary:rgb(var(--theme-on-primary-rgb));
  --theme-selection:rgb(var(--theme-selection-rgb));
  --theme-decoration:rgb(var(--theme-decoration-rgb));
  --theme-scrollbar:rgb(var(--theme-scrollbar-rgb));
  --theme-knob-rgb:255,255,255;
  --theme-knob:rgb(var(--theme-knob-rgb));
  --theme-on-accent-rgb:255,255,255;
  --theme-on-accent:rgb(var(--theme-on-accent-rgb));
  --theme-shadow-rgb:0,0,0;
  --theme-shadow:rgb(var(--theme-shadow-rgb));
  --theme-highlight-rgb:255,255,255;
  --theme-highlight:rgb(var(--theme-highlight-rgb));
  --theme-backdrop-rgb:0,0,0;
  --theme-backdrop:rgb(var(--theme-backdrop-rgb));
  --theme-success-rgb:37,190,130;
  --theme-success:rgb(var(--theme-success-rgb));
  --theme-success-text-rgb:98,227,174;
  --theme-success-text:rgb(var(--theme-success-text-rgb));
  --theme-success-surface-rgb:12,67,48;
  --theme-success-surface:rgb(var(--theme-success-surface-rgb));
  --theme-danger-rgb:236,57,86;
  --theme-danger:rgb(var(--theme-danger-rgb));
  --theme-danger-text-rgb:255,163,177;
  --theme-danger-text:rgb(var(--theme-danger-text-rgb));
  --theme-danger-surface-rgb:73,24,35;
  --theme-danger-surface:rgb(var(--theme-danger-surface-rgb));
  --theme-warning-rgb:229,171,51;
  --theme-warning:rgb(var(--theme-warning-rgb));
  --theme-warning-text-rgb:247,207,121;
  --theme-warning-text:rgb(var(--theme-warning-text-rgb));
  /* Media canvases and controls keep a neutral, dark contrast floor in all
     themes. These tokens affect UI paint, never video, photos or thumbnails. */
  --theme-media-surface-rgb:8,8,10;
  --theme-media-surface:rgb(var(--theme-media-surface-rgb));
  --theme-media-hover-rgb:33,33,38;
  --theme-media-hover:rgb(var(--theme-media-hover-rgb));
  --theme-media-text-rgb:246,247,250;
  --theme-media-text:rgb(var(--theme-media-text-rgb));
  --theme-media-muted-rgb:198,205,219;
  --theme-media-muted:rgb(var(--theme-media-muted-rgb));
  --theme-media-border-rgb:150,155,166;
  --theme-media-border:rgb(var(--theme-media-border-rgb));
  --theme-media-danger-rgb:255,173,189;
  --theme-media-danger:rgb(var(--theme-media-danger-rgb));
  --theme-media-danger-surface-rgb:73,24,35;
  --theme-media-danger-surface:rgb(var(--theme-media-danger-surface-rgb));
}
:root[data-theme="white"] {
  --theme-shadow-rgb:109,127,154;
  --theme-success-text-rgb:0,112,72;
  --theme-success-surface-rgb:221,247,235;
  --theme-danger-text-rgb:168,25,51;
  --theme-danger-surface-rgb:255,229,232;
  --theme-warning-text-rgb:126,79,0;
}
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) :is(.entry-waves,.transition-curve) stop { stop-color:var(--theme-decoration); }
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) .home-action-primary { color:var(--theme-on-primary); }

/* The only new geometry is the appearance picker itself. */
.appearance-settings-card { margin-top:8px; container-type:inline-size; }
.theme-fieldset { min-width:0; margin:2px 0 0; padding:0; border:0; }
.theme-fieldset legend { margin-bottom:10px; padding:0; color:var(--theme-text-primary,#e7eefb); font-size:12px; font-weight:700; }
.theme-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px 14px; }
.theme-option { display:grid; min-width:0; gap:8px; cursor:pointer; color:var(--theme-text-primary,#eef3ff); }
.theme-preview { --preview-bg:#080e1b; --preview-panel:#131b32; --preview-lines:#333454; --preview-accent:#7852f8; display:grid; grid-template-rows:14px 1fr; gap:7px; aspect-ratio:2.1; overflow:hidden; padding:10px; border:1px solid var(--theme-border-subtle,#34425d); border-radius:12px; background:var(--preview-bg); box-shadow:inset 0 0 18px #0002; }
.theme-preview[data-preview-theme="dark"] { --preview-bg:#020203; --preview-panel:#171719; --preview-lines:#424246; --preview-accent:#1483ee; }
.theme-preview[data-preview-theme="grey"] { --preview-bg:#455366; --preview-panel:#607087; --preview-lines:#92a3b9; --preview-accent:#50a4f4; }
.theme-preview[data-preview-theme="white"] { --preview-bg:#f6f8fc; --preview-panel:#e2eaf7; --preview-lines:#b5c9e8; --preview-accent:#1479ed; }
.theme-preview-header { display:flex; align-items:center; gap:8px; color:var(--preview-lines); }
.theme-preview-header b { color:#f2f4ff; font-size:9px; letter-spacing:2px; }
.theme-preview[data-preview-theme="white"] .theme-preview-header b { color:#172640; }
.theme-preview-header > i { width:28%; height:4px; border-radius:3px; background:var(--preview-lines); }
.theme-preview-header > span { margin-left:auto; font-size:12px; }
.theme-preview-body { display:grid; min-height:0; grid-template-columns:16% 40% 1fr; gap:7px; }
.theme-preview-rail { display:flex; flex-direction:column; align-items:center; justify-content:space-around; padding:3px; border-radius:5px; background:var(--preview-panel); }
.theme-preview-rail i { width:7px; height:7px; border:1px solid var(--preview-lines); border-radius:2px; }
.theme-preview-rail i:last-child { border-color:var(--preview-accent); background:var(--preview-accent); }
.theme-preview-list { display:grid; gap:4px; }
.theme-preview-list i { display:block; border:5px solid var(--preview-panel); border-radius:4px; background:var(--preview-lines); }
.theme-preview-stage { align-self:center; height:80%; border-radius:7px; background:var(--preview-panel); border:1px solid var(--preview-lines); }
.theme-option-label { display:flex; align-items:center; gap:8px; font-size:12px; font-weight:650; }
.appearance-settings-card .theme-option input { appearance:none; flex:none; width:19px; height:19px; min-height:19px; padding:0; margin:0; border:1px solid var(--theme-border-strong,#647997); border-radius:50%; background:transparent; cursor:pointer; }
.appearance-settings-card .theme-option input:checked { border:2px solid var(--theme-accent,#8c60ff); background:radial-gradient(circle,var(--theme-accent,#8c60ff) 0 5px,transparent 5.5px); }
.theme-option:has(input:checked) .theme-preview { border-color:var(--theme-accent,#8c60ff); box-shadow:0 0 0 1px var(--theme-accent,#8c60ff); }
.theme-option:hover .theme-preview { border-color:var(--theme-focus,#b19aff); }
.theme-option:has(input:focus-visible) .theme-preview { outline:2px solid var(--theme-focus,#b19aff); outline-offset:3px; }
.appearance-settings-card .adaptive-icon-row { margin-top:18px; }
@container (max-width:300px) { .theme-grid { grid-template-columns:minmax(0,1fr); } }

/* Decorative identity stays neutral in Dark; blue is reserved for interaction. */
:root[data-theme="dark"] :is(.voice-toggle input:checked,.setting-check input:checked,.active-share-toggle > input:checked + .active-share-toggle-switch,.desktop-picker-switch input:checked + span,.desktop-picker-option input:checked + .desktop-picker-checkbox) {
  --theme-accent:var(--theme-functional);
}
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) .reference-entry-copy h1 em {
  background:none;
  color:var(--theme-text-primary);
  -webkit-text-fill-color:currentColor;
}
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) :is(.desktop-picker-switch span::after,.active-share-toggle-switch::after) { background:var(--theme-knob); }
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) .call-controls .control-leave > svg { color:var(--theme-on-accent); }
:root:is([data-theme="dark"],[data-theme="grey"],[data-theme="white"]) .active-share-options footer .button:not([data-state="success"]) {
  color:var(--theme-on-primary);
  background:var(--theme-primary);
}
