/* v230.8 - Central theme & contrast safety layer. Loaded LAST. */
:root{
  --ui-bg:#fffdf9; --ui-surface:#ffffff; --ui-surface-2:#f7faf8;
  --ui-text:#10231d; --ui-muted:#526b62; --ui-border:#cfdcd6;
  --ui-accent:#0f6b43; --ui-accent-text:#ffffff;
  --ui-input-bg:#ffffff; --ui-input-text:#10231d;
}
html[data-theme="dark"], body.dark, .dark{
  --ui-bg:#0d1b17; --ui-surface:#172720; --ui-surface-2:#1d3028;
  --ui-text:#f4faf7; --ui-muted:#bed0c8; --ui-border:#395348;
  --ui-accent:#37b987; --ui-accent-text:#07150f;
  --ui-input-bg:#1d3028; --ui-input-text:#f4faf7;
}
/* Form controls must never inherit an unreadable foreground. */
input,select,textarea{color:var(--ui-input-text);}
html[data-theme="dark"] input,html[data-theme="dark"] select,html[data-theme="dark"] textarea,
body.dark input,body.dark select,body.dark textarea,.dark input,.dark select,.dark textarea{
  background-color:var(--ui-input-bg); color:var(--ui-input-text); border-color:var(--ui-border);
}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder,
body.dark input::placeholder,body.dark textarea::placeholder,.dark input::placeholder,.dark textarea::placeholder{color:#a9bdb4;opacity:1}
/* Native options otherwise frequently become white-on-white in dark mode. */
html[data-theme="dark"] option,body.dark option,.dark option{background:#172720;color:#f4faf7}
/* Common secondary copy: keep muted, but readable. */
html[data-theme="dark"] .muted,html[data-theme="dark"] .hint,html[data-theme="dark"] .help-text,
html[data-theme="dark"] small,body.dark .muted,body.dark .hint,body.dark .help-text,body.dark small,
.dark .muted,.dark .hint,.dark .help-text,.dark small{color:var(--ui-muted)}
/* Links retain visible contrast on both themes. */
html[data-theme="dark"] a:not(.btn):not([class*="button"]),body.dark a:not(.btn):not([class*="button"]),.dark a:not(.btn):not([class*="button"]){color:#8fe3c2}
/* Tables: protect header/body text when legacy rules collide. */
html[data-theme="dark"] table td,html[data-theme="dark"] table th,body.dark table td,body.dark table th,.dark table td,.dark table th{border-color:var(--ui-border)}
/* Dialog/popover generic text safety without forcing their backgrounds. */
html[data-theme="dark"] dialog,html[data-theme="dark"] [role="dialog"],body.dark dialog,body.dark [role="dialog"],.dark dialog,.dark [role="dialog"]{color:var(--ui-text)}
/* Disabled text still has enough contrast to be legible. */
html[data-theme="dark"] :disabled,body.dark :disabled,.dark :disabled{opacity:.72}
/* Selection and focus visibility in both themes. */
:focus-visible{outline:3px solid #e6a93a;outline-offset:2px}
::selection{background:#174c3a;color:#fff}
