* { 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;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  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[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;
}

.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: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 84px;
  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);
}

.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));
}

.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;
}

.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(84px, 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(70px, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px 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;
}

.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.owned.tile--perfect {
  border-color: var(--perfect);
}

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

.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);
}

.best-friend-badge {
  width: 22px;
  height: 22px;
  background: url("ui/spr_pokemon_buddy_crown_badge_icon_small.png") center / 18px 18px no-repeat;
}

.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;
}

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

.tile-badge--custom {
  background: var(--custom);
  color: #fff;
}

.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;
}

.entry-iv-sliders {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.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[open] .bg-card-chevron {
  transform: rotate(180deg);
}

.bg-card-body {
  padding: 0 10px 14px;
  border-top: 1px solid var(--border);
}

.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);
}

/* --- 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;
}

.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;
}
