* { box-sizing: border-box; }

[hidden] { display: none !important; }

@font-face {
  font-family: "pogodex-icons";
  src: url("fonts/pogodex-icons.woff2") format("woff2");
  font-display: block;
}

.pi {
  display: inline-block;
  font-family: "pogodex-icons" !important;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
}

.pi-dex::before { content: "\f192"; }
.pi-species::before { content: "\f2c9"; }
.pi-stats::before { content: "\f17a"; }
.pi-offline::before { content: "\f61b"; }
.pi-data::before { content: "\f8be"; }
.pi-settings::before { content: "\f3e2"; }
.pi-profile::before { content: "\f4d7"; }
.pi-chanceux::before { content: "\f586"; }

:root, [data-theme="dark"] {
  --bg: #17181c;
  --bg-elevated: #1f2126;
  --surface: #23262c;
  --surface-alt: #2b2e35;
  --border: #34373f;
  --border-strong: #4a4d55;
  --text: #f2f3f5;
  --text-muted: #9a9ea6;
  --text-faint: #6b6e75;
  --accent: #6ecb47;
  --accent-soft: rgba(110, 203, 71, .18);
  --team-none-accent: #6ecb47;
  --owned: #39d98a;
  --owned-soft: rgba(57, 217, 138, .14);
  --shiny: #f6c344;
  --perfect: #f6c344;
  --custom: #8b8f98;
  --best-friend: #ef5da8;
  --danger: #ef5350;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-alt: #eef0f3;
  --border: #dde1e6;
  --border-strong: #c7cdd5;
  --text: #1c1e22;
  --text-muted: #5b5f66;
  --text-faint: #8a8e95;
  --accent: #4a9128;
  --accent-soft: rgba(74, 145, 40, .12);
  --team-none-accent: #4a9128;
  --owned: #1fa971;
  --owned-soft: rgba(31, 169, 113, .12);
  --shiny: #b9820a;
  --perfect: #b9820a;
  --custom: #6b6f77;
  --best-friend: #d63384;
  --danger: #d64540;
  color-scheme: light;
}

[data-team="blue"] {
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, .18);
}

[data-theme="light"][data-team="blue"] {
  --accent: #2f6fe0;
  --accent-soft: rgba(47, 111, 224, .12);
}

[data-team="red"] {
  --accent: #e2483a;
  --accent-soft: rgba(226, 72, 58, .18);
}

[data-theme="light"][data-team="red"] {
  --accent: #b8371f;
  --accent-soft: rgba(184, 55, 31, .12);
}

[data-team="yellow"] {
  --accent: #f5a623;
  --accent-soft: rgba(245, 166, 35, .18);
}

[data-theme="light"][data-team="yellow"] {
  --accent: #b97913;
  --accent-soft: rgba(185, 121, 19, .12);
}

