:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] input[type="date"] { color-scheme: light; }
:root[data-theme="dark"] input[type="date"] { color-scheme: dark; }

:root[data-theme="light"][data-theme-palette="strict"] {
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --text: #17191d;
  --muted: #667085;
  --line: #d9dde5;
  --accent: #1769e0;
  --accent-soft: #e9f1ff;
  --positive: #c6242f;
  --negative: #14804a;
  --warning: #9a5b00;
  --focus: #0a84ff;
  --shadow: 0 8px 24px rgba(20, 28, 42, 0.08);
}

:root[data-theme="dark"][data-theme-palette="strict"] {
  --page: #111316;
  --surface: #1b1e23;
  --surface-muted: #242830;
  --text: #f2f3f5;
  --muted: #a4acb9;
  --line: #363c46;
  --accent: #6aa8ff;
  --accent-soft: #1d3555;
  --positive: #ff6670;
  --negative: #54c78a;
  --warning: #f0ad45;
  --focus: #0a84ff;
  --shadow: none;
}

:root[data-theme="light"][data-theme-palette="auth"] {
  --page: #f2f4f7;
  --surface: #ffffff;
  --text: #17191d;
  --muted: #667085;
  --line: #d7dce4;
  --accent: #1769e0;
  --accent-hover: #0f57bd;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success: #067647;
  --success-soft: #ecfdf3;
  --focus: #0a84ff;
  --shadow: 0 14px 36px rgba(24, 34, 52, 0.12);
}

:root[data-theme="dark"][data-theme-palette="auth"] {
  --page: #111316;
  --surface: #1b1e23;
  --text: #f2f3f5;
  --muted: #a4acb9;
  --line: #363c46;
  --accent: #4f91ed;
  --accent-hover: #6aa5f4;
  --danger: #ff8b82;
  --danger-soft: #3a2021;
  --success: #6ce9a6;
  --success-soft: #16372a;
  --focus: #0a84ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

:root[data-theme="light"][data-theme-palette="users"] {
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --text: #17191d;
  --muted: #667085;
  --line: #d9dee7;
  --line-strong: #c8cfda;
  --accent: #1769e0;
  --accent-soft: #eaf2ff;
  --accent-hover: #0f57bd;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #9a6700;
  --warning-soft: #fff7db;
  --focus: #0a84ff;
  --shadow: 0 8px 24px rgba(20, 28, 42, 0.08);
}

:root[data-theme="dark"][data-theme-palette="users"] {
  --page: #111316;
  --surface: #1b1e23;
  --surface-muted: #242830;
  --text: #f2f3f5;
  --muted: #a4acb9;
  --line: #363c46;
  --line-strong: #4b5360;
  --accent: #6aa8ff;
  --accent-soft: #243d63;
  --accent-hover: #82b6ff;
  --danger: #ff8b82;
  --danger-soft: #3a2021;
  --success: #6ce9a6;
  --success-soft: #16372a;
  --warning: #f5c563;
  --warning-soft: #3c3217;
  --focus: #0a84ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

:root[data-theme="light"][data-theme-palette="original"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #5b677b;
  --line: #dbe3ee;
  --accent: #2358d8;
  --accent-soft: #eaf0ff;
  --positive: #0f766e;
  --positive-soft: #e6f7f4;
  --warning: #b45309;
  --warning-soft: #fff4e5;
  --negative: #b42318;
  --negative-soft: #feeceb;
  --focus: #0a84ff;
  --shadow: 0 10px 30px rgba(24, 42, 74, 0.08);
}

:root[data-theme="dark"][data-theme-palette="original"] {
  --bg: #08101d;
  --surface: #111b2b;
  --surface-soft: #172338;
  --text: #f1f5fb;
  --muted: #a8b4c7;
  --line: #2a3950;
  --accent: #82a7ff;
  --accent-soft: #1b315f;
  --positive: #5ee0cf;
  --positive-soft: #103a38;
  --warning: #ffc26d;
  --warning-soft: #452e10;
  --negative: #ff938b;
  --negative-soft: #4a211f;
  --focus: #0a84ff;
  --shadow: none;
}

.theme-toggle {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  padding: 0;
  border: 1px solid var(--line, #d9dde5);
  border-radius: 6px;
  background: var(--surface, #ffffff);
  color: var(--text, #17191d);
  cursor: pointer;
}

.theme-toggle:hover { background: var(--surface-muted, #f8f9fb); }
.theme-toggle:focus-visible {
  outline: 2px solid var(--focus, #0a84ff);
  outline-offset: 2px;
}
.theme-toggle [data-theme-icon] { font-size: 18px; line-height: 1; }
.theme-toggle-floating {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 20;
}

@media (max-width: 720px) {
  .topbar .theme-toggle {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-basis: 44px;
  }
}
