/* Shared neutral tokens also cover the default light and dark themes. */
:root {
  --theme-background: #f5f4ed;
  --theme-surface: #ffffff;
  --theme-ink: #222e28;
  --theme-muted: #58635c;
  --theme-accent: #2c5943;
  --theme-tint: #e8eee8;
  --status-caught-bg: #cbe5d0;
  --status-caught-ink: #203c2a;
}
html[data-theme="dark"] {
  --theme-background: #141a17;
  --theme-surface: #202923;
  --theme-ink: #e0e8e2;
  --theme-muted: #acbbb0;
  --theme-accent: #a0d5b5;
  --theme-tint: #283a30;
  --status-caught-bg: #294d38;
  --status-caught-ink: #e4f3e8;
}
.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Illustrated headings keep live text and earned medals independent of artwork. */
#entries h2.illustrated-region {
  gap: 0.2rem;
  max-width: 100%;
  width: fit-content;
  margin: 0.8rem 0 0.35rem;
}
.region-heading-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: none;
}
.region-progress {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0 0.8rem;
}
.region-progress > span {
  min-width: 0;
}
#entries .region-progress .region-medal {
  flex: none;
}
.region-ornament {
  position: relative;
  display: block;
  width: clamp(3.5rem, 22vw, 7rem);
  aspect-ratio: 1.5;
  overflow: hidden;
  flex: 0 1 auto;
}
.region-ornament img {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  max-width: none;
}
.region-ornament.right img {
  left: -100%;
}
.dex-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.35rem 0;
}
.dex-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.dex-legend b {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #68746b;
  border-radius: 0.25rem;
}
.key-caught {
  background: #cbe5d0;
}
.key-missing {
  background: #e5e7e5;
}
.dex-legend .key-unknown {
  border-style: dashed;
}
.dex-legend .key-unreleased,
.dex-grid .dex-tile.unreleased {
  border: 2px dashed #886010;
  background: repeating-linear-gradient(135deg, transparent 0 7px, #88601014 7px 9px), #fff2d3;
  color: #493206;
}
.dex-grid .dex-tile.unreleased {
  padding: 4px 1px;
}
html[data-theme="dark"] .dex-legend .key-caught {
  background: #294d38;
  border-color: #719780;
}
html[data-theme="dark"] .dex-legend .key-missing {
  background: #28322d;
  border-color: #87968c;
}
html[data-theme="dark"] .dex-legend .key-unknown {
  border-color: #87968c;
}
html[data-theme="dark"] .dex-legend .key-unreleased,
html[data-theme="dark"] .dex-grid .dex-tile.unreleased {
  border: 2px dashed #e3b967;
  background: repeating-linear-gradient(135deg, transparent 0 7px, #e3b96718 7px 9px), #302718;
  color: #ffe5ac;
}
@media (forced-colors: active) {
  .dex-grid .dex-tile.unreleased,
  .dex-legend .key-unreleased {
    border: 2px dashed CanvasText;
  }
  .region-ornament {
    display: none;
  }
}
.theme-control select {
  width: auto;
  min-height: 44px;
  font: inherit;
  padding: 0.4rem 2.2rem 0.4rem 0.6rem;
  border: 1px solid #9da79f;
  border-radius: 0.5rem;
  background-color: transparent;
  color: inherit;
}
.utility-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
/* Native popup items need a matched foreground/background pair on Windows too. */
select option,
select optgroup {
  background: Canvas;
  color: CanvasText;
}
html[data-theme="dark"] {
  color-scheme: dark;
  color: #e0e8e2;
  background: #141a17;
  --muted: #acbbb0;
  --line: #3b4940;
  --green: #a0d5b5;
}
html[data-theme="dark"] body {
  background: #141a17;
  color: #e0e8e2;
}
html[data-theme="dark"] :is(a, small, .muted, .eyebrow) {
  color: #adcbb7;
}
html[data-theme="dark"] :is(.card, dialog, #ai-import, #bulk-controls, .import-row) {
  background: #202923;
  color: #e0e8e2;
  border-color: #435247;
}
html[data-theme="dark"] :is(input, select, textarea) {
  background-color: #18201b;
  color: #e0e8e2;
  border-color: #65796b;
}
html[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='m5 6.5 3 3 3-3' fill='none' stroke='%23adcbb7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
html[data-theme="dark"] button {
  background-color: #345d47;
  color: #edf5ef;
}
html[data-theme="dark"]
  :is(
    .collection-actions button,
    .assistant-disconnect,
    .evolution-link,
    #achievement-overview button,
    #agent-list button,
    .history-row button,
    #history-refresh,
    #history-more
  ) {
  background-color: #202923;
  color: #b8dfc6;
  border-color: #53685a;
}
html[data-theme="dark"] #collection-menu[open] > .collection-actions {
  background: #202923;
  color: #b8dfc6;
  border-color: #53685a;
}
html[data-theme="dark"] .dex-tile {
  background: #28322d;
  color: #e0e8e2;
  border-color: #637167;
}
html[data-theme="dark"] .dex-tile.registered {
  background: #294d38;
  border-color: #719780;
}
html[data-theme="dark"] .dex-tile.unknown {
  background: #202923;
}
html[data-theme="dark"] .dex-tile.unreleased {
  background: #3b362a;
  border-color: #8b7d5b;
}
html[data-theme="dark"] :is(.type-badge, .badge) {
  background: #344b3d;
  color: #dcf0e2;
}
html[data-theme="dark"] #achievement-overview {
  background: transparent;
  border-color: #435247;
}
html[data-theme="dark"] .achievement-badge {
  background: transparent;
  color: #aab7ae;
  border-color: transparent;
}
html[data-theme="dark"] .achievement-badge.earned {
  background: transparent;
  color: #e0e8e2;
  border-color: transparent;
}
html[data-theme="dark"]
  :is(
    .achievement-region,
    #detail-facts,
    .evolution-current,
    .assistant-row,
    .history-entries > div
  ) {
  border-color: #435247;
}
html[data-theme="dark"] .evolution-current {
  color: #acbbb0;
}
html[data-theme="dark"] dialog::backdrop {
  background: #000a;
}
html[data-theme="dark"] progress {
  accent-color: #8cc5a1;
}
html[data-theme="dark"] :focus-visible {
  outline-color: #e2ae70;
}
html[data-theme="dark"] :is(pre, code) {
  background: #202923;
  color: #d5e8dc;
}
html[data-theme="dark"] .mark {
  background: #345d47;
  color: #edf5ef;
}

html[data-theme="dark"] :is(.intro, .project-copy p, .prose, .prose h2, .grid-label, .grid-footer) {
  color: #c1d1c6;
}
html[data-theme="dark"] :is(.project-art, .rings div, .empty, .skip) {
  background-color: #202923;
}
html[data-theme="dark"] .button {
  background: #345d47;
  color: #edf5ef;
}
.shell > header {
  flex-wrap: wrap;
}
.shell > header nav {
  flex-wrap: wrap;
}

html[data-theme="dark"] select {
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

.theme-control select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='m5 6.5 3 3 3-3' fill='none' stroke='%2358635c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}
@media (forced-colors: active) {
  html .theme-control select {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
  }
}

html[data-theme="dark"] select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem;
}
html[data-theme="dark"] select[multiple] {
  background-image: none;
}
html[data-theme="dark"] .setup blockquote {
  background: #26372d;
  color: #e0e8e2;
  border-color: #8cc5a1;
}
html[data-theme="dark"] .setup section {
  border-color: #435247;
}
html[data-theme="dark"] .setup :is(input, textarea)::placeholder {
  color: #acbbb0;
  opacity: 1;
}
@media (forced-colors: active) {
  html[data-theme] select:not([multiple]) {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
  }
}
/* Keep narrow account pages compact without changing reading order. */
@media (max-width: 600px) {
  body > main:has(.utility-nav) {
    margin-top: 1rem;
  }
}
/* Success feedback uses the top layer, including inside an open dialog. */
html body .site-toast {
  position: fixed;
  inset: max(1rem, env(safe-area-inset-top)) 1rem auto auto;
  margin: 0;
  box-sizing: border-box;
  width: max-content;
  max-width: min(24rem, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem 0.55rem 1rem;
  border: 1px solid #659772;
  border-radius: 0.65rem;
  background: #edf6ef;
  color: #203c2a;
  box-shadow: 0 4px 18px #0002;
  font:
    500 0.9rem/1.5 system-ui,
    sans-serif;
  z-index: 10000;
}
html body .site-toast[hidden] {
  display: none;
}
html body .site-toast span {
  overflow-wrap: anywhere;
}
html body .site-toast button {
  flex: none;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}
html body .site-toast button:hover {
  background: #65977222;
}
html[data-theme="dark"] body .site-toast {
  background: #223d2d;
  color: #e4f3e8;
  border-color: #81ae8f;
  box-shadow: 0 4px 18px #0006;
}

#sharing .sharing-close-bar {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 5;
}
html body #sharing #close-sharing {
  position: absolute;
  right: 0;
  top: 0;
  float: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
  background: #fff;
  color: #26372c;
  border: 1px solid #65796b;
  border-radius: 50%;
}
html[data-theme="dark"] body #sharing #close-sharing {
  background: #202923;
  color: #edf5ef;
}
html body #sharing h2 {
  padding-right: 3.2rem;
}