body {
  font-family: system-ui, sans-serif;
  margin: 0 auto;
  min-height: 100vh;
  max-width: 480px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(62px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.app-header-back {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.app-header-back[hidden] {
  display: none;
}

.app-header-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header-theme-toggle {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 15px;
}

.app-header-theme-toggle .icon-sun,
.app-header-theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .app-header-theme-toggle .icon-sun {
  display: inline;
}

[data-theme="light"] .app-header-theme-toggle .icon-moon {
  display: inline;
}

.app-header-offline-toggle {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 15px;
}

.app-header-offline-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
}

.toast-container {
  position: fixed;
  /* Pleine largeur (et non left: 50% + translateX) : sinon la largeur disponible pour le
     contenu est plafonnée à la moitié de l'écran et le toast passe sur 2 lignes en mobile. */
  left: 0;
  right: 0;
  padding: 0 16px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast--offline {
  border-color: var(--danger);
}

.toast--online {
  border-color: var(--accent);
}

.toast--interactive {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: normal;
}

.toast--update {
  border-color: var(--accent);
}

.toast--success {
  border-color: var(--owned);
}

.toast-action {
  flex-shrink: 0;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 15;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  text-decoration: none;
}

.tab-bar-item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
}

.tab-bar-item .pi {
  font-size: 20px;
}

.tab-bar-item .tab-bar-svg {
  width: 20px;
  height: 20px;
}

.tab-bar-item[aria-current="page"] {
  color: var(--accent);
}

.tab-bar-dot {
  position: absolute;
  top: 2px;
  right: calc(50% - 15px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid var(--bg-elevated);
}

.tab-bar-dot[hidden] {
  display: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  flex: 0 0 auto;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.dex-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}

/* Toolbar épinglée : une fois la zone de filtres sortie de l'écran, l'onglet à chevron
   (.toolbar-pull) la fait redescendre, collée sous la barre génération/année (ou le header).
   --toolbar-pin-top est posé en JS (bas réel de la barre d'ancrage). */
.dex-toolbar.is-pinned {
  position: sticky;
  top: var(--toolbar-pin-top, 60px);
  z-index: 13;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 18px -12px rgba(0, 0, 0, .45);
  animation: toolbarDrop .22s cubic-bezier(.2, .8, .3, 1);
}

.dex-toolbar.is-pinned.is-closing {
  animation: toolbarLift .18s ease-in forwards;
}

@keyframes toolbarDrop {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toolbarLift {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-100%); opacity: 0; }
}

.toolbar-pull {
  position: fixed;
  top: var(--toolbar-pull-top, 60px);
  left: 50%;
  z-index: 13;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 18px;
  padding: 0;
  margin-left: -23px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  box-shadow: 0 6px 12px -8px rgba(0, 0, 0, .5);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .3, 1), top .22s cubic-bezier(.2, .8, .3, 1), color .15s ease;
}

/* Zone tactile plus large que l'onglet lui-même (44px de haut). */
.toolbar-pull::before {
  content: "";
  position: absolute;
  inset: -4px -12px -16px;
}

.toolbar-pull.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toolbar-pull:hover,
.toolbar-pull:focus-visible {
  color: var(--accent);
}

.toolbar-pull:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolbar-pull svg {
  transition: transform .22s ease;
}

.toolbar-pull[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* Rappel discret qu'un filtre est actif alors que la zone est repliée. */
.toolbar-pull-dot {
  position: absolute;
  top: 3px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .dex-toolbar.is-pinned,
  .dex-toolbar.is-pinned.is-closing { animation: none; }
  .toolbar-pull,
  .toolbar-pull svg { transition: none; }
}

.dex-picker {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.picker-zone[hidden] {
  display: none;
}

.picker-zone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin: 0 0 10px;
}

.picker-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 12px 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.picker-card[hidden] {
  display: none;
}

.picker-card:hover {
  border-color: var(--accent);
}

/* Progression globale de la liste (voir updatePickerProgress dans dex.js). */
.picker-card-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  margin-top: auto;
  padding-top: 2px;
}

.picker-card-progress-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.picker-card-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .3s ease;
}

.picker-card-progress--complete .picker-card-progress-fill {
  background: var(--perfect);
}

.picker-card-progress-count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.picker-card-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  image-rendering: pixelated;
}

.picker-card-media--crop {
  position: relative;
  overflow: hidden;
  width: 52px;
  height: 52px;
}

.picker-card-img--zoom-top {
  position: absolute;
  top: 0;
  left: 50%;
  width: 130%;
  height: 130%;
  transform: translateX(-50%);
  object-fit: cover;
  image-rendering: auto;
}

.picker-card-media {
  position: relative;
  display: inline-flex;
}

.picker-card-badge {
  position: absolute;
  right: -10px;
  top: -10px;
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5));
}

/* Listes 100% / 0% : pas d'icône dédiée dans ui/, pastille texte à la place. */
.picker-card-badge--iv {
  width: auto;
  height: auto;
  top: -6px;
  right: -14px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.picker-card-badge--iv100 {
  background: var(--perfect);
  color: #1a1400;
}

/* Bleu comme l'appréciation 0 % en jeu. */
.picker-card-badge--iv0 {
  background: #3d8fe0;
  color: #fff;
}

/* Home : pas d'icône dans ui/ non plus, même pastille texte (vert HOME). */
.picker-card-badge--home {
  background: #1fb87a;
  color: #fff;
}

.halo-shadow {
  filter: drop-shadow(0 0 5px rgba(155, 60, 220, .95)) drop-shadow(0 0 11px rgba(155, 60, 220, .65));
}

.halo-purified {
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, .95)) drop-shadow(0 0 11px rgba(255, 255, 255, .65));
}

