:root {
    color-scheme: light;
    --theme-canvas: 249 250 251;
    --theme-surface: 255 255 255;
    --theme-surface-muted: 243 244 246;
    --theme-ink: 17 24 39;
    --theme-muted: 75 85 99;
    --theme-subtle: 103 110 124;
    --theme-line: 229 231 235;
    --theme-control-line: 107 114 128;
    --theme-strong: 17 24 39;
    --theme-strong-ink: 255 255 255;
    --theme-link: 185 28 28;
    --theme-link-hover: 153 27 27;
    --theme-success-surface: 240 253 244;
    --theme-success-ink: 22 101 52;
    --theme-success-line: 134 239 172;
    --theme-warning-surface: 255 251 235;
    --theme-warning-ink: 146 64 14;
    --theme-warning-line: 252 211 77;
    --theme-danger-surface: 254 242 242;
    --theme-danger-ink: 185 28 28;
    --theme-danger-line: 252 165 165;
    --theme-info-surface: 239 246 255;
    --theme-info-ink: 30 64 175;
    --theme-info-line: 147 197 253;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --theme-canvas: 17 24 39;
    --theme-surface: 31 41 55;
    --theme-surface-muted: 41 53 72;
    --theme-ink: 243 244 246;
    --theme-muted: 203 213 225;
    --theme-subtle: 156 163 175;
    --theme-line: 75 85 99;
    --theme-control-line: 148 163 184;
    --theme-strong: 226 232 240;
    --theme-strong-ink: 17 24 39;
    --theme-link: 250 120 120;
    --theme-link-hover: 252 165 165;
    --theme-success-surface: 20 51 40;
    --theme-success-ink: 134 239 172;
    --theme-success-line: 34 125 73;
    --theme-warning-surface: 66 47 22;
    --theme-warning-ink: 253 230 138;
    --theme-warning-line: 180 123 26;
    --theme-danger-surface: 69 32 39;
    --theme-danger-ink: 252 165 165;
    --theme-danger-line: 185 65 74;
    --theme-info-surface: 30 48 79;
    --theme-info-ink: 147 197 253;
    --theme-info-line: 59 130 246;
}

body {
    background-color: rgb(var(--theme-canvas));
    color: rgb(var(--theme-ink));
}

/* Branded buttons and fixed-dark sections deliberately keep white link text. */
a.text-white:hover { color: #fff; }

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select,
textarea {
    background-color: rgb(var(--theme-surface));
    color: rgb(var(--theme-ink));
}

input::placeholder, textarea::placeholder { color: rgb(var(--theme-subtle)); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: #dc2626; }

/* Override the older global outline reset with a visible keyboard indicator. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid rgb(var(--theme-link));
    outline-offset: 3px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0.5rem;
    color: #d1d5db;
}
.theme-toggle:hover { color: #fff; background-color: #374151; }
.theme-toggle:focus-visible { outline-color: #fff; }
.theme-toggle svg { width: 22px; height: 22px; }
.theme-toggle .theme-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-moon { display: none; }

@media print {
    .theme-toggle { display: none; }
}
