/* Green palettes also paint the miniature workspace previews.
   Keep stored theme IDs stable so existing preferences carry forward. */
:is(#rf-app[data-theme="tech"], .rf-theme-preview[data-palette="tech"]) {
  color-scheme:dark; --ui-bg:#0d2120; --ui-panel:#193331; --ui-rail:#122927;
  --ui-soft:#2a4744; --ui-line:#517975; --ui-text:#edf8f6; --ui-muted:#b0cbc8;
  --ui-accent:#bce0df; --ui-on-accent:#173a36;
}
:is(#rf-app[data-theme="violet"], .rf-theme-preview[data-palette="violet"]) {
  color-scheme:dark; --ui-bg:#0d180e; --ui-panel:#1b301c; --ui-rail:#132415;
  --ui-soft:#2c452b; --ui-line:#506e4d; --ui-text:#f0f8eb; --ui-muted:#b8cbae;
  --ui-accent:#95cc80; --ui-on-accent:#152e10;
}
:is(#rf-app[data-theme="emerald"], .rf-theme-preview[data-palette="emerald"]) {
  color-scheme:dark; --ui-bg:#041d13; --ui-panel:#0b3323; --ui-rail:#072719;
  --ui-soft:#164c35; --ui-line:#397452; --ui-text:#e9fff2; --ui-muted:#a4cfb8;
  --ui-accent:#50df99; --ui-on-accent:#042c18;
}
:is(#rf-app[data-theme="graphite"], .rf-theme-preview[data-palette="graphite"]) {
  color-scheme:dark; --ui-bg:#0c1512; --ui-panel:#19251f; --ui-rail:#111e18;
  --ui-soft:#2a3a30; --ui-line:#536c5c; --ui-text:#edf4ee; --ui-muted:#b0c3b6;
  --ui-accent:#a5c8b1; --ui-on-accent:#192d20;
}
:is(#rf-app[data-theme="ocean"], .rf-theme-preview[data-palette="ocean"]) {
  color-scheme:dark; --ui-bg:#06221b; --ui-panel:#103c30; --ui-rail:#0a2d24;
  --ui-soft:#1d5040; --ui-line:#427a64; --ui-text:#e8fff3; --ui-muted:#a2cdb9;
  --ui-accent:#69dca7; --ui-on-accent:#062f20;
}
:is(#rf-app[data-theme="ember"], .rf-theme-preview[data-palette="ember"]) {
  color-scheme:dark; --ui-bg:#181d0c; --ui-panel:#2a3319; --ui-rail:#202811;
  --ui-soft:#3c4726; --ui-line:#647448; --ui-text:#f5f8e9; --ui-muted:#c2cbab;
  --ui-accent:#bdcf7d; --ui-on-accent:#252e0e;
}
:is(#rf-app[data-theme="rose"], .rf-theme-preview[data-palette="rose"]) {
  color-scheme:dark; --ui-bg:#162015; --ui-panel:#253622; --ui-rail:#1d2a1a;
  --ui-soft:#394c30; --ui-line:#627953; --ui-text:#f1f7e9; --ui-muted:#bdceb0;
  --ui-accent:#a8d18b; --ui-on-accent:#203416;
}
:is(#rf-app[data-theme="light"], .rf-theme-preview[data-palette="light"]) {
  color-scheme:light; --ui-bg:#bce0df; --ui-panel:#f0f9f7; --ui-rail:#aed4d1;
  --ui-soft:#acd3ce; --ui-line:#6f9e96; --ui-text:#183c36; --ui-muted:#355b53;
  --ui-accent:#245e50; --ui-on-accent:#ffffff;
}
:is(#rf-app[data-theme="paper"], .rf-theme-preview[data-palette="paper"]) {
  color-scheme:light; --ui-bg:#f2f5e9; --ui-panel:#fdfef8; --ui-rail:#e7ecd5;
  --ui-soft:#dde6c8; --ui-line:#b6c39a; --ui-text:#303d20; --ui-muted:#556343;
  --ui-accent:#536b2f; --ui-on-accent:#ffffff;
}
:is(#rf-app[data-theme="sage"], .rf-theme-preview[data-palette="sage"]) {
  color-scheme:light; --ui-bg:#eff4ef; --ui-panel:#fbfdf9; --ui-rail:#e2ebe1;
  --ui-soft:#dce8da; --ui-line:#b3c6b1; --ui-text:#243627; --ui-muted:#506650;
  --ui-accent:#32653d; --ui-on-accent:#ffffff;
}