.halo-dynamax {
  filter: drop-shadow(0 0 5px rgba(255, 90, 180, .95)) drop-shadow(0 0 11px rgba(255, 90, 180, .65));
}

.halo-chanceux {
  filter: drop-shadow(0 0 5px rgba(255, 200, 40, .95)) drop-shadow(0 0 11px rgba(255, 200, 40, .65));
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-row.wrap {
  flex-wrap: wrap;
  overflow-x: visible;
}

.region-nav {
  position: sticky;
  top: 60px;
  z-index: 14;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.region-chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.region-chip:hover {
  border-color: var(--accent);
}

.region-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.region-chip[hidden] {
  display: none;
}

.chip-radio {
  flex: 0 0 auto;
  position: relative;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chip-radio:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-radio:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dex-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  flex: 0 0 auto;
}

.segmented label {
  flex-direction: row;
  align-items: center;
  position: relative;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.variant-toggle .opt-normal:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.variant-toggle .opt-shiny:has(input:checked) {
  background: var(--shiny);
  color: #1a1400;
}

.gender-toggle .opt-principal:has(input:checked),
.gender-toggle .opt-principal-variants:has(input:checked),
.gender-toggle .opt-all:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.density-toggle .opt-comfortable:has(input:checked),
.density-toggle .opt-compact:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.icon-btn-square {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
}

.icon-btn-square:hover {
  border-color: var(--accent);
}

.filter-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.filter-dot[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  gap: 4px;
}

.field[hidden] {
  display: none;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay[hidden] {
  display: none;
}

.bottom-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp .2s ease;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 16px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 14px;
}

.sheet-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.sheet-row-label {
  font-size: 14px;
  font-weight: 600;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  background: var(--border-strong);
  cursor: pointer;
  padding: 0;
}

.toggle-switch.on {
  background: var(--accent);
}

.toggle-switch .toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: left .15s ease;
}

.toggle-switch.on .toggle-knob {
  left: 20px;
}

.toggle-switch.toggle-switch--sm {
  width: 38px;
  height: 22px;
}

.toggle-switch.toggle-switch--sm .toggle-knob {
  width: 18px;
  height: 18px;
}

.toggle-switch.toggle-switch--sm.on .toggle-knob {
  left: 18px;
}

.field-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-size: 14px;
  min-width: 150px;
  padding: 9px 34px 9px 12px;
  color: var(--text);
  background-color: var(--surface-alt);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a9ea6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

select:hover {
  border-color: var(--border-strong);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select:disabled {
  opacity: .45;
  cursor: not-allowed;
}

select option {
  background: var(--surface);
  color: var(--text);
}

.search-bar {
  display: flex;
  align-items: stretch;
  flex: 1 1 320px;
  min-width: 0;
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  padding: 9px 12px;
  color: var(--text);
  background: transparent;
  border: none;
}

.search-input:focus {
  outline: none;
}

.search-input::placeholder {
  color: var(--text-faint);
}

#count {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.offline-badge-text {
  display: inline;
}

.offline-badge.never {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.offline-badge.stale {
  background: rgba(230, 126, 34, .2);
  color: #e67e22;
}

.offline-badge.up-to-date {
  background: var(--owned-soft);
  color: var(--owned);
}

.btn {
  display: inline-block;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 83, 80, .15);
  border-color: var(--danger);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - 480px / 2 + 16px));
  bottom: calc(62px + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 16;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  text-decoration: none;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

.fab:hover {
  filter: brightness(1.1);
}

.btn-primary-full {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.btn-danger-outline {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger-outline[hidden] {
  display: none;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.sheet-actions .btn-primary-full {
  flex: 2;
}

.field-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.field-switch {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px !important;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.field-switch--sub {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  border-top: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}

.switch--sm {
  width: 38px;
  height: 22px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  pointer-events: none;
  transition: background-color .15s ease;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: left .15s ease;
}

.switch--sm .switch-knob {
  width: 18px;
  height: 18px;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-knob {
  left: 20px;
}

.switch--sm input:checked + .switch-track .switch-knob {
  left: 18px;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  min-width: 280px;
  max-width: 90vw;
  color: var(--text);
}

.modal-message {
  font-size: 14px;
  margin: 0 0 16px;
}

.prefs-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 260px;
}

.prefs-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.prefs-page {
  padding: 20px 16px 40px;
}

.prefs-page h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

.prefs-page .prefs-form {
  min-width: 0;
  margin-bottom: 24px;
}

.prefs-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.prefs-accordion {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--surface);
}

.prefs-accordion-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.prefs-accordion-summary::-webkit-details-marker {
  display: none;
}

.prefs-accordion-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.prefs-accordion-chevron {
  flex: 0 0 auto;
  color: var(--text-muted);
  transition: transform .15s ease;
}

.prefs-accordion[open] .prefs-accordion-chevron {
  transform: rotate(180deg);
}

.prefs-accordion-body {
  padding: 0 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prefs-accordion-subhead {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  margin: 8px 0 2px;
}

.prefs-accordion-subhead:first-child {
  margin-top: 0;
}

.prefs-help {
  margin-bottom: 16px;
  background: var(--surface-alt);
}

.prefs-help-list {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.prefs-help-list dt {
  font-weight: 600;
  margin-top: 10px;
}

.prefs-help-list dt:first-child {
  margin-top: 0;
}

.prefs-help-list dd {
  margin: 2px 0 0;
  color: var(--text-muted);
}

.prefs-help-list dd strong {
  color: var(--text);
  font-weight: 600;
}

.prefs-help-foot {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.data-page {
  padding: 20px 16px 40px;
}

.data-page h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

.data-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.data-section h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.data-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.data-section .field {
  margin-bottom: 12px;
}

.data-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.data-actions-split .btn {
  flex: 1;
}

.text-input {
  font-size: 14px;
  padding: 9px 12px;
  color: var(--text);
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.profile-page {
  padding: 20px 16px 40px;
}

.profile-banner {
  background: var(--bg-elevated);
}

.profile-banner .app-header {
  background: transparent;
  border-bottom: none;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 22px;
}

.team-picker {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

.team-option {
  position: relative;
  width: 64px;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
}

.team-option img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.team-option-swatch {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: var(--team-none-accent);
}

.team-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.team-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.team-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  box-sizing: border-box;
}

.profile-header .text-input {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text);
  width: 220px;
}

.stat-tiles {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.stat-tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-tile-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.stat-tile-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.profile-menu-item:hover {
  border-color: var(--accent);
}

.profile-menu-item .nav-icon {
  font-size: 18px;
  color: var(--accent);
}

.profile-menu-item .chevron-right {
  margin-left: auto;
  color: var(--text-muted);
}

.profile-offline-detail {
  font-size: 13px;
  color: var(--text-muted);
  padding: 10px 16px;
  margin-bottom: 22px;
}

.missing-result {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: monospace;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.region-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 112px;
}

.region-header:first-child {
  padding-top: 0;
  border-top: none;
}

.region-header-actions {
  display: inline-flex;
  gap: 6px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
}

.grid.grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 6px 3px 6px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  user-select: none;
}

.tile img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  image-rendering: pixelated;
}

/* Cadre du sprite : l'image y est agrandie sur sa zone visible (dex.js zoomSpriteOnContent),
   le débordement est rogné pour ne pas recouvrir le libellé. */
.tile-sprite {
  aspect-ratio: 1;
  overflow: hidden;
}

.tile-sprite img {
  image-rendering: auto;
}

.tile .label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-badges {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Surcharge .tile img (width:100%/aspect-ratio:1) qui s'applique sinon aussi à ce badge,
   car .timeline-item-cat-badge seul est moins spécifique que .tile img. */
.tile-badges img.timeline-item-cat-badge {
  width: 16px;
  height: 16px;
  aspect-ratio: auto;
}

.gender-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  line-height: 16px;
  font-weight: bold;
  color: #fff;
}

.gender-badge.male {
  background: #3498db;
}

.gender-badge.female {
  background: #e84393;
}

.placeholder-badge {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  line-height: 16px;
  font-weight: bold;
  color: #fff;
  background: #e67e22;
}

.shiny-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  line-height: 16px;
  font-weight: bold;
  color: #1a1400;
  background: var(--shiny);
}

/* Visuel récupéré depuis sprites_tmp/ (en attente du sprite officiel équivalent) — voir
   generer_manifest.php et le skill transfer-tmp-sprite. */
.temp-sprite-badge {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  line-height: 16px;
  font-weight: bold;
  color: #fff;
  background: #8e44ad;
}

.tile.owned {
  border-color: var(--owned);
  background: var(--owned-soft);
}

.tile--toggle.selected {
  border-color: var(--accent);
  background: var(--owned-soft);
}

.tile--toggle.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

.tile--unavailable {
  opacity: .5;
  cursor: default;
}

.tile--unavailable:hover {
  border-color: var(--border);
}

.tile--upcoming {
  opacity: .5;
  cursor: default;
}

.tile--upcoming:hover {
  border-color: var(--border);
}

.tile-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: none;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tile-badge--plain {
  background: var(--owned);
  color: #08210f;
}

.entry-sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.entry-sheet-img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  image-rendering: pixelated;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 4px;
}

.entry-sheet-title-wrap {
  flex: 1;
  min-width: 0;
}

.entry-sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.entry-sheet-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.iv-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.iv-slider-row span:first-child {
  font-size: 11px;
  color: var(--text-muted);
  width: 28px;
  flex: 0 0 auto;
}

.iv-slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.iv-slider-row span:last-child {
  font-size: 12px;
  width: 20px;
  text-align: right;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  select {
    font-size: 16px;
  }

  .search-input {
    font-size: 16px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1;
    min-width: 100px;
  }
}

/* --- Fond d'écran : liste de cartes dépliables, remplace la grille de tuiles pour cette
   catégorie (voir dex.js renderBackgroundList). --- */

#background-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.background-type-toggle .opt-lieu:has(input:checked),
.background-type-toggle .opt-special:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.background-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 16px;
}

.bg-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.bg-card-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.bg-card-summary::-webkit-details-marker {
  display: none;
}

.bg-card-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--surface-alt);
  cursor: pointer;
}

.bg-zoom-overlay {
  background: rgba(0, 0, 0, .85);
  padding: 20px;
}

.bg-zoom-img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  cursor: zoom-out;
}

.bg-card-info {
  flex: 1;
  min-width: 0;
}

.bg-card-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.bg-card-ratio {
  font-size: 11px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.bg-card-global-toggle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.bg-card-global-toggle.active {
  border-color: var(--owned);
  background: var(--owned) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center/14px no-repeat;
}

.bg-card.owned .bg-card-summary {
  background: var(--owned-soft);
}

.bg-card-chevron {
  flex: 0 0 auto;
  color: var(--text-muted);
  transition: transform .15s ease;
}

.bg-card-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 14px;
}

/* Modale des Pokémon d'un fond (#bg-sheet-overlay). */
.bg-sheet {
  max-width: 640px;
}

.bg-sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.bg-sheet-thumb {
  width: 64px;
  height: 64px;
  cursor: zoom-in;
}

.bg-sheet-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.bg-sheet-body {
  padding-bottom: 4px;
}

.bg-card-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  padding-top: 10px;
}

