:root {
  --color-bg: #f6f3ee;
  --color-surface: #fffdf8;
  --color-surface-muted: #efe7dc;
  --color-surface-elevated: rgba(255, 253, 248, 0.94);
  --color-text: #1f2933;
  --color-text-muted: #4b5a67;
  --color-text-soft: #73808c;
  --color-text-inverse: #fffdf8;
  --color-border: #d6c6b5;
  --color-border-subtle-ui: #e7ddd1;
  --color-border-strong-ui: #b59f88;
  --color-accent: #2563eb;
  --color-accent-muted: rgba(37, 99, 235, 0.14);
  --color-shadow: 0 8px 24px rgba(31, 41, 51, 0.16);
  --color-shadow-soft: 0 4px 12px rgba(31, 41, 51, 0.12);
  --theme-toggle-bg: rgba(255, 253, 248, 0.88);
  --theme-toggle-border: rgba(31, 41, 51, 0.14);
  --theme-toggle-text: #1f2933;
  --theme-toggle-shadow: 0 14px 30px rgba(31, 41, 51, 0.12);
  color-scheme: light;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  --color-bg: #0f0f0f;
  --color-surface: #181818;
  --color-surface-muted: #202020;
  --color-surface-elevated: rgba(24, 24, 24, 0.94);
  --color-text: #e8e8e8;
  --color-text-muted: #b8b8b8;
  --color-text-soft: #8d8d8d;
  --color-text-inverse: #0f0f0f;
  --color-border: rgba(232, 232, 232, 0.18);
  --color-border-subtle-ui: rgba(232, 232, 232, 0.1);
  --color-border-strong-ui: rgba(232, 232, 232, 0.3);
  --color-accent: #7aa2ff;
  --color-accent-muted: rgba(122, 162, 255, 0.18);
  --color-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --color-shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.32);
  --theme-toggle-bg: rgba(24, 24, 24, 0.82);
  --theme-toggle-border: rgba(232, 232, 232, 0.14);
  --theme-toggle-text: #f3f3f3;
  --theme-toggle-shadow: 0 18px 36px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

:root,
html[data-theme="dark"] {
  --color-surface-base: var(--color-bg);
  --color-surface-raised: var(--color-surface);
  --color-surface-sunken: var(--color-surface-muted);
  --color-surface-overlay: var(--color-surface-elevated);
  --color-text-primary: var(--color-text);
  --color-text-secondary: var(--color-text-muted);
  --color-text-muted: var(--color-text-soft);
  --color-border-default: var(--color-border);
  --color-border-subtle: var(--color-border-subtle-ui);
  --color-border-strong: var(--color-border-strong-ui);
  --shadow-sm: var(--color-shadow-soft);
  --shadow-md: var(--color-shadow-soft);
  --shadow-lg: var(--color-shadow);
  --color-page: var(--color-bg);
  --color-paper: color-mix(in srgb, var(--color-surface) 88%, transparent);
  --color-paper-solid: var(--color-surface);
  --color-ink: var(--color-text);
  --color-muted: var(--color-text-muted);
  --color-border: var(--color-border-subtle-ui);
  --color-border-strong: var(--color-border-strong-ui);
  --color-accent: #2563eb;
  --color-accent-soft: var(--color-accent-muted);
  --shadow-card: var(--color-shadow);
}

html[data-theme="dark"] body {
  color: var(--color-text);
  background-color: var(--color-bg);
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  width: 2.85rem;
  height: 2.85rem;
  border: 1px solid var(--theme-toggle-border);
  border-radius: 999px;
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--theme-toggle-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-accent) 40%, white);
  outline-offset: 3px;
}

.theme-toggle__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.theme-toggle__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
    width: 2.65rem;
    height: 2.65rem;
  }
}
