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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0 4px;
  color: inherit;
  font: 600 14px/1 Arial, sans-serif;
  white-space: nowrap;
}
.theme-toggle[hidden] {display: none}
.theme-toggle:hover .theme-label {text-decoration: underline; text-underline-offset: 3px}
.theme-toggle:focus-visible {outline-offset: 0; border-radius: 4px}
.theme-track {
  box-sizing: border-box;
  inline-size: 34px;
  block-size: 20px;
  display: flex;
  align-items: center;
  padding: 2px;
  border: 1px solid currentColor;
  border-radius: 10px;
}
.theme-track::before {
  content: "";
  inline-size: 12px;
  block-size: 12px;
  background: currentColor;
  border-radius: 50%;
}
.theme-toggle[aria-checked="true"] .theme-track {
  justify-content: flex-end;
  color: #271b16;
  background: #ffce3d;
  border-color: #ffce3d;
}
.campaign .theme-toggle {margin: 4px auto 0}
@media (max-width: 880px) {
  .tpb-red .theme-toggle {flex-direction: column; gap: 3px; font-size: 10px}
}
@media (max-width: 440px) {
  .tpb-red .logo-reverse {width: clamp(87px, 29vw, 128px)}
  header.tpb-red, .store-page header.tpb-red {gap: 7px}
  .tpb-red .exam-cta {padding-inline: 9px}
}
@media (max-width: 360px) {
  header.tpb-red, .store-page header.tpb-red {gap: 5px}
  .tpb-red summary, .tpb-red .exam-cta {font-size: 12px; white-space: nowrap}
  .tpb-red .exam-cta {padding-inline: 7px}
}
@media (forced-colors: active) {
  .theme-track::before {background: ButtonText}
}