.bg-card-empty {
  padding: 12px 2px 2px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Fond d'écran, vue cartes (#background-view-toggle) : grille de cartes avec l'image en
   grand et la progression des Pokémon rattachés. --- */

/* Même hauteur que le bouton Filtres (.icon-btn-square, 36px) de la liste nationale. */
.background-view-toggle label {
  height: 28px;
  padding: 0 10px;
}

.background-view-toggle svg {
  display: block;
}

.bg-card-stats {
  display: none;
}

.background-cards--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-items: stretch;
}

.background-cards--grid .bg-card.owned {
  border-color: var(--owned);
}

.background-cards--grid .bg-card .bg-card-summary {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  height: 100%;
}

.background-cards--grid .bg-card .bg-card-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 0;
}

.background-cards--grid .bg-card .bg-card-info {
  padding: 8px 10px 0;
}

.background-cards--grid .bg-card .bg-card-name {
  font-size: 13px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.background-cards--grid .bg-card .bg-card-global-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  border-color: #fff;
  background-color: rgba(0, 0, 0, .35);
}

.background-cards--grid .bg-card .bg-card-global-toggle.active {
  border-color: var(--owned);
  background-color: var(--owned);
}

.background-cards--grid .bg-card .bg-card-ratio,
.background-cards--grid .bg-card .bg-card-chevron {
  display: none;
}