/* One set of surfaces keeps new and existing themes consistent across pages. */
#rf-app[data-theme] {
  --ui-panel-line:color-mix(in srgb,var(--ui-line) 55%,var(--ui-panel));
  --ui-control-line:color-mix(in srgb,var(--ui-muted) 70%,var(--ui-panel));
  --ui-shadow:0 2px 8px light-dark(rgba(20,43,31,.04),rgba(0,0,0,.09));
  --ui-floating-shadow:0 12px 32px light-dark(rgba(20,43,31,.12),rgba(0,0,0,.24));
  --rf-blue:var(--ui-accent); --rf-muted:var(--ui-muted); --rf-border:var(--ui-line); --rf-line:var(--ui-line);
  --tech-blue:var(--ui-accent); --tech-cyan:var(--ui-accent); --tech-violet:var(--ui-accent);
  --rf-green:light-dark(#21634d,#8bd5b7); --rf-amber:light-dark(#845500,#ebc16f); --rf-red:light-dark(#a32a3a,#ffabb5);
  --ui-good-bg:light-dark(#e9f6f0,#17362e); --ui-warn-bg:light-dark(#fff5dc,#352c1c); --ui-error-bg:light-dark(#fff0f1,#3c232a);
  color:var(--ui-text); background:var(--ui-bg); accent-color:var(--ui-accent);
}
#rf-app[data-theme] :is(.rf-sidebar,.rf-globalbar) {background:var(--ui-rail); color:var(--ui-text); border-color:var(--ui-panel-line);}
/* Legacy pale marks remain readable on bright sidebars. */
#rf-app:is([data-theme="light"],[data-theme="paper"],[data-theme="sage"]) .rf-logo-crop {
  background:#0b211a;
  border:1px solid var(--ui-line);
  filter:none;
  box-shadow:0 2px 6px rgba(11,33,26,.12);
}
#rf-app[data-theme] :is(.rf-card,.rf-modal,.rf-select-menu,.rf-cardmenu,.rf-job-menu-items,.rf-job-choice,.rf-stageitem,.rf-toast) {background:var(--ui-panel); color:var(--ui-text); border-color:var(--ui-panel-line); box-shadow:var(--ui-shadow);}
/* Reading a panel should not make it look like a clickable control. */
#rf-app[data-theme] .rf-card:hover {border-color:var(--ui-panel-line); box-shadow:var(--ui-shadow);}
#rf-app[data-theme] :is(.rf-candidate,.rf-job-choice,.rf-stageitem):hover {border-color:var(--ui-accent); box-shadow:var(--ui-shadow); transform:none;}
#rf-app[data-theme] .rf-job-choice:focus-visible {transform:none;}
#rf-app[data-theme] :is(.rf-modal,.rf-select-menu,.rf-cardmenu,.rf-job-menu-items,.rf-toast) {box-shadow:var(--ui-floating-shadow);}
#rf-app[data-theme] :is(.rf-stage,.rf-batch,.rf-note,.rf-home-hero,.rf-home-continue,.rf-home-tutorial,.rf-admin-breakdown>div) {background:var(--ui-rail); color:var(--ui-text); border-color:var(--ui-panel-line);}
#rf-app[data-theme] :is(.rf-card h3,.rf-sectiontitle h2,.rf-top h1,.rf-table td,.rf-top-table td,.rf-userbar strong,.rf-summary-row span:last-child,.rf-score-breakdown b,.rf-score-explain-head strong,.rf-score-reasons li b,.rf-cardmenu button,.rf-select-option) {color:var(--ui-text);}
#rf-app[data-theme] :is(.rf-sub,.rf-kicker,.rf-panel-meta,.rf-top p,.rf-sectiontitle p,.rf-table th,.rf-top-table th,.rf-form label,.rf-modal p,.rf-userbar span,.rf-stage h4,.rf-bench h4,.rf-mini small,.rf-job-picker-hero p,.rf-job-choice-client,.rf-job-picker-foot,.rf-guide-copy small,.rf-readiness-copy,.rf-score-breakdown>div,.rf-score-explain-head>span,.rf-score-empty,.rf-evidence-text) {color:var(--ui-muted);}
#rf-app[data-theme] :is(.rf-brand span,.rf-linkbtn,.rf-score-reasons summary,.rf-sync-status button,.rf-job-choice-arrow) {color:var(--ui-accent);}
#rf-app[data-theme] .rf-nav button {color:var(--ui-muted);}
#rf-app[data-theme] .rf-nav button span:first-child {color:inherit;}
#rf-app[data-theme] .rf-nav button:hover {background:var(--ui-soft); color:var(--ui-text); transform:none;}
#rf-app[data-theme] .rf-nav button.active {background:var(--ui-soft); color:var(--ui-text); border-color:transparent; border-left-color:var(--ui-accent); box-shadow:none;}
/* Change foreground and background together when switching between dark and light. */
#rf-app[data-theme] :is(.rf-btn,.rf-select-button) {background:var(--ui-panel); color:var(--ui-text); border-color:var(--ui-control-line); border-radius:10px; font-family:inherit; font-weight:600; transition:border-color .14s ease,box-shadow .14s ease;}
#rf-app[data-theme] .rf-btn:hover:not(:disabled) {background:var(--ui-soft); border-color:var(--ui-accent); transform:none;}
#rf-app[data-theme] .rf-btn.primary {background:var(--ui-accent); color:var(--ui-on-accent); border-color:var(--ui-accent);}
#rf-app[data-theme] .rf-btn.primary:hover:not(:disabled) {background:var(--ui-accent); filter:none; box-shadow:0 0 0 3px color-mix(in srgb,var(--ui-accent) 18%,transparent);}
#rf-app[data-theme] :is(.rf-btn,.rf-select-button):active:not(:disabled) {box-shadow:inset 0 2px 4px light-dark(rgba(20,43,31,.16),rgba(0,0,0,.24));}
#rf-app[data-theme] :is(.rf-btn,.rf-select-button):disabled {transform:none; box-shadow:none;}
#rf-app[data-theme] :is(.rf-btn.danger,.rf-cardmenu .danger) {background:var(--ui-error-bg); color:var(--rf-red); border-color:var(--rf-red);}
#rf-app[data-theme] .rf-btn.danger:hover:not(:disabled) {background:var(--ui-error-bg); border-color:var(--rf-red);}
#rf-app[data-theme] :is(.rf-form input,.rf-form select,.rf-form textarea,.rf-globaljob select,.rf-search) {background:var(--ui-panel); color:var(--ui-text); border-color:var(--ui-control-line); color-scheme:inherit; font-family:inherit;}
#rf-app[data-theme] :is(input,textarea)::placeholder {color:var(--ui-muted); opacity:1;}
#rf-app[data-theme] #globalJobSelect {color-scheme:inherit;}
/* Carry the selected green through focus, hover, and selected controls. */
#rf-app[data-theme] .rf-select-button:after {border-color:var(--ui-accent);}
#rf-app[data-theme] .rf-select.open .rf-select-button {background:var(--ui-panel); border-color:var(--ui-accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--ui-accent) 18%,transparent);}
#rf-app[data-theme] :is(.rf-home-job:hover,.rf-home-job:focus-visible,.rf-job-filters [aria-pressed=true]) {background:var(--ui-soft);}
#rf-app[data-theme] :is(.rf-workspace-details>summary,.rf-supporting-details>summary) {color:var(--ui-muted);}
/* Native option colors retain the existing Windows/Edge readability workaround. */
#rf-app[data-theme] :is(.rf-select-option:hover,.rf-select-option.active,.rf-select-option.selected,.rf-cardmenu button:hover,.rf-row:hover,.rf-more:hover) {background:var(--ui-soft); color:var(--ui-text);}
#rf-app[data-theme] .rf-select-option.selected {box-shadow:inset 3px 0 var(--ui-accent);}
#rf-app[data-theme] :is(.rf-table th,.rf-table td,.rf-top-table th,.rf-top-table td,.rf-feeditem,.rf-recent,.rf-score-explain-head,.rf-score-total,.rf-queue-summary) {border-color:var(--ui-panel-line);}
#rf-app[data-theme] :is(.rf-blue,.rf-jobbadge,.rf-icon,.rf-empty-icon,.rf-job-choice-icon,.rf-step-number) {background:var(--ui-soft); color:var(--ui-accent); border-color:var(--ui-line);}
#rf-app[data-theme] .rf-green {background:var(--ui-good-bg); color:var(--rf-green);}
#rf-app[data-theme] .rf-amber {background:var(--ui-warn-bg); color:var(--rf-amber);}
#rf-app[data-theme] .rf-red {background:var(--ui-error-bg); color:var(--rf-red);}
#rf-app[data-theme] :is(.rf-gray,.rf-job-choice-meta span) {background:var(--ui-soft); color:var(--ui-muted);}
#rf-app[data-theme] .rf-value {background:none; color:var(--ui-text); -webkit-text-fill-color:var(--ui-text);}
#rf-app[data-theme] .rf-score-ring:after {background:var(--ui-panel);}
#rf-app[data-theme] :is(.rf-score-ring strong,.rf-score-breakdown .rf-score-total,.rf-screen-context strong,.rf-screen-evidence strong,.rf-score-change b,.rf-funnel-row,.rf-funnel-pct,.rf-legend-row,.rf-activity-copy,.rf-ai-summary) {color:var(--ui-text);}
#rf-app[data-theme] :is(.rf-screen-context,.rf-screen-evidence,.rf-score-change,.rf-ai-summary,.rf-ai-evidence,.rf-weight-change,.rf-compare-field select,.rf-reason-chip) {background:var(--ui-rail); border-color:var(--ui-line);}
#rf-app[data-theme] :is(.rf-feeditem p,.rf-summary-row span:first-child,.rf-screen-context div,.rf-score-change,.rf-why,.rf-compare-field label,.rf-compare-empty,.rf-ai-evidence,.rf-weight-change p,.rf-ai-status,.rf-funnel-label,.rf-conversion,.rf-activity-time,.rf-more,.rf-reason-chip,.rf-admin-user small,.rf-usage-zero,.rf-admin-breakdown span,.rf-select-empty) {color:var(--ui-muted);}
#rf-app[data-theme] :is(.rf-compare-field select,.rf-reason-chip:hover) {color:var(--ui-text);}
#rf-app[data-theme] :is(.rf-why summary,.rf-guide-toggle,.rf-compare-number,.rf-conversion strong,.rf-activity-copy strong,.rf-top-table .rf-fit-mid) {color:var(--ui-accent);}
#rf-app[data-theme] :is(.rf-reason-chip.active,.rf-verdicts button.active) {background:var(--ui-accent); color:var(--ui-on-accent); border-color:var(--ui-accent);}
#rf-app[data-theme] :is(.rf-score-delta.up,.rf-score-change .up,.rf-top-table .rf-fit-good,.rf-home-steps .complete .rf-home-step) {color:var(--rf-green);}
#rf-app[data-theme] :is(.rf-score-delta.down,.rf-score-change .down,.rf-job-menu-items .danger) {color:var(--rf-red);}
#rf-app[data-theme] .rf-top-table .rf-fit-warn {color:var(--rf-amber);}
#rf-app[data-theme] .rf-bar i {background:var(--ui-accent);}
#rf-app[data-theme] :is(.rf-guide-step,.rf-analysis-step,.rf-readiness-hero) {background:var(--ui-rail); color:var(--ui-text); border-color:var(--ui-line);}
#rf-app[data-theme] :is(.rf-guide-step.done,.rf-analysis-step.complete) {background:var(--ui-good-bg); color:var(--rf-green);}
#rf-app[data-theme] .rf-guide-step:hover {background:var(--ui-soft); border-color:var(--ui-accent);}
#rf-app[data-theme] :is(.rf-evidence-status.confirmed,.rf-reevaluation-score .up) {color:var(--rf-green);}
#rf-app[data-theme] .rf-evidence-status.screen {color:var(--rf-amber);}
#rf-app[data-theme] :is(.rf-evidence-status.missing,.rf-evidence-status.knockout,.rf-reevaluation-score .down) {color:var(--rf-red);}
#rf-app[data-theme] :is(.rf-evidence-status.partial,.rf-evidence-status.clear) {color:var(--ui-muted);}
#rf-app[data-theme] :is(button,input,textarea,select,summary,a):focus-visible {outline:2px solid var(--ui-accent); outline-offset:3px;}
/* Typography and finishes change without changing spacing or page geometry.
   Theme foregrounds and backgrounds switch together; only outlines and shadows ease. */
