:root {
  color-scheme: light dark;

  /* Page surfaces, typography and controls. */
  --canvas: light-dark(#f7f9fc, #11151e);
  --surface: light-dark(#ffffff, #191f2a);
  --surface-raised: light-dark(#ffffff, #212936);
  --surface-hover: light-dark(#e9eef5, #242d3c);
  --ink: light-dark(#171c26, #f1f5fc);
  --text-secondary: light-dark(#414e61, #ced8e8);
  --muted: light-dark(#526074, #acbbcf);
  --line: light-dark(#e2e7ef, #364253);
  --control-line: light-dark(#78879e, #718198);

  /* Accent text on a surface and filled actions have different contrast needs. */
  --accent: light-dark(#204cb6, #a4c2ff);
  --wash: light-dark(#edf3ff, #202f4a);
  --wash-hover: light-dark(#dce8ff, #2a4268);
  --accent-line: light-dark(#d5e2ff, #3a5481);
  --accent-pattern: light-dark(#b0c9fd, #496493);
  --action: light-dark(#204cb6, #a4c2ff);
  --action-hover: light-dark(#183b91, #bed3ff);
  --action-active: light-dark(#132d70, #8cb1fd);
  --on-action: light-dark(#ffffff, #172644);

  /* Tinted panels, illustrations and overlays. */
  --panel-tint: light-dark(#182b50, #25395e);
  --panel-avatar: light-dark(#213b71, #324d80);
  --on-panel: #f5f8ff;
  --on-panel-muted: #c1d3f5;
  --on-panel-line: #f5f8ff44;
  --panel-pattern: light-dark(#b0c9fd42, #8cb1fd43);
  --panel-glow: light-dark(#2c52a8, #395c9e);
  --illustration-back: light-dark(#2a4779, #345489);
  --illustration-front: light-dark(#3660a5, #355a98);
  --illustration-detail: light-dark(#5c83c3, #648ac8);
  --illustration-line: #d5e4ff8c;
  --illustration-tile: light-dark(#dbe8ff, #b9cef5);
  --illustration-tile-ink: #4b6ba3;
  --overlay: light-dark(#0e1c36a0, #06090fbc);
  --shadow-subtle: light-dark(#182b500d, #06090f48);
  --shadow-raised: light-dark(#19284a26, #06090f88);

  /* Feedback colors. */
  --danger: light-dark(#852b2b, #ffb5b5);
  --danger-line: light-dark(#c17f7f, #a36369);
  --danger-surface: light-dark(#fff2f2, #41252c);
}

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

.theme-picker {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--wash);
  color: var(--accent);
  touch-action: manipulation;
}

.theme-picker:hover { background: var(--wash-hover); }
.theme-picker:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-picker svg { display: block; width: 21px; height: 21px; }
.theme-picker svg g { transform-origin: 12px 12px; }
.theme-picker__moon { opacity: 0; transform: rotate(38deg) scale(.65); }
.theme-picker[aria-pressed="true"] .theme-picker__sun { opacity: 0; transform: rotate(-42deg) scale(.65); }
.theme-picker[aria-pressed="true"] .theme-picker__moon { opacity: 1; transform: none; }

@property --theme-sweep {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@media (prefers-reduced-motion: no-preference) {
  .theme-picker { transition: background-color .22s ease, transform .2s var(--ease-out); }
  .theme-picker:hover { transform: translateY(-1px); }
  .theme-picker:active { transform: scale(.91); }
  .theme-picker svg g { transition: opacity .24s ease, transform .36s var(--ease-out); }

  :root.theme-revealing :where(article, section, button, input, select, a, summary) { transition: none; }
  :root.theme-revealing .theme-picker[data-theme-transition] { view-transition-name: theme-picker; transform: none; }
  :root.theme-revealing .theme-picker[data-theme-transition] svg g { transition: none; }
  :root.theme-revealing::view-transition { pointer-events: none; }
  :root.theme-revealing::view-transition-group(root) { animation-duration: .6s; }
  :root.theme-revealing::view-transition-old(root) {
    animation: none;
    mix-blend-mode: normal;
  }
  :root.theme-revealing::view-transition-new(root) {
    animation: theme-reveal .6s cubic-bezier(.33, .85, .3, 1) both;
    mask-image: radial-gradient(
      circle at var(--theme-reveal-origin),
      #000 max(0px, calc(var(--theme-sweep) - 42px)),
      transparent var(--theme-sweep)
    );
    mix-blend-mode: normal;
  }

  :root.theme-revealing::view-transition-group(theme-picker) { z-index: 1; animation: none; }
  :root.theme-revealing::view-transition-old(theme-picker) {
    animation: theme-icon-out .24s ease-in both;
    mix-blend-mode: normal;
  }
  :root.theme-revealing::view-transition-new(theme-picker) {
    animation: theme-icon-in .38s cubic-bezier(.22, .85, .35, 1.12) both;
    mix-blend-mode: normal;
  }

  :root.theme-fading :where(body, main, nav, section, article, aside, header, footer, dialog, button, input, select, a, .login-shell, .profile-panel) {
    transition: background-color .34s ease, color .34s ease, border-color .34s ease, box-shadow .34s ease;
  }
}

@keyframes theme-reveal {
  from { --theme-sweep: 0px; }
  to { --theme-sweep: calc(var(--theme-reveal-radius) + 42px); }
}

@keyframes theme-icon-out {
  to { opacity: 0; transform: rotate(-36deg) scale(.76); }
}

@keyframes theme-icon-in {
  from { opacity: 0; transform: rotate(42deg) scale(.76); }
  to { opacity: 1; transform: none; }
}