.background-cards--grid .bg-card .bg-card-stats {
  display: block;
  padding: 8px 10px 10px;
}

.bg-card-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.bg-card-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bg-card-progress--complete span {
  background: var(--perfect);
}

.bg-card-stats-label {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Page Sorties (timeline des dates de sortie en jeu) --- */

.timeline-page {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.timeline-toolbar .dex-filter-row {
  justify-content: flex-end;
}

.timeline-year-header {
  align-self: center;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 8px 28px;
  margin: 6px 0;
  scroll-margin-top: 112px;
}

.timeline-empty {
  padding: 24px 4px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.timeline-node {
  position: relative;
  padding-left: 20px;
  padding-bottom: 14px;
  border-left: 2px solid var(--border);
}

.timeline-node:last-child {
  border-left-color: transparent;
}

.timeline-node::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-node-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.timeline-node-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-node-date-row::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.timeline-node-date {
  font-weight: 600;
  font-size: 15px;
}

.timeline-node-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.timeline-node-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.timeline-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  text-align: center;
}

.timeline-item-media {
  position: relative;
  width: 44px;
  height: 44px;
}

.timeline-item-media > img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.timeline-item-badges {
  position: absolute;
  top: -2px;
  left: -2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-item-cat-badge {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
}

.timeline-item-label {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 64px;
}

.timeline-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.timeline-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding-top: 8px;
}

.timeline-modal-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.timeline-modal-variant {
  position: relative;
}

.timeline-modal-img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  image-rendering: pixelated;
  background: var(--surface-alt);
  border-radius: 16px;
  padding: 12px;
}

.timeline-modal-variant .gender-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  border: 2px solid var(--bg-elevated);
}