.site-dialog-close-bar {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 10;
  margin: 0;
}
html body dialog .site-dialog-close {
  position: absolute;
  right: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
  background: #fff;
  color: #26372c;
  border: 1px solid #65796b;
  border-radius: 50%;
}
html[data-theme="dark"] body dialog .site-dialog-close {
  background: #202923;
  color: #edf5ef;
}
.site-dismissible-dialog h2 {
  padding-right: 3.2rem;
}

html body dialog .site-dialog-close {
  box-sizing: border-box;
}
html body dialog .site-dialog-close svg {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* Shared site preferences, independent of tracker content. */
.utility-nav {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.utility-nav .account-tools {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.display-menu {
  position: relative;
  font-size: inherit;
}
.display-menu[open] {
  z-index: 40;
}
html[data-theme] .account-tools > .display-menu > summary {
  width: 44px;
  justify-content: center;
  border-radius: 50%;
}
.display-menu > summary::after {
  display: none;
}
.display-menu[open] > summary,
.display-menu > summary:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.display-menu > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  gap: 0.4rem;
}
:is(.display-menu, #collection-menu, .member-actions, #detail-costumes) > summary {
  gap: 0.4rem;
  list-style: none;
}
.member-actions > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
summary::after {
  content: "";
  width: 1rem;
  height: 1rem;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='m5 6.5 3 3 3-3' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
  flex: none;
}
summary::-webkit-details-marker {
  display: none;
}
.display-options {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  padding: 0.85rem;
  border: 1px solid #ccd5ce;
  border-radius: 0.65rem;
  background: #fff;
  box-shadow: 0 6px 24px #0002;
  display: grid;
  gap: 0.65rem;
  width: 15rem;
}
html[data-theme="dark"] .display-options {
  background: #202923;
}
.display-options .theme-control {
  display: grid;
  grid-template-columns: 1fr 9rem;
  width: 100%;
  justify-self: stretch;
}
.account-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  font-size: 0.875rem;
  line-height: 1.25;
}
html[data-theme] .account-tools > a,
html[data-theme] .account-tools > .display-menu > summary {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 44px;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: none;
}
html[data-theme] .account-tools > a:hover,
html[data-theme] .account-tools > .display-menu > summary:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
details[open] > summary::after {
  transform: rotate(180deg);
}
.display-menu:not([open]) > .display-options {
  display: none;
}
.display-options label.theme-control {
  margin: 0;
  min-width: 0;
}
.display-options select {
  width: 100%;
}
html[data-theme="dark"] .display-options {
  border-color: #435247;
}
@media (max-width: 600px) {
  .utility-nav .account-tools {
    flex-wrap: nowrap;
  }
  .utility-nav .display-options .theme-control {
    width: 100%;
  }
}

.display-options {
  box-sizing: border-box;
  width: 17rem;
  max-width: calc(100vw - 2rem);
}
.display-options select {
  box-sizing: border-box;
  font: inherit;
  min-height: 44px;
  padding: 0.7rem 2.5rem 0.7rem 0.7rem;
}
/* Secondary wishlist actions keep their hierarchy in both themes. */
html[data-theme="dark"] .wish-quiet {
  background: transparent;
  color: #b8dfc6;
  border-color: #65796b;
}

/* Shared keyboard access and comfortable site-navigation targets. */
.skip {
  position: fixed;
  left: 1rem;
  top: 0;
  transform: translateY(-150%);
  max-width: calc(100vw - 2rem);
  box-sizing: border-box;
  padding: 0.75rem;
  background: #fff;
  color: #222e28;
  z-index: 100;
}
.skip:focus {
  top: 0.75rem;
  transform: none;
}
:is(.utility-nav, .shell > header) a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  box-sizing: border-box;
}
.utility-nav > a {
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Team palettes share surfaces and controls; catch status stays semantic. */
html[data-palette="mystic"] {
  --theme-background: #edf4fc;
  --theme-surface: #fafdff;
  --theme-ink: #1c3049;
  --theme-muted: #506580;
  --theme-accent: #205da0;
  --theme-line: #afc4dc;
  --theme-tint: #dceafb;
}
html[data-palette="instinct"] {
  --theme-background: #fff8e3;
  --theme-surface: #fffdf5;
  --theme-ink: #3e3216;
  --theme-muted: #70603a;
  --theme-accent: #805b00;
  --theme-line: #cbbc8c;
  --theme-tint: #f7e6ac;
}
html[data-palette="valor"] {
  --theme-background: #fcf0ef;
  --theme-surface: #fffafa;
  --theme-ink: #482626;
  --theme-muted: #805555;
  --theme-accent: #a33238;
  --theme-line: #d8b4b4;
  --theme-tint: #f7dfe0;
}
html[data-palette="alliance"] {
  --theme-background: #f4f1e5;
  --theme-surface: #fffdf5;
  --theme-ink: #202f49;
  --theme-muted: #566078;
  --theme-accent: #254d85;
  --theme-line: #baaa76;
  --theme-tint: #e6dfbd;
}
html[data-palette="horde"] {
  --theme-background: #f7ede7;
  --theme-surface: #fff9f3;
  --theme-ink: #382827;
  --theme-muted: #79564c;
  --theme-accent: #922e2a;
  --theme-line: #bd9c88;
  --theme-tint: #ecd6c5;
}
html[data-palette="midnight"] {
  --theme-background: #101827;
  --theme-surface: #19263a;
  --theme-ink: #e4ecfa;
  --theme-muted: #a7b9d3;
  --theme-accent: #8bbcff;
  --theme-line: #415776;
  --theme-tint: #243650;
  --theme-button-ink: #101827;
}
html[data-palette="ember"] {
  --theme-background: #211613;
  --theme-surface: #30201b;
  --theme-ink: #fae8de;
  --theme-muted: #d2ada0;
  --theme-accent: #f5aa78;
  --theme-line: #725246;
  --theme-tint: #432b22;
  --theme-button-ink: #211613;
}
html[data-palette="twilight"] {
  --theme-background: #1c1628;
  --theme-surface: #2a203c;
  --theme-ink: #eee5fa;
  --theme-muted: #bfb0d3;
  --theme-accent: #c8a3ff;
  --theme-line: #615078;
  --theme-tint: #392b50;
  --theme-button-ink: #1c1628;
}
html[data-palette="graphite"] {
  --theme-background: #181a1d;
  --theme-surface: #24272c;
  --theme-ink: #e9edf2;
  --theme-muted: #b4bdc9;
  --theme-accent: #becfe3;
  --theme-line: #515b69;
  --theme-tint: #323840;
  --theme-button-ink: #181a1d;
}
html[data-palette="coffee"] {
  --theme-background: #201c18;
  --theme-surface: #2d2721;
  --theme-ink: #f2ece2;
  --theme-muted: #c6baa8;
  --theme-accent: #dec79e;
  --theme-line: #695c4b;
  --theme-tint: #3c3228;
  --theme-button-ink: #201c18;
}
html[data-palette="aurora"] {
  --theme-background: #0b2026;
  --theme-surface: #163039;
  --theme-ink: #e3f6f3;
  --theme-muted: #a9cbc9;
  --theme-accent: #83e6d2;
  --theme-line: #416d78;
  --theme-tint: #203e48;
  --theme-button-ink: #0b2026;
  --theme-halo-a: #173945;
  --theme-halo-b: #302342;
  --theme-backdrop:
    radial-gradient(ellipse 55rem 35rem at 0 0, var(--theme-halo-a), transparent),
    radial-gradient(ellipse 45rem 30rem at 100% 0, var(--theme-halo-b), transparent);
}
html[data-palette="neon"] {
  --theme-background: #160e20;
  --theme-surface: #281b34;
  --theme-ink: #faeafa;
  --theme-muted: #cfb6d5;
  --theme-accent: #f4a2dc;
  --theme-line: #775078;
  --theme-tint: #3a2546;
  --theme-button-ink: #160e20;
  --theme-halo-a: #392044;
  --theme-halo-b: #103b43;
  --theme-backdrop:
    radial-gradient(ellipse 55rem 35rem at 0 0, var(--theme-halo-a), transparent),
    radial-gradient(ellipse 45rem 30rem at 100% 0, var(--theme-halo-b), transparent);
}
/* Vivid dark palettes share one static glow treatment and keep status colours separate. */
html[data-palette="arcade"] {
  --theme-background: #080d20;
  --theme-surface: #111b35;
  --theme-ink: #f0f5ff;
  --theme-muted: #b6c6e6;
  --theme-accent: #49eaff;
  --theme-heading: #ff80ce;
  --theme-line: #465b8b;
  --theme-tint: #202c4b;
  --theme-button-ink: #080d20;
  --theme-halo-a: #38103d;
  --theme-halo-b: #08334a;
}
html[data-palette="biolume"] {
  --theme-background: #061510;
  --theme-surface: #10291f;
  --theme-ink: #edfff3;
  --theme-muted: #b4d4c4;
  --theme-accent: #80ff9c;
  --theme-heading: #c7a0ff;
  --theme-line: #3e735c;
  --theme-tint: #1c382b;
  --theme-button-ink: #061510;
  --theme-halo-a: #06432d;
  --theme-halo-b: #35164d;
}
html[data-palette="eclipse"] {
  --theme-background: #120d08;
  --theme-surface: #271c13;
  --theme-ink: #fff6e5;
  --theme-muted: #dbc4a4;
  --theme-accent: #ffd166;
  --theme-heading: #ff9e80;
  --theme-line: #80603d;
  --theme-tint: #3b2a1a;
  --theme-button-ink: #120d08;
  --theme-halo-a: #4c2910;
  --theme-halo-b: #3c1230;
}
html:is([data-palette="arcade"], [data-palette="biolume"], [data-palette="eclipse"]) {
  --theme-backdrop:
    radial-gradient(ellipse 65rem 42rem at 0 0, var(--theme-halo-a), transparent 75%),
    radial-gradient(ellipse 55rem 38rem at 100% 8rem, var(--theme-halo-b), transparent 75%);
}
html:is([data-palette="arcade"], [data-palette="biolume"], [data-palette="eclipse"])
  body
  .site-content
  h1 {
  color: var(--theme-heading);
}
html[data-palette] {
  color-scheme: light;
  background: var(--theme-background);
  color: var(--theme-ink);
  --muted: var(--theme-muted);
  --line: var(--theme-line);
  --green: var(--theme-accent);
}
html[data-palette] body {
  background: var(--theme-backdrop, none) var(--theme-background);
  background-repeat: no-repeat;
  color: var(--theme-ink);
}
html[data-palette] .pokemon-page {
  --tracker-line: var(--theme-line);
}
html[data-palette] :is(a, .eyebrow) {
  color: var(--theme-accent);
}
html[data-palette] :is(small, .muted, .detail-note, .detail-sources, .evolution-current) {
  color: var(--theme-muted);
}
html[data-palette]
  :is(.card, dialog, .display-options, .evolution-card, #ai-import, #bulk-controls, .import-row),
html[data-palette] .pokemon-page #collection-menu[open] > .collection-actions {
  background-color: var(--theme-surface);
  color: var(--theme-ink);
  border-color: var(--theme-line);
}
html[data-palette] :is(input, select, textarea) {
  background-color: var(--theme-surface);
  color: var(--theme-ink);
  border-color: var(--theme-muted);
  accent-color: var(--theme-accent);
}
html[data-palette] :is(input, textarea)::placeholder {
  color: var(--theme-muted);
  opacity: 1;
}
html[data-palette]
  :is(button, .button, .primary-link):where(
    :not(
      .dex-tile,
      .achievement-badge,
      .pokemon-reference-row,
      .evolution-link,
      .trainer-code,
      .wish-quiet
    )
  ) {
  background-color: var(--theme-accent);
  color: var(--theme-button-ink, #fff);
}
html[data-palette] :is(.collection-actions, #achievement-overview, .history-row) button,
html[data-palette]
  :is(.evolution-link, .wish-quiet, .assistant-disconnect, #history-refresh, #history-more),
html[data-palette] body :is(.site-dialog-close, #close-sharing, #detail-close-top, #detail-cancel) {
  background: transparent;
  color: var(--theme-accent);
  border-color: var(--theme-line);
}
html[data-palette] body :is(.site-dialog-close, #close-sharing, #detail-close-top) {
  background: var(--theme-surface);
}
html[data-palette] :is(.collection-actions button, .evolution-link, .wish-quiet):hover {
  background-color: var(--theme-tint);
}
html[data-palette] :focus-visible {
  outline-color: var(--theme-accent);
}
html[data-palette] .mark {
  background: var(--theme-accent);
  color: var(--theme-button-ink, #fff);
}
html[data-palette] progress:not(.trainer-card progress) {
  accent-color: var(--theme-accent);
}
html[data-palette] :is(.skip, pre, code) {
  background-color: var(--theme-surface);
  color: var(--theme-ink);
}

html[data-palette][data-theme="dark"] {
  color-scheme: dark;
}

html[data-palette] .game-heading svg {
  color: var(--theme-accent);
}
/* Collection settings: the dialog header and dismissal stay outside the scrolling body. */
html body #settings-panel {
  width: calc(100% - 2rem);
  max-width: 38rem;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1rem;
  overflow: hidden;
}
#settings-panel[open] {
  display: flex;
  flex-direction: column;
}
#settings-panel > h2 {
  flex: none;
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 1.35rem;
}
#settings-panel .settings-body {
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding-right: 0.4rem;
}
#settings-panel .settings-body > section,
#settings-panel #collection-publication {
  margin: 0.75rem 0 0;
  border-top: 1px solid #65796b;
  padding-top: 0.75rem;
}
#settings-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}
#settings-panel p {
  margin: 0.35rem 0 0.6rem;
}
#settings-panel p:empty {
  display: none;
}
#settings-panel .settings-help,
#settings-panel #collection-publication p {
  font-size: 0.85rem;
  line-height: 1.5;
}
#settings-panel .settings-name button,
#settings-panel .settings-footer button {
  background: transparent;
  color: inherit;
  border: 1px solid #65796b;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
}
#settings-panel .settings-name {
  margin-top: 0.5rem;
}
#settings-panel .settings-link,
#settings-panel #collection-profile-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9rem;
}
#settings-panel #collection-browsing {
  margin-top: 0.35rem;
}
#settings-panel .connection-row {
  padding: 0.5rem 0;
  border-bottom: 0;
}
#settings-panel .connection-row label {
  margin: 0;
}
#settings-panel #agent-controls {
  margin: 0.35rem 0 0;
}
#settings-panel #agent-controls > summary {
  min-height: 44px;
  align-content: center;
  cursor: pointer;
  font-size: 0.85rem;
}
#settings-panel #collection-export {
  margin: 0;
}
#settings-panel #trash-control {
  border-top: 0 !important;
  padding-top: 0.5rem !important;
  margin-bottom: 0.25rem;
}
#settings-panel .settings-footer {
  flex: none;
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid #65796b;
  text-align: right;
}
#rename-dialog,
#connections-dialog {
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}
@media (min-width: 600px) {
  html body #settings-panel {
    padding: 1.25rem;
  }
}
#settings-panel .connection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  column-gap: 0.75rem;
  align-items: center;
}
#settings-panel .connection-row > strong,
#settings-panel .connection-row > small {
  grid-column: 1;
}
#settings-panel .connection-row > label {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-content: center;
  min-width: 44px;
  cursor: pointer;
}
#settings-panel .connection-row > label > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Site footers stand alone when the header is out of view. */
body > footer,
body > main > footer {
  text-align: center;
  justify-content: center;
}

