:root {
  --ink: #000;
  --paper: #fff;
  --panel: #000;
  --panel-ink: #fff;
  --accent: #000;
  --accent-ink: #fff;
  --surface: #fff;
  --highlight: #fff;
}

:root[data-theme="hot-dog-stand"] {
  --ink: #000;
  --paper: #ffff00;
  --panel: #ff0000;
  --panel-ink: #fff;
  --accent: #ff0000;
  --accent-ink: #fff;
  --surface: #fff;
  --highlight: #ffff00;
}

:root[data-theme="halloween"] {
  --ink: #fff4df;
  --paper: #111;
  --panel: #ff7a00;
  --panel-ink: #16100a;
  --accent: #ff7a00;
  --accent-ink: #16100a;
  --surface: #24160d;
  --highlight: #3a210d;
}

:root[data-theme="christmas"] {
  --ink: #174d2a;
  --paper: #fffaf0;
  --panel: #b5121b;
  --panel-ink: #fff;
  --accent: #18733a;
  --accent-ink: #fff;
  --surface: #e8f3df;
  --highlight: #fff;
}

:root[data-theme="valentine"] {
  --ink: #6d1230;
  --paper: #fff6f8;
  --panel: #d81b60;
  --panel-ink: #fff;
  --accent: #ff8fb3;
  --accent-ink: #4d0d24;
  --surface: #ffe2ec;
  --highlight: #fff;
}

:root[data-theme="easter"] {
  --ink: #284b63;
  --paper: #fffaf0;
  --panel: #9dc9ff;
  --panel-ink: #183349;
  --accent: #f4b9d8;
  --accent-ink: #48253a;
  --surface: #fff3a8;
  --highlight: #fff;
}

:root[data-theme="ocean"] {
  --ink: #073b4c;
  --paper: #eafaff;
  --panel: #087e8b;
  --panel-ink: #fff;
  --accent: #00b4d8;
  --accent-ink: #052c3a;
  --surface: #cceff5;
  --highlight: #fff;
}

[data-theme-picker-mount] {
  position: relative;
  z-index: 1000;
  width: min(100%, 360px);
  margin-top: 12px;
  color: var(--ink);
  font-family: "Noto Sans Mono", "Courier New", monospace;
  font-size: 16px;
  line-height: 1.45;
  text-align: left;
}

body > [data-theme-picker-mount] {
  width: min(1180px, calc(100% - clamp(22px, 4vw, 48px)));
  margin: 18px auto 0;
}

.theme-picker {
  position: relative;
  width: min(100%, 360px);
}

.theme-picker > summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 8px 10px;
  color: var(--accent-ink);
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.theme-picker > summary::-webkit-details-marker {
  display: none;
}

.theme-picker > summary::after {
  content: "+";
  flex: 0 0 auto;
  font-size: 1.25rem;
  line-height: 1;
}

.theme-picker[open] > summary::after {
  content: "−";
}

.theme-current {
  margin-left: auto;
  font-weight: 400;
  text-align: right;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  width: 100%;
  gap: 6px;
  border: 2px solid var(--ink);
  padding: 8px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
}

.theme-menu button {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 7px 9px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.theme-menu button:hover,
.theme-menu button:focus-visible,
.theme-menu button[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.theme-menu button[aria-pressed="true"]::after {
  content: "✓";
  margin-left: auto;
}

.theme-swatch {
  flex: 0 0 auto;
  width: 30px;
  height: 20px;
  border: 1px solid currentColor;
  background: var(--swatch-a);
  box-shadow: inset -14px 0 0 var(--swatch-b);
}

.swatch-default { --swatch-a: #fff; --swatch-b: #000; }
.swatch-hot-dog { --swatch-a: #ffff00; --swatch-b: #ff0000; }
.swatch-halloween { --swatch-a: #111; --swatch-b: #ff7a00; }
.swatch-christmas { --swatch-a: #fffaf0; --swatch-b: #b5121b; }
.swatch-valentine { --swatch-a: #fff6f8; --swatch-b: #ff8fb3; }
.swatch-easter { --swatch-a: #fff3a8; --swatch-b: #9dc9ff; }
.swatch-ocean { --swatch-a: #eafaff; --swatch-b: #00b4d8; }

html[data-theme],
html[data-theme] body {
  color: var(--ink);
  background: var(--paper);
}

html[data-theme] body *:not(#email-signature):not(#email-signature *) {
  border-color: var(--ink) !important;
}

html[data-theme] a {
  color: var(--ink);
}

html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea,
html[data-theme] button,
html[data-theme] .profile-links a,
html[data-theme] nav a,
html[data-theme] .link-list a,
html[data-theme] .project-index summary,
html[data-theme] .printer-callout a,
html[data-theme] .api-result,
html[data-theme] .positioning-grid article,
html[data-theme] .project-themes article,
html[data-theme] .preview,
html[data-theme] .model-card,
html[data-theme] .reference-panel,
html[data-theme] .paint-panel,
html[data-theme] .commands-panel,
html[data-theme] .prompt-box,
html[data-theme] .range,
html[data-theme] mark,
html[data-theme] .leaderboard-thumb,
html[data-theme] .download-grid a,
html[data-theme] img,
html[data-theme] video {
  color: var(--ink);
  background-color: var(--surface);
}

html[data-theme] .profile-links .button-primary,
html[data-theme] .link-list .primary-link,
html[data-theme] .submit-btn,
html[data-theme] button.active,
html[data-theme] .section-controls button:first-child,
html[data-theme] .section-heading,
html[data-theme] .consent-banner {
  color: var(--panel-ink);
  background: var(--panel);
}

html[data-theme] .profile-links a:hover,
html[data-theme] nav a:hover,
html[data-theme] .link-list a:hover,
html[data-theme] button:hover,
html[data-theme] button:focus-visible,
html[data-theme] .project-index summary:hover,
html[data-theme] .printer-callout a:hover,
html[data-theme] .download-grid a:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

html[data-theme] .profile-links .button-primary:hover,
html[data-theme] .link-list .primary-link:hover,
html[data-theme] .section-controls button:first-child:hover {
  color: var(--ink);
  background: var(--highlight);
}

html[data-theme] .theme-picker > summary,
html[data-theme] .theme-menu button:hover,
html[data-theme] .theme-menu button:focus-visible,
html[data-theme] .theme-menu button[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

html[data-theme] .theme-menu {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
}

html[data-theme] .theme-menu button {
  color: var(--ink);
  background: var(--surface);
}

html[data-theme] ::selection {
  color: var(--accent-ink);
  background: var(--accent);
}

/* Keep the copyable email signature itself intentionally black and white. */
html[data-theme] #email-signature,
html[data-theme] #email-signature * {
  border-color: #000 !important;
}

@media (max-width: 560px) {
  [data-theme-picker-mount],
  .theme-picker {
    width: 100%;
  }

  .theme-menu {
    position: static;
    margin-top: 6px;
    box-shadow: none;
  }
}