.timeline-modal-title {
  margin: 4px 0 0;
  font-size: 18px;
}

.timeline-modal-date {
  font-size: 13px;
  color: var(--text-muted);
}

.timeline-modal-shiny-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  font-size: 12px;
  line-height: 22px;
  border: 2px solid var(--bg-elevated);
}

.timeline-modal-cat-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
}

.timeline-node--upcoming {
  border-left-color: var(--accent);
}

.timeline-node--upcoming .timeline-node-date {
  color: var(--accent);
}

.timeline-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.timeline-divider::before,
.timeline-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Page Ma collection (liste + fiche de spécimen) --- */

.specimen-page {
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
}

.specimen-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-year-header.specimen-year-header {
  font-size: 20px;
  padding: 4px 22px;
  margin: 8px 0 2px;
}

.specimen-empty {
  padding: 24px 4px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.specimen-row,
.specimen-compact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.specimen-row:hover,
.specimen-compact-card:hover {
  border-color: var(--accent);
}

.specimen-row-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.specimen-row-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Contour selon l'IV, sur le conteneur (pas l'img) pour ne pas entrer en conflit avec les
   halos .halo-* (filter: drop-shadow) posés sur l'image elle-même. */
.specimen-row-thumb--iv-perfect {
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--shiny) inset;
}

.specimen-row-thumb--iv-zero {
  border-radius: 10px;
  box-shadow: 0 0 0 2px #3498db inset;
}

.specimen-row-thumb--iv-partial {
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--text-muted) inset;
}

.specimen-row-info {
  flex: 1;
  min-width: 0;
}

.specimen-row-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.specimen-row-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.specimen-form-page {
  padding: 16px 16px calc(90px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.specimen-visual-picker-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.specimen-visual-picker-trigger img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

.specimen-visual-picker-placeholder {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-alt);
}

.specimen-picker-species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
}

.specimen-picker-species-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
  text-align: center;
  cursor: pointer;
}

.specimen-picker-species-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.specimen-picker-back-btn {
  margin-bottom: 10px;
}

.specimen-picker-section {
  margin-bottom: 20px;
}

.specimen-picker-section:last-child {
  margin-bottom: 0;
}

.specimen-picker-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.specimen-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}

.specimen-gender-toggle {
  display: flex;
  gap: 10px;
}

.gender-pick-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.gender-pick-btn.selected {
  border-color: var(--accent);
  background: var(--owned-soft);
}

.gender-pick-btn .gender-badge {
  width: 22px;
  height: 22px;
  font-size: 12px;
  line-height: 22px;
}

.specimen-step-next {
  margin-top: 4px;
}