#rf-app[data-theme] :is(.rf-kicker,.rf-panel-meta,.rf-navgroup-label,.rf-globaljob label,.rf-confidence-dots+span,.rf-table th,.rf-top-table th,.rf-stage h4,.rf-bench h4,.rf-compare-field label,.rf-compare-label,.rf-home-eyebrow,.rf-home-kicker) {font-family:inherit; letter-spacing:.01em; text-transform:none; font-weight:600;}
#rf-app[data-theme] :is(.rf-card h3,.rf-sectiontitle h2,.rf-top h1) {font-weight:650;}
#rf-app[data-theme] :is(.rf-score,.rf-value,.rf-scorebox,.rf-score-ring strong) {font-family:inherit; font-weight:650; font-variant-numeric:tabular-nums; text-shadow:none;}
#rf-app[data-theme] :is(.rf-card,.rf-stageitem,.rf-job-choice) {border-radius:12px;}
#rf-app[data-theme] :is(.rf-icon,.rf-empty-icon,.rf-job-choice-icon) {border-radius:10px; border-color:var(--ui-panel-line); box-shadow:none;}
#rf-app[data-theme] :is(.rf-pill,.rf-tag) {font-weight:600;}
#rf-app[data-theme] .rf-ui-icon {width:18px; height:18px; vertical-align:middle; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; pointer-events:none;}
#rf-app[data-theme] :is(.rf-linkbtn,.rf-nav button,.rf-select-option,.rf-theme-option) {transition:border-color .14s ease;}
#rf-app[data-theme] .rf-linkbtn:hover:not(:disabled) {text-decoration:underline; text-underline-offset:3px;}
#rf-app[data-theme] .rf-brand {border-color:var(--ui-panel-line);}
#rf-app[data-theme] .rf-brand span {color:var(--ui-muted); letter-spacing:.025em;}
#rf-app[data-theme] .rf-sync-status i {background:var(--rf-green); box-shadow:none;}
#rf-app[data-theme] .rf-sync-status[data-state="saving"] i {background:var(--ui-accent);}
#rf-app[data-theme] .rf-sync-status:is([data-state="error"],[data-state="offline"]) i {background:var(--rf-amber);}
#rf-app[data-theme] .rf-toast.success {border-left-color:var(--rf-green);}
#rf-app[data-theme] .rf-toast.error {border-left-color:var(--rf-red);}
#rf-app[data-theme] #ancalagon-tutorial {
  --at-bg:var(--ui-bg); --at-panel:var(--ui-panel); --at-rail:var(--ui-rail); --at-soft:var(--ui-soft);
  --at-text:var(--ui-text); --at-muted:var(--ui-muted); --at-line:var(--ui-line);
  --at-primary:var(--ui-accent); --at-onprimary:var(--ui-on-accent);
  color-scheme:inherit;
}
#rf-app[data-theme] #ancalagon-tutorial .at-eyebrow {text-transform:none; letter-spacing:.01em; color:var(--ui-muted);}