/* Authored navigation uses decorative icons, never font-dependent arrow glyphs. */
:root {
  --site-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h10M8 3l5 5-5 5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-nav-direction="left"]::before,
[data-nav-direction="right"]::after,
[data-nav-direction="down"]::after,
[data-nav-direction="external"]::after,
.site-direction-icon {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  vertical-align: -0.15em;
  background: currentColor;
  mask: var(--site-arrow) center / contain no-repeat;
}
[data-nav-direction="left"]::before {
  transform: rotate(180deg);
  margin-inline-end: 0.4rem;
}
[data-nav-direction="right"]::after,
[data-nav-direction="down"]::after,
[data-nav-direction="external"]::after {
  margin-inline-start: 0.4rem;
}
[data-nav-direction="down"]::after {
  transform: rotate(90deg);
}
[data-nav-direction="external"]::after {
  transform: rotate(-45deg);
}
summary {
  list-style: none;
}
summary::marker {
  content: "";
}
summary::after {
  display: inline-block;
  margin-inline-start: 0.4rem;
  vertical-align: -0.15em;
}

/* Status meaning is independent of palette hue. Text and symbols remain primary. */
html body .dex-grid .dex-tile:is(.missing, .unknown):not(.unreleased),
html:root body .dex-legend :is(.key-missing, .key-unknown) {
  background: var(--theme-surface);
  color: var(--theme-ink);
  border-color: var(--theme-muted);
}
html body .dex-grid .dex-tile:is(.missing, .unknown):not(.unreleased) small {
  color: var(--theme-muted);
}
html body .dex-grid .dex-tile.registered:not(.unreleased),
html:root body .dex-legend .key-caught {
  background: color-mix(
    in srgb,
    var(--status-caught-bg) var(--caught-fill-weight, 75%),
    var(--theme-surface)
  );
  color: var(--theme-ink);
  border-color: color-mix(in srgb, var(--status-caught-ink) 30%, var(--theme-surface));
}
html body .dex-grid .dex-tile.registered:not(.unreleased) small {
  color: var(--theme-ink);
}
/* Tile edges group content; the visible marker carries status. */
html:root body .dex-grid .dex-tile:is(.missing, .unknown):not(.unreleased),
html:root body .dex-legend :is(.key-missing, .key-unknown) {
  border-color: color-mix(in srgb, var(--theme-muted) 45%, var(--theme-surface));
}
html:root body .dex-grid .dex-tile.unknown:not(.unreleased),
html:root body .dex-legend .key-unknown {
  border-style: dotted;
}
html:root body .dex-grid .dex-tile.unreleased,
html:root body .dex-legend .key-unreleased {
  background: var(--theme-surface);
  color: var(--theme-ink);
  border: 1px dashed color-mix(in srgb, #886010 65%, var(--theme-surface));
}
html:root[data-theme="dark"] body .dex-grid .dex-tile.unreleased,
html:root[data-theme="dark"] body .dex-legend .key-unreleased {
  border-color: color-mix(in srgb, #e3b967 45%, var(--theme-surface));
}
html:root body .dex-grid .dex-tile.unreleased > span:first-child,
html:root body .dex-legend .key-unreleased {
  color: #76520b;
}
html:root[data-theme="dark"] body .dex-grid .dex-tile.unreleased > span:first-child,
html:root[data-theme="dark"] body .dex-legend .key-unreleased {
  color: #e3b967;
}
html:root body .dex-grid .dex-tile.unreleased small {
  color: var(--theme-muted);
}
/* Muted text doubles as a tested boundary colour; decorative lines stay subtle. */
html body :is(input, select, textarea) {
  border-color: var(--theme-muted);
}
html body :is(input, textarea)::placeholder {
  color: var(--theme-muted);
  opacity: 1;
}
html body :focus-visible {
  outline: 3px solid var(--theme-accent);
  outline-offset: 4px;
}
html body .dex-grid .dex-tile:focus-visible {
  outline-offset: 3px;
}

/* Keep progress team-coloured without a low-contrast pale gradient. */
html body .trainer-card {
  --trainer-progress-ink: #766022;
}
html body .trainer-card[data-team="valor"] {
  --trainer-progress-ink: #a33238;
}
html body .trainer-card[data-team="mystic"] {
  --trainer-progress-ink: #205da0;
}
html body .trainer-card[data-team="instinct"] {
  --trainer-progress-ink: #805b00;
}
html[data-theme="dark"] body .trainer-card {
  --trainer-progress-ink: #d9bd77;
}
html[data-theme="dark"] body .trainer-card[data-team="valor"] {
  --trainer-progress-ink: #f18f8b;
}
html[data-theme="dark"] body .trainer-card[data-team="mystic"] {
  --trainer-progress-ink: #8bbcff;
}
html[data-theme="dark"] body .trainer-card[data-team="instinct"] {
  --trainer-progress-ink: #e7c85c;
}
html body .trainer-card progress {
  background: var(--theme-surface);
  border: 1px solid var(--theme-muted);
  box-shadow: none;
}
html body .trainer-card progress::-webkit-progress-bar {
  background: var(--theme-surface);
  box-shadow: none;
}
html body .trainer-card progress::-webkit-progress-value {
  background: var(--trainer-progress-ink);
  box-shadow: none;
}
html body .trainer-card progress::-moz-progress-bar {
  background: var(--trainer-progress-ink);
}
html body .trainer-card .trainer-collection {
  opacity: 1;
}

/* Dense grids need a perceptible state fill and an independent caught badge. */
html[data-theme="dark"] {
  --caught-fill-weight: 55%;
}
html[data-theme="dark"][data-palette] {
  --caught-fill-weight: 40%;
}
.dex-registration {
  display: block;
}
.dex-status-mark {
  display: inline-block;
  min-width: 1.15em;
  line-height: 1.3;
}
html body .dex-tile.registered .dex-status-mark {
  background: #d1ead9;
  color: #214d32;
  border-radius: 0.25rem;
  font-weight: 700;
}
html[data-theme="dark"] body .dex-tile.registered .dex-status-mark {
  background: #315b44;
  color: #edf5ef;
}
html body #trainer-identity-row:not([hidden]) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}
html body #trainer-identity-row #trainer-toggle {
  background: transparent;
  color: var(--theme-accent);
  border: 0;
  padding: 0.35rem 0.25rem;
  margin: 0;
  min-height: 44px;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Quiet utility actions share a bounded dialog with a persistent close control. */
.site-utility-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0.5rem 0 1rem;
}
html:is(:root, [data-palette]) body button.site-utility-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  background: transparent;
  color: var(--theme-ink);
  border: 1px solid transparent;
  border-radius: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: normal;
  text-align: left;
}
html:is(:root, [data-palette]) body button.site-utility-action[hidden] {
  display: none !important;
}
html:is(:root, [data-palette]) body button.site-utility-action:hover {
  background: color-mix(in srgb, var(--theme-accent) 10%, transparent);
}
html:is(:root, [data-palette]) body button.site-utility-action:focus-visible {
  outline: 3px solid var(--theme-accent);
  outline-offset: 2px;
}
html body dialog.site-utility-dialog {
  width: min(600px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: 85dvh;
  box-sizing: border-box;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--theme-line, #697d70);
  border-radius: 0.8rem;
  background: var(--theme-surface);
  color: var(--theme-ink);
}
html body dialog.site-utility-dialog[open] {
  display: flex;
  flex-direction: column;
}
.site-utility-dialog::backdrop {
  background: #0008;
}
.site-utility-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.8rem 1.25rem 0.5rem;
}
.site-utility-head h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin: 0;
  overflow-wrap: anywhere;
  min-width: 0;
}
.site-utility-head > button {
  flex-shrink: 0;
}
.site-utility-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 1.25rem 1.25rem;
  overflow-wrap: anywhere;
}
html body details.site-utility-content {
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
html body details.site-utility-content > summary {
  display: none !important;
}
.site-utility-body :is(input, select, textarea) {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}
.site-utility-body form {
  max-width: 100%;
}
.site-utility-feedback:empty {
  display: none;
}
@media (max-width: 480px) {
  .site-utility-head {
    padding: 0.75rem 1rem 0.5rem;
  }
  .site-utility-body {
    padding: 0 1rem 1rem;
  }
}

.site-utility-feedback {
  flex-shrink: 0;
  margin: 0 1.25rem 0.75rem;
  overflow-wrap: anywhere;
}
#games-rename {
  display: grid;
  gap: 0.75rem;
}
#games-rename label {
  display: grid;
  gap: 0.35rem;
}
#games-rename button {
  justify-self: start;
}
#main-content #log-options .log-form > button {
  justify-self: start;
  border-color: var(--theme-line, #65796b);
  margin: 0;
}
#log-owner-controls {
  margin-top: 1.25rem;
}

body:has(.site-utility-dialog[open]) {
  overflow: hidden;
}

/* Shared bounded collection forms keep the task and dismissal in view. */
html body dialog.bounded-dialog {
  width: calc(100% - 2rem);
  max-width: 32rem;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--theme-line);
  border-radius: 1rem;
  box-sizing: border-box;
}
.bounded-dialog > form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 2rem - 2px);
  margin: 0;
  min-width: 0;
}
.bounded-dialog-head {
  flex: none;
  padding: 1rem 1.25rem;
}
.bounded-dialog-head h2 {
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}
.bounded-dialog-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 1.25rem 1rem;
  overflow-wrap: anywhere;
}
.bounded-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  flex: none;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--theme-line);
}
html body .bounded-dialog .site-dialog-close {
  top: 1rem;
  right: 1.25rem;
}
.bounded-dialog :is(input, select, textarea) {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}
html body .bounded-dialog button.quiet {
  background: transparent;
  color: inherit;
  border: 1px solid var(--theme-line);
}
html body #sharing .site-dialog-close {
  top: 1rem;
  right: 1.25rem;
}