.specimen-save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(62px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.specimen-save-bar .btn-primary-full {
  flex: 1;
}

.chanceux-info-panel .data-section:last-child {
  margin-bottom: 0;
}

.chanceux-info-panel .species-grid {
  padding: 0;
}

.picker-empty {
  flex: 1;
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.picker-empty[hidden] {
  display: none;
}

.lists-sheet-body .sheet-section-label {
  margin-top: 14px;
}

.lists-sheet-body .sheet-section-label:first-child {
  margin-top: 0;
}

.lists-sheet-body .field-switch--sub {
  color: var(--text);
  font-size: 14px;
}

/* --- Feuille de filtres : réglages du contenu de la liste courante --- */

/* --- Listes personnelles : couleurs, cartes « Mes listes », onglets de parties --- */
.list-color-green { --list-color: #3fb950; }
.list-color-gold { --list-color: #e3b341; }
.list-color-pink { --list-color: #ef5da8; }
.list-color-violet { --list-color: #a371f7; }
.list-color-blue { --list-color: #58a6ff; }
.list-color-orange { --list-color: #f0883e; }
.list-color-red { --list-color: #f85149; }
.list-color-teal { --list-color: #2bb8c4; }

.picker-zone-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.picker-zone-head .picker-zone-title {
  margin: 0;
}

.picker-zone-link {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.picker-zone .picker-empty {
  margin: 0 0 10px;
}

.picker-card--custom {
  position: relative;
}

.picker-card-dot {
  position: absolute;
  top: 8px;
  left: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--list-color);
}

.picker-card-name {
  overflow-wrap: anywhere;
}

.picker-card--add {
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: var(--accent);
}

.picker-card--link {
  justify-content: center;
  text-decoration: none;
}

.picker-card-icon {
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
}

.picker-card-plus {
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.dex-part-row {
  margin-top: 8px;
}

.dex-part-row[hidden] {
  display: none;
}

.part-toggle {
  display: flex;
  width: 100%;
  min-width: 0;
}

/* Onglets répartis sur toute la largeur, resserrés sur petit écran pour que tous les
   libellés tiennent en entier sans défilement. */
.part-toggle label {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
  padding: 7px clamp(4px, 1.6vw, 14px);
  font-size: clamp(11px, 3.3vw, 13px);
  white-space: nowrap;
}

.collection-badge {
  font-size: 10px;
  line-height: 1;
  color: var(--accent);
}

.entry-sheet-list {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.bg-card--flat .bg-card-summary {
  cursor: pointer;
}

/* --- Créateur de liste --- */
.list-builder .builder-block {
  margin-bottom: 16px;
}

.list-builder .builder-block[hidden] {
  display: none;
}

.builder-templates {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.builder-template {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.builder-template img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.builder-template img.builder-template-bg {
  object-fit: cover;
  border-radius: 50%;
}

.builder-template.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.builder-seg {
  display: flex;
  width: 100%;
  margin-bottom: 10px;
}

.builder-seg label {
  flex: 1;
  justify-content: center;
  text-align: center;
  padding: 7px 8px;
  font-size: 12px;
}

.builder-seg .opt-shiny:has(input:checked) {
  background: var(--shiny);
  color: #1a1400;
}

.builder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.builder-chips[hidden],
.builder-fonds[hidden] {
  display: none;
}

.builder-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.builder-chip img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.chip-radio:has(input:disabled) {
  opacity: .35;
  cursor: not-allowed;
  text-decoration: line-through;
}

.builder-fonds {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder-fonds .builder-seg {
  margin-bottom: 0;
}

.builder-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.builder-detail-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.builder-detail-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.builder-detail-card b {
  color: var(--text);
  font-size: 12px;
}

.builder-detail-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.builder-detail-card:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.builder-detail-sprites {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 38px;
}

.builder-detail-sprites img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
}

.builder-detail-sprites small {
  margin: 0 2px 0 -6px;
  font-size: 10px;
  font-weight: 700;
}

.list-builder .text-input {
  width: 100%;
}

.builder-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 4px;
}

.builder-color {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--list-color);
  cursor: pointer;
}

.builder-color input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.builder-color:has(input:checked) {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.builder-color:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.builder-summary {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.builder-summary-text {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.builder-summary-count {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Feuille « À quoi sert cette page ? » de Ma collection. */
.collection-info-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 18px;
}

.collection-info-body p {
  margin: 0 0 10px;
}
