/* Semantic dark palette. Light-mode fallbacks stay with their components.
   Screen-only tokens deliberately leave printed documents in the light palette. */
:root { color-scheme: light; }
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --theme-canvas: #181a1e;
    --theme-surface: #202329;
    --theme-soft: #262a31;
    --theme-raised: #30353e;
    --theme-text: #f1f2f4;
    --theme-muted: #bcc2cb;
    --theme-subtle: #a6aebb;
    --theme-border: #464d59;
    --theme-solid: #353d49;
    --theme-accent-text: #ff75a5;
    --theme-accent-soft: #35222e;
    --theme-success-text: #8edbb5;
    --theme-success-soft: #21362d;
    --theme-warning-text: #f2cb8f;
    --theme-warning-soft: #373024;
    --theme-info-text: #a6c8f6;
    --theme-info-soft: #243141;
    --theme-error-text: #ffabb8;
    --theme-error-soft: #3a252e;
    --theme-surface-rgb: 32, 35, 41;
    --theme-line-rgb: 220, 225, 234;
    --theme-highlight-rgb: 65, 71, 82;
    background: var(--theme-canvas);
    color: var(--theme-text);
  }
  html[data-theme="dark"] input::placeholder,
  html[data-theme="dark"] textarea::placeholder { color: var(--theme-subtle); opacity: 1; }
  html[data-theme="dark"] :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]) { border-color: #657080; }
  html[data-theme="dark"] :focus-visible { outline-color: var(--theme-accent-text); }
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--theme-muted, #4b5563);
  cursor: pointer;
  touch-action: manipulation;
}
.theme-toggle::before {
  position: absolute;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border: 1px solid var(--theme-border, #dce0e5);
  border-radius: 50%;
  background: var(--theme-surface, #fff);
  content: "";
  pointer-events: none;
}
.theme-toggle:hover { background: transparent; color: var(--theme-accent-text, #cf0048); }
.theme-toggle:hover::before { background: var(--theme-soft, #f1f3f5); }
.theme-toggle:focus-visible { outline: none; }
.theme-toggle:focus-visible::before { outline: 2px solid var(--theme-accent-text, #cf0048); outline-offset: 3px; }
.theme-toggle svg { position: relative; width: 14px; height: 14px; pointer-events: none; }
.theme-toggle .theme-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
.theme-toggle-standalone { position: fixed; z-index: 40; top: 20px; right: 20px; }
@media print { .theme-toggle { display: none !important; } }