/* The picker is a single keyboard radio group with compact workspace previews. */
.rf-appearance {margin-bottom:16px;}
.rf-appearance>.rf-cardhead {align-items:flex-start; flex-wrap:wrap; margin-bottom:20px;}
#rf-app .rf-appearance h3 {margin-bottom:8px;}
.rf-theme-grid {display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:14px;}
#rf-app[data-theme] .rf-theme-option {display:flex; flex-direction:column; gap:0; padding:5px; border:1px solid var(--ui-line); border-radius:12px; background:var(--ui-panel); color:var(--ui-text); min-width:0; box-shadow:none;}
#rf-app[data-theme] .rf-theme-option:hover {border-color:var(--ui-accent);}
#rf-app[data-theme] .rf-theme-option.active {border-color:var(--ui-accent); box-shadow:0 0 0 1px var(--ui-accent);}
.rf-theme-preview {display:grid; grid-template-columns:24% 1fr; gap:0; height:94px; width:100%; border-radius:7px; overflow:hidden; background:var(--ui-bg); border:1px solid var(--ui-line);}
.rf-theme-preview-rail {background:var(--ui-rail); border-right:1px solid var(--ui-line); padding:16px 9px; display:flex; flex-direction:column; gap:8px;}
.rf-theme-preview-rail i {display:block; width:100%; height:4px; border-radius:4px; background:var(--ui-muted); opacity:.5;}
.rf-theme-preview-rail i:first-child {background:var(--ui-accent); opacity:1; height:7px; margin-bottom:6px;}
.rf-theme-preview-work {padding:12px; display:flex; flex-direction:column; gap:8px;}
.rf-theme-preview-bar {width:52%; height:5px; border-radius:4px; background:var(--ui-muted);}
.rf-theme-preview-panels {display:grid; grid-template-columns:1.3fr 1fr; gap:7px; flex:1;}
.rf-theme-preview-panels i {background:var(--ui-panel); border:1px solid var(--ui-line); border-radius:4px;}
.rf-theme-preview-action {width:32%; height:9px; border-radius:3px; background:var(--ui-accent);}
.rf-theme-copy {display:block; width:100%; padding:12px 9px 10px;}
.rf-theme-title {display:flex; justify-content:space-between; align-items:center; gap:8px;}
.rf-theme-title strong {font-size:13px; font-weight:650;}
#rf-app[data-theme] .rf-theme-option small {color:var(--ui-muted); font-size:11px; margin-top:6px; line-height:1.5;}
#rf-app[data-theme] .rf-theme-check {display:grid; place-items:center; width:18px; height:18px; flex-shrink:0; border:1px solid var(--ui-muted); border-radius:50%; background:transparent;}
#rf-app[data-theme] .rf-theme-option.active .rf-theme-check {border:1px solid var(--ui-accent); background:var(--ui-accent); color:var(--ui-on-accent);}
.rf-theme-option.active .rf-theme-check:after {content:'✓'; font-size:12px; font-weight:800;}
.rf-theme-footnote {margin:17px 0 0; color:var(--ui-muted); font-size:12px; line-height:1.6;}
@media(max-width:560px) {
  .rf-theme-grid {grid-template-columns:1fr; gap:10px;}
  #rf-app[data-theme] .rf-theme-option {display:grid; grid-template-columns:86px minmax(0,1fr); align-items:center;}
  .rf-theme-preview {height:70px;}
  .rf-theme-preview-rail {padding:11px 4px;}
  .rf-theme-preview-work {padding:10px 6px; gap:6px;}
  .rf-theme-title strong {font-size:12px;}
  .rf-theme-copy {padding:9px;}
}
@media(forced-colors:active) {
  #rf-app[data-theme] .rf-theme-option.active {outline:2px solid Highlight;}
  #rf-app[data-theme] .rf-theme-option.active .rf-theme-check {color:HighlightText; background:Highlight; forced-color-adjust:none;}
}