.appearance {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-top: .75rem;
  font: inherit;
}
.appearance[hidden] {display: none}
.appearance select {
  min-height: 36px;
  padding: .25rem .5rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: Canvas;
  color: CanvasText;
  font: inherit;
}
.appearance select:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.publisher-end .appearance select:focus-visible {outline-color: #ffce3d}
.publisher-end .appearance select {
  color-scheme: dark;
  background: #48201c;
  color: #fffaf5;
  border-color: #b79890;
}

@media (prefers-color-scheme: dark) {
  /* Dark palette for the storefront. The build applies this to system and pinned dark mode. */
  :root:not([data-theme="light"]) {
    --night-page: #1c1918;
    --night-ink: #faf2e9;
    --night-muted: #d7c9bf;
    --night-field: #2d2623;
    --night-outline: #9c897e;
    --night-gold: #ffce3d;
    --night-link: #ffd78d;
    --night-card: #302a27;
    --night-cream: #433932;
    --night-sage: #344239;
    --night-gold-paper: #4a3c28;
    --night-clay: #4b3431;
    --night-band-cream: #2a211e;
    --night-band-sage: #26342b;
    --night-band-gold: #27374a;
    --night-band-clay: #542824;
    background: var(--night-page);
    color: var(--night-ink);
  }
  :root:not([data-theme="light"]) .store-page, :root:not([data-theme="light"]) .store-page:has(#store), :root:not([data-theme="light"]) .store-page #directory {
    background: var(--night-page);
    color: var(--night-ink);
    border-color: var(--night-field);
  }
  :root:not([data-theme="light"]) body.credits-page {color: var(--night-ink)}
  :root:not([data-theme="light"]) .credits-page article {border-color: var(--night-field)}
  :root:not([data-theme="light"]) .exam-headline.full-spread {
    background: linear-gradient(118deg, #342622, #211b19 40%, #211b19 60%, #342622);
    color: var(--night-ink);
  }
  :root:not([data-theme="light"]) .exam-headline .exam-word, :root:not([data-theme="light"]) .store-intro h1 span {color: var(--night-gold)}
  :root:not([data-theme="light"]) .campaign .rotation {background: #171414; border: 1px solid #6b5952}
  :root:not([data-theme="light"]) .skip {background: var(--night-field)}
  :root:not([data-theme="light"]) :is(.store-tools > a, .store-page .section-head > a, .collection-page .back-library, .formats-reset) {
    color: var(--night-link);
  }
  :root:not([data-theme="light"]) :is(.amazon-link-note, .listing-meta output, .filters output, .formats-toolbar) {
    color: var(--night-muted);
  }
  :root:not([data-theme="light"]) :is(.campaign #top-search, .store-tools #top-search, #catalog-search, .format-exam-field, .filters select) {
    background: var(--night-field);
    border-color: var(--night-outline);
    color: var(--night-ink);
  }
  :root:not([data-theme="light"]) .format-exam-search, :root:not([data-theme="light"]) .format-exam-field input {color: var(--night-ink)}
  :root:not([data-theme="light"]) :is(#top-query, #query, #format-exam)::placeholder {color: var(--night-muted); opacity: 1}
  :root:not([data-theme="light"]) :is(.campaign #top-search button, #catalog-search button, .format-exam-field [type="submit"], #more, #letters button[aria-pressed="true"]) {
    background: var(--night-gold);
    color: #302522;
  }
  :root:not([data-theme="light"]) :is(#top-search, #catalog-search, #format-exam-search .format-exam-field):focus-within {
    outline: 2px solid var(--night-link);
    outline-offset: 2px;
    box-shadow: none;
  }
  :root:not([data-theme="light"]) :is(a, button, select, [tabindex]):focus-visible {outline-color: var(--night-link)}
  :root:not([data-theme="light"]) :is(.campaign #top-search button, #catalog-search button, .format-exam-field [type="submit"], #more, #letters button[aria-pressed="true"]):focus-visible {
    outline: 2px solid var(--night-link);
    outline-offset: 3px;
  }
  :root:not([data-theme="light"]) .tpb-red .exam-cta:focus-visible {outline-color: #302522}

  /* Preserve the existing card placement, band spacing, and product artwork. */
  :root:not([data-theme="light"]) .format-gallery a {color: var(--night-ink)}
  :root:not([data-theme="light"]) .format-gallery a[aria-current="true"] .format-name {border-color: var(--night-gold)}
  :root:not([data-theme="light"]) #store :is(.format-gallery a:nth-child(1), .format-shelf .product:nth-child(4n+1)) {--paper: var(--night-cream); --band: var(--night-band-cream)}
  :root:not([data-theme="light"]) #store :is(.format-gallery a:nth-child(2), .format-shelf .product:nth-child(4n+2)) {--paper: var(--night-sage); --band: var(--night-band-sage)}
  :root:not([data-theme="light"]) #store :is(.format-gallery a:nth-child(3), .format-shelf .product:nth-child(4n+3)) {--paper: var(--night-gold-paper); --band: var(--night-band-gold)}
  :root:not([data-theme="light"]) #store :is(.format-gallery a:nth-child(4), .format-shelf .product:nth-child(4n)) {--paper: var(--night-clay); --band: var(--night-band-clay)}
  :root:not([data-theme="light"]) #store .format-shelf .product {
    background-color: var(--paper, var(--night-card));
    color: var(--night-ink);
  }
  :root:not([data-theme="light"]) #store .format-shelf .product:is(:nth-child(5n+1), :nth-child(5n+4)) {background-color: var(--night-card)}
  :root:not([data-theme="light"]) .store-page #results .product {
    --listing-paper: var(--night-cream);
    --listing-band: var(--night-band-cream);
    color: var(--night-ink);
    border-color: #75605755;
  }
  :root:not([data-theme="light"]) #results .product.tone-1, :root:not([data-theme="light"]) #results > .product:nth-child(4n+2) {--listing-paper: var(--night-sage); --listing-band: var(--night-band-sage)}
  :root:not([data-theme="light"]) #results .product.tone-2, :root:not([data-theme="light"]) #results > .product:nth-child(4n+3) {--listing-paper: var(--night-gold-paper); --listing-band: var(--night-band-gold)}
  :root:not([data-theme="light"]) #results .product.tone-3, :root:not([data-theme="light"]) #results > .product:nth-child(4n) {--listing-paper: var(--night-clay); --listing-band: var(--night-band-clay)}
  :root:not([data-theme="light"]) #results .product.paper-white, :root:not([data-theme="light"]) #results > .product:is(:nth-child(5n+1), :nth-child(5n+4)) {background-color: var(--night-card)}
  :root:not([data-theme="light"]) #results .product .surface img, :root:not([data-theme="light"]) .rail .product .surface img, :root:not([data-theme="light"]) .format-gallery img {mix-blend-mode: normal}
  :root:not([data-theme="light"]) .rail .product .surface {background-color: var(--night-card)}
  :root:not([data-theme="light"]) #store .format-shelf .product .surface {background-color: transparent}
  :root:not([data-theme="light"]) .rail {scrollbar-color: #9c897e #342b27}
  :root:not([data-theme="light"]) .shelf-controls button {color: var(--night-ink)}
  :root:not([data-theme="light"]) .shelf-controls button::before {background: #4d4039}
  :root:not([data-theme="light"]) .shelf-controls button:not([aria-disabled="true"]):hover::before {background: #6b574c}
}

/* Dark palette for the storefront. The build applies this to system and pinned dark mode. */
:root[data-theme="dark"] {
  --night-page: #1c1918;
  --night-ink: #faf2e9;
  --night-muted: #d7c9bf;
  --night-field: #2d2623;
  --night-outline: #9c897e;
  --night-gold: #ffce3d;
  --night-link: #ffd78d;
  --night-card: #302a27;
  --night-cream: #433932;
  --night-sage: #344239;
  --night-gold-paper: #4a3c28;
  --night-clay: #4b3431;
  --night-band-cream: #2a211e;
  --night-band-sage: #26342b;
  --night-band-gold: #27374a;
  --night-band-clay: #542824;
  background: var(--night-page);
  color: var(--night-ink);
}
:root[data-theme="dark"] .store-page, :root[data-theme="dark"] .store-page:has(#store), :root[data-theme="dark"] .store-page #directory {
  background: var(--night-page);
  color: var(--night-ink);
  border-color: var(--night-field);
}
:root[data-theme="dark"] body.credits-page {color: var(--night-ink)}
:root[data-theme="dark"] .credits-page article {border-color: var(--night-field)}
:root[data-theme="dark"] .exam-headline.full-spread {
  background: linear-gradient(118deg, #342622, #211b19 40%, #211b19 60%, #342622);
  color: var(--night-ink);
}
:root[data-theme="dark"] .exam-headline .exam-word, :root[data-theme="dark"] .store-intro h1 span {color: var(--night-gold)}
:root[data-theme="dark"] .campaign .rotation {background: #171414; border: 1px solid #6b5952}
:root[data-theme="dark"] .skip {background: var(--night-field)}
:root[data-theme="dark"] :is(.store-tools > a, .store-page .section-head > a, .collection-page .back-library, .formats-reset) {
  color: var(--night-link);
}
:root[data-theme="dark"] :is(.amazon-link-note, .listing-meta output, .filters output, .formats-toolbar) {
  color: var(--night-muted);
}
:root[data-theme="dark"] :is(.campaign #top-search, .store-tools #top-search, #catalog-search, .format-exam-field, .filters select) {
  background: var(--night-field);
  border-color: var(--night-outline);
  color: var(--night-ink);
}
:root[data-theme="dark"] .format-exam-search, :root[data-theme="dark"] .format-exam-field input {color: var(--night-ink)}
:root[data-theme="dark"] :is(#top-query, #query, #format-exam)::placeholder {color: var(--night-muted); opacity: 1}
:root[data-theme="dark"] :is(.campaign #top-search button, #catalog-search button, .format-exam-field [type="submit"], #more, #letters button[aria-pressed="true"]) {
  background: var(--night-gold);
  color: #302522;
}
:root[data-theme="dark"] :is(#top-search, #catalog-search, #format-exam-search .format-exam-field):focus-within {
  outline: 2px solid var(--night-link);
  outline-offset: 2px;
  box-shadow: none;
}
:root[data-theme="dark"] :is(a, button, select, [tabindex]):focus-visible {outline-color: var(--night-link)}
:root[data-theme="dark"] :is(.campaign #top-search button, #catalog-search button, .format-exam-field [type="submit"], #more, #letters button[aria-pressed="true"]):focus-visible {
  outline: 2px solid var(--night-link);
  outline-offset: 3px;
}
:root[data-theme="dark"] .tpb-red .exam-cta:focus-visible {outline-color: #302522}

/* Preserve the existing card placement, band spacing, and product artwork. */
:root[data-theme="dark"] .format-gallery a {color: var(--night-ink)}
:root[data-theme="dark"] .format-gallery a[aria-current="true"] .format-name {border-color: var(--night-gold)}
:root[data-theme="dark"] #store :is(.format-gallery a:nth-child(1), .format-shelf .product:nth-child(4n+1)) {--paper: var(--night-cream); --band: var(--night-band-cream)}
:root[data-theme="dark"] #store :is(.format-gallery a:nth-child(2), .format-shelf .product:nth-child(4n+2)) {--paper: var(--night-sage); --band: var(--night-band-sage)}
:root[data-theme="dark"] #store :is(.format-gallery a:nth-child(3), .format-shelf .product:nth-child(4n+3)) {--paper: var(--night-gold-paper); --band: var(--night-band-gold)}
:root[data-theme="dark"] #store :is(.format-gallery a:nth-child(4), .format-shelf .product:nth-child(4n)) {--paper: var(--night-clay); --band: var(--night-band-clay)}
:root[data-theme="dark"] #store .format-shelf .product {
  background-color: var(--paper, var(--night-card));
  color: var(--night-ink);
}
:root[data-theme="dark"] #store .format-shelf .product:is(:nth-child(5n+1), :nth-child(5n+4)) {background-color: var(--night-card)}
:root[data-theme="dark"] .store-page #results .product {
  --listing-paper: var(--night-cream);
  --listing-band: var(--night-band-cream);
  color: var(--night-ink);
  border-color: #75605755;
}
:root[data-theme="dark"] #results .product.tone-1, :root[data-theme="dark"] #results > .product:nth-child(4n+2) {--listing-paper: var(--night-sage); --listing-band: var(--night-band-sage)}
:root[data-theme="dark"] #results .product.tone-2, :root[data-theme="dark"] #results > .product:nth-child(4n+3) {--listing-paper: var(--night-gold-paper); --listing-band: var(--night-band-gold)}
:root[data-theme="dark"] #results .product.tone-3, :root[data-theme="dark"] #results > .product:nth-child(4n) {--listing-paper: var(--night-clay); --listing-band: var(--night-band-clay)}
:root[data-theme="dark"] #results .product.paper-white, :root[data-theme="dark"] #results > .product:is(:nth-child(5n+1), :nth-child(5n+4)) {background-color: var(--night-card)}
:root[data-theme="dark"] #results .product .surface img, :root[data-theme="dark"] .rail .product .surface img, :root[data-theme="dark"] .format-gallery img {mix-blend-mode: normal}
:root[data-theme="dark"] .rail .product .surface {background-color: var(--night-card)}
:root[data-theme="dark"] #store .format-shelf .product .surface {background-color: transparent}
:root[data-theme="dark"] .rail {scrollbar-color: #9c897e #342b27}
:root[data-theme="dark"] .shelf-controls button {color: var(--night-ink)}
:root[data-theme="dark"] .shelf-controls button::before {background: #4d4039}
:root[data-theme="dark"] .shelf-controls button:not([aria-disabled="true"]):hover::before {background: #6b574c}
