*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --text: #e8eaf6;
  --muted: #7b82b0;
  --giving: #ff6b35;
  --receiving: #00c8ff;
  --radius: 16px;
  --font: 'Google Sans Flex', 'Google Sans', 'Plus Jakarta Sans', 'Nunito', system-ui, sans-serif;

  /* move chip tokens */
  --move-fast-bg:       #1a2a3a;
  --move-fast-color:    #64b5f6;
  --move-fast-border:   #1e4466;
  --move-charged-bg:    #2a1a3a;
  --move-charged-color: #ce93d8;
  --move-charged-border:#4a1a66;
  /* lucky highlight */
  --lucky-color: #66bb6a;
  --lucky-bg:    #1b3a1e;
  --lucky-border:#2a4a2e;
}

[data-theme="light"] {
  --bg: #eef0f8;
  --surface: #ffffff;
  --surface2: #f0f2fa;
  --border: #d0d4e8;
  --text: #1a1d2e;
  --muted: #5a6080;
  --receiving: #0088bb;

  --move-fast-bg:       #dbeeff;
  --move-fast-color:    #1565c0;
  --move-fast-border:   #90caf9;
  --move-charged-bg:    #f3e5f5;
  --move-charged-color: #7b1fa2;
  --move-charged-border:#ce93d8;
  --lucky-color: #2e7d32;
  --lucky-bg:    #e8f5e9;
  --lucky-border:#a5d6a7;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* Mobile WebView polish: Android/Chrome paints a default blue tap highlight
   over buttons and labels unless it is explicitly disabled. Keep real
   keyboard focus rings via the existing :focus-visible rules below. */
html {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button,
a,
label,
[role="button"],
[role="tab"],
[role="option"],
.tl-row-clickable,
.boss-card,
.hist-entry {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button,
[role="button"],
[role="tab"],
[role="option"] {
  user-select: none;
}

button:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
[role="tab"]:focus:not(:focus-visible),
[role="option"]:focus:not(:focus-visible) {
  outline: none;
}

img,
svg {
  -webkit-user-drag: none;
}

@media (hover: none) and (pointer: coarse) {
  button,
  a,
  label,
  [role="button"],
  [role="tab"],
  [role="option"],
  .tl-row-clickable,
  .boss-card,
  .hist-entry {
    transition-duration: .12s;
  }

  .touch-pressed {
    filter: brightness(.96);
    opacity: .92;
    transform: scale(.985);
  }

  .bnav-btn.touch-pressed {
    transform: none;
  }

  .bnav-btn.touch-pressed::before {
    background: color-mix(in srgb, var(--md-primary-container, var(--surface2)) 72%, transparent);
  }

  body.keyboard-open .bottom-nav {
    transform: translateY(100%);
    pointer-events: none;
  }

  body.keyboard-open main {
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  body.keyboard-open .poke-modal-sheet,
  body.keyboard-open .settings-content,
  body.keyboard-open .record-content {
    max-height: calc(100vh - var(--keyboard-height, 0px) - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background .2s, border-color .2s;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.logo img { width: 44px; height: 44px; display: block; }
.header-inner > div:nth-child(2) { flex: 1; min-width: 0; }
h1 {
  font-size: 1.55rem; font-weight: 700; letter-spacing: -0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subtitle {
  color: var(--muted); font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 540px) {
  h1 { font-size: 1.2rem; letter-spacing: -0.3px; }
  .subtitle { font-size: 0.72rem; }
  .logo img { width: 36px; height: 36px; border-radius: 9px; }
}

.header-nav { display: flex; gap: 4px; flex-shrink: 0; }
.nav-link {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--surface2); color: var(--text); }

/* ── Main / Slides ─────────────────────────────────────── */
main { width: 100%; }

.slides-viewport { overflow-x: clip; width: 100%; }
.slides-track    { display: flex; }

.slide {
  display: none;
  flex: 0 0 100%;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}
.slide.active { display: block; }
.slide.anim-from-right { animation: slideFromRight .28s cubic-bezier(.4,0,.2,1) both; }
.slide.anim-from-left  { animation: slideFromLeft  .28s cubic-bezier(.4,0,.2,1) both; }

@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-36px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Section headers ───────────────────────────────────── */
.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.section-sub { color: var(--muted); font-size: 0.88rem; max-width: 640px; }

/* ── Selectors ─────────────────────────────────────────── */
.selectors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}
.selector-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
}
.panel-label {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 2px;
  margin-bottom: 14px; padding: 4px 10px; border-radius: 20px; display: inline-block;
}
.panel-label.giving   { background: rgba(255,107,53,.15); color: var(--giving); }
.panel-label.receiving{ background: rgba(0,200,255,.12);  color: var(--receiving); }

.panel-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-label-row .panel-label { margin-bottom: 0; }

.dex-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.dex-toggle-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.dex-toggle-track {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.dex-toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.dex-toggle-thumb {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background .2s;
}
.dex-toggle-thumb::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.dex-toggle-input:checked + .dex-toggle-thumb { background: var(--primary, #6366f1); }
.dex-toggle-input:checked + .dex-toggle-thumb::before { transform: translateX(16px); }

.search-wrap { position: relative; }
.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: #5c6bc0; }

.dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; list-style: none; z-index: 100;
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain; display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.dropdown.open { display: block; }
.dropdown li {
  padding: 10px 14px; cursor: pointer; display: flex; align-items: center;
  gap: 10px; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 0.88rem;
  transition: background .15s;
}
.dropdown li:last-child { border-bottom: none; }
.dropdown li:hover { background: rgba(255,255,255,.06); }
.tier-badge-sm {
  font-size: 0.65rem; font-weight: 800; padding: 2px 6px;
  border-radius: 4px; margin-left: auto; flex-shrink: 0;
}

/* ── Shiny toggle ──────────────────────────────────────── */
.toggle-row { display: flex; gap: 6px; margin: 8px 0 4px; justify-content: flex-start; flex-wrap: wrap; }

/* ── ETM custom SVG glyph — TM cartridge + sparkle ─────────────────────── */
.etm-svg {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
}
/* Legacy ETM SVG hooks — kept for backward compat with any cached HTML/CSS */
.toggle-chip-etm .etm-svg { width: 17px; height: 17px; }
.poke-mod-svg { width: 13px; height: 13px; }

/* ── Analysis comparison table (3 columns: label / giving / receiving) ────
   Replaces the old two-tile Giving/Receiving stat-card grid. Single panel,
   one row per stat, with the label column anchored on the left. */
.analysis-compare {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  /* extra breathing room from the orange info banner that sits above */
  margin-top: 14px;
}
.ac-grid {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr 1fr;
}
.ac-row { display: contents; }
.ac-row > * {
  padding: 9px 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  display: flex;
  align-items: center;
  min-width: 0;
}
.ac-row-head > * { border-top: none; padding: 8px 12px; }
.ac-headcell {
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  justify-content: center;
}
.ac-headcell.ac-giving    { color: var(--giving); }
.ac-headcell.ac-receiving { color: var(--receiving); }

.ac-rowlabel {
  background: color-mix(in srgb, var(--surface2) 50%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  gap: 6px;
}
.ac-rowicon { font-size: 1rem !important; color: var(--md-primary, #6366f1); }
.ac-cell { justify-content: center; text-align: center; gap: 5px; flex-wrap: wrap; }
.ac-empty { color: var(--muted); font-style: italic; }

.ac-name  { font-weight: 700; font-size: .92rem; color: var(--text); }
.ac-tier  { font-weight: 800; font-size: .92rem; }
.ac-rarity { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; }
.ac-rarity .material-symbols-rounded { font-size: 1.05rem; }
.ac-rarity-lbl { white-space: nowrap; }

.ac-value-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.ac-value {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ac-value-bar {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--border) 50%, transparent);
  overflow: hidden;
}
.ac-value-fill { display: block; height: 100%; border-radius: 4px; transition: width .3s; }

/* Softer dark-mode contrast — analysis panel blends slightly toward the page bg */
[data-theme="dark"] .analysis-compare,
.dark .analysis-compare {
  background: color-mix(in srgb, var(--surface) 80%, var(--bg) 20%);
  border-color: color-mix(in srgb, var(--border) 60%, transparent);
}
[data-theme="dark"] .ac-rowlabel,
.dark .ac-rowlabel {
  background: color-mix(in srgb, var(--surface2) 30%, transparent);
}

/* Trade-info-row (the orange "Caught Legendary/Shiny…" banner) → add gap below */
.trade-info-row { margin-bottom: 14px; }

@media (max-width: 640px) {
  /* On phones/small tablets the label column collapses to icon-only */
  .ac-grid { grid-template-columns: 44px 1fr 1fr; }
  .ac-row > * { padding: 8px 6px; }
  .ac-rowlabel { padding: 8px 4px; gap: 0; justify-content: center; }
  .ac-rowlabel span:not(.material-symbols-rounded) { display: none; }
  .ac-rowicon  { font-size: 1.1rem !important; }
  .ac-name, .ac-tier { font-size: .85rem; }
  .ac-rarity { font-size: .76rem; gap: 3px; }
  .ac-rarity-lbl { display: none; }
  .ac-value { font-size: 1rem; }
}

/* Compact icon-only toggle chips — same visual language as the move-stat icons
   in the modal moveset section. Each chip flips to its theme color when active. */
.toggle-chip {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  padding: 0;
}
.toggle-chip .material-symbols-rounded { font-size: 16px; }
.toggle-chip img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.5;
  transition: opacity .15s, transform .15s;
}
.toggle-chip:hover img { opacity: 1; }
.toggle-chip.active img { opacity: 1; transform: scale(1.05); }
.toggle-chip:hover { border-color: #5c6bc0; }
.toggle-chip.active {
  background: color-mix(in srgb, var(--toggle-accent, #6366f1) 14%, transparent);
  border-color: var(--toggle-accent, #6366f1);
}
.toggle-chip-shiny.active { --toggle-accent: #facc15; }
.toggle-chip-bg.active    { --toggle-accent: #10b981; }
.toggle-chip-etm.active   { --toggle-accent: #a855f7; }
.toggle-btn {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted); font-family: var(--font);
  font-size: 0.8rem; font-weight: 600; padding: 7px 10px;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.toggle-icon {
  width: 15px; height: 15px; object-fit: contain; flex-shrink: 0;
  opacity: 0.5; transition: opacity .15s;
}
.toggle-btn:hover .toggle-icon,
.toggle-btn.active .toggle-icon { opacity: 1; }
[data-theme="light"] .toggle-icon { filter: invert(1) brightness(0.4); }
.toggle-btn:hover { border-color: #5c6bc0; color: var(--text); }
.toggle-btn#giving-shiny.active,
.toggle-btn#receiving-shiny.active {
  background: rgba(255,215,0,.12); border-color: #ffd700; color: #ffd700;
}

/* ── Pokemon display card ──────────────────────────────── */
.pokemon-display {
  margin-top: 10px; min-height: 110px;
  display: flex; flex-direction: column; align-items: stretch;
  text-align: center;
  gap: 6px;
}
.placeholder-art {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--surface2); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--muted);
}
.placeholder-text { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }

.sprite-wrap { position: relative; display: inline-block; margin-bottom: 4px; }
.poke-sprite {
  width: 72px; height: 72px; image-rendering: pixelated;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.5));
  align-self: center; display: block;
}
.poke-tier-badge { align-self: center; display: inline-block; }
.poke-name { font-size: 1.05rem; font-weight: 700; }
/* Name + form badge + inline modifier icons — single tight row */
.poke-name-row {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap;
  margin-top: 4px; margin-bottom: 0;
}
/* Tier + rarity sit on one centered row, like the modal */
.poke-meta-row {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  margin: 2px 0;
}
.poke-types { display: inline-flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin: 0; }

/* Search dropdown — richer rows with sprite, name, types, tier */
.search-result-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  cursor: pointer;
}
.search-result-row:hover { background: var(--surface2); }
.sd-sprite-wrap { display: inline-flex; align-items: center; justify-content: center; }
.sd-sprite { width: 32px; height: 32px; image-rendering: pixelated; }
.sd-name { font-weight: 600; color: var(--text); font-size: .85rem; }
.sd-types { display: flex; gap: 3px; }
.sd-type {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0;
  overflow: hidden;
}
.sd-type .type-pill-name { display: none; }
.sd-type .type-pill-icon-wrap { width: 18px; height: 18px; }
.sd-type .type-pill-icon-wrap img.type-icon { width: 18px; height: 18px; }
.sd-tier-badge {
  font-size: .65rem; font-weight: 800; padding: 2px 7px;
  border-radius: 4px; letter-spacing: .04em;
}
.type-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: .8px;
  padding: 3px 9px 3px 4px; border-radius: 20px; text-transform: uppercase; color: #fff;
  position: relative;
}
.type-icon-img {
  width: 16px; height: 16px; object-fit: contain; flex-shrink: 0;
  display: block; image-rendering: -webkit-optimize-contrast;
}
.type-pill .type-icon-img { width: 18px; height: 18px; }
/* New wrapper for partywhale icons inside type-pill — sized for the small pill */
.type-pill-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.type-pill-icon-wrap img.type-icon { width: 16px; height: 16px; }
/* Legacy big tier badge kept for any non-trade callers; trade card uses .poke-tier-chip below */
.poke-tier-badge {
  font-size: 1.3rem; font-weight: 900; padding: 6px 18px;
  border-radius: 10px; margin: 6px 0; letter-spacing: 1px;
}
/* Compact tier chip — matches modal style, sits inline with types + rarity */
.poke-tier-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  font-size: .74rem;
  font-weight: 800;
  border-radius: 6px;
  border: 1px solid;
  letter-spacing: .02em;
}
.poke-rarity-ic {
  display: inline-flex;
  align-items: center;
  font-size: 1.05rem;
  line-height: 1;
}
.poke-notes  { font-size: 0.78rem; color: var(--muted); margin-top: 4px; font-style: italic; }

/* Inline modifier icons — small circles after the Pokémon name. */
.poke-mod-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--mod-accent, #6366f1) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--mod-accent, #6366f1) 38%, transparent);
  flex-shrink: 0;
}
.poke-mod-ic img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}
.poke-mod-ic-shiny { --mod-accent: #facc15; }
.poke-mod-ic-bg    { --mod-accent: #10b981; }
.poke-mod-ic-etm   { --mod-accent: #a855f7; }
.poke-mod-ic .material-symbols-rounded { font-size: 11px; }

/* ── Horizontal trade-card tile ─────────────────────────────────────────── */
/* Two-column body (left: name+sprite+rarity, right: stacked type pills),
   with a tier-colored "bottom cap" band underneath. Compact, info-card style. */
.poke-tile {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
}
.poke-tile-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  align-items: center;
}
.poke-tile-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.poke-tile-name-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}
.poke-tile-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.poke-tile-sprite img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.4));
  display: block;
}
.poke-tile-rarity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1;
}
.poke-tile-rarity .ms-icon-inline,
.poke-tile-rarity .material-symbols-rounded { font-size: 1.05rem; }

.poke-tile-types {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: stretch;
  justify-content: center;
  min-width: 92px;
}
.poke-tile-type {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 8px;
  width: 100%;
  font-size: .68rem;
  white-space: nowrap;
}

/* Bottom cap — tier-colored band echoing the role banner pattern */
.poke-tile-tier-cap {
  --tier-color: #888;
  --tier-bg: #888;
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--tier-bg) 18%, var(--surface));
  color: var(--tier-color);
  border-top: 1px solid color-mix(in srgb, var(--tier-bg) 40%, var(--border));
}

@media (max-width: 380px) {
  .poke-tile-types { min-width: 78px; }
  .poke-tile-sprite img { width: 64px; height: 64px; }
  .poke-tile-name { font-size: .94rem; }
}

/* ── VS divider ────────────────────────────────────────── */
.vs-divider {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; padding-top: 68px; width: 60px;
}
.vs-circle {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 900; color: var(--muted);
}

/* ── Analysis ──────────────────────────────────────────── */
.analysis { margin-top: 28px; animation: fadeUp .4s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.verdict-banner {
  border-radius: var(--radius); padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 18px; border: 1px solid;
}
.verdict-icon  { font-size: 2.2rem; flex-shrink: 0; }
.verdict-title { font-size: 1.35rem; font-weight: 800; }
.verdict-sub   { font-size: 0.88rem; margin-top: 2px; opacity: .85; }

.verdict-great { background: rgba(0,200,100,.1);   border-color: rgba(0,200,100,.3);   color: #00e676; }
.verdict-fair  { background: rgba(255,200,0,.08);  border-color: rgba(255,200,0,.25);  color: #ffd740; }
.verdict-bad   { background: rgba(255,70,70,.1);   border-color: rgba(255,70,70,.3);   color: #ff5252; }
.verdict-even  { background: rgba(120,130,255,.1); border-color: rgba(120,130,255,.3); color: #7c8dff; }

.comparison-grid {
  display: grid; grid-template-columns: 1fr 1px 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.compare-col { padding: 20px; }
.compare-divider { background: var(--border); }
.compare-col h4 {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 2px;
  margin-bottom: 14px; opacity: .6; text-transform: uppercase;
}
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 0.87rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--muted); }
.stat-value { font-weight: 600; }
.tier-bar-wrap { margin-top: 14px; }
.tier-bar-label { font-size: 0.73rem; color: var(--muted); margin-bottom: 6px; }
.tier-bar-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.tier-bar-fill  { height: 100%; border-radius: 4px; transition: width .6s ease; }

.tips-box {
  margin-top: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px;
}
.tips-box h4 {
  font-size: 0.78rem; font-weight: 700; margin-bottom: 10px;
  color: var(--muted); letter-spacing: 1px; text-transform: uppercase;
}
.tips-box ul { padding-left: 18px; }
.tips-box li { font-size: 0.86rem; margin-bottom: 6px; color: var(--text); }
.tips-box a  { color: var(--md-primary, #6366f1); text-decoration: none; font-weight: 600; }
[data-theme="light"] .tips-box li strong { color: #1f2937; }
[data-theme="light"] .tips-box .material-symbols-rounded { color: var(--md-primary, #6366f1); }
.tips-box a:hover { text-decoration: underline; }
.tip-link {
  background: none; border: none; color: #7c8dff; font-family: var(--font);
  font-size: inherit; cursor: pointer; padding: 0; text-decoration: underline;
}

/* ── IV Floors ─────────────────────────────────────────── */
.iv-table {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.iv-row {
  display: grid;
  grid-template-columns: 200px 140px 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .15s;
}
.iv-row:last-child { border-bottom: none; }
.iv-row:hover { background: rgba(255,255,255,.03); }
.iv-level-wrap { display: flex; align-items: center; gap: 10px; }
.iv-icon  { font-size: 1.2rem; flex-shrink: 0; }
.iv-level { font-weight: 600; font-size: 0.9rem; }
.iv-friend-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 112px;
}
.iv-friend-indicator .friend-heart {
  width: 18px;
  height: 18px;
  font-size: 13px;
}
.iv-lucky-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, #ffb300 18%, var(--surface-container));
  color: #f59e0b;
  font-size: 18px;
}
.iv-floor-badge {
  font-size: 1rem; font-weight: 800; padding: 5px 14px;
  border-radius: 8px; border: 1px solid; text-align: center;
  letter-spacing: 1px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.iv-desc { font-size: 0.82rem; color: var(--muted); }

.iv-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.iv-note-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; display: flex; gap: 14px; align-items: flex-start;
}
.iv-note-icon { font-size: 1.5rem; flex-shrink: 0; }
.iv-note-card strong { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.iv-note-card p { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

/* Compact distance / candy table inside the Catch Distance Bonus card */
.iv-distance-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.iv-distance-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.iv-distance-table th:nth-child(2),
.iv-distance-table th:nth-child(3),
.iv-distance-table td:nth-child(2),
.iv-distance-table td:nth-child(3) { text-align: center; }
.iv-distance-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(127,127,127,0.08);
  color: var(--text);
}
.iv-distance-table tr:last-child td { border-bottom: none; }
.iv-distance-table td:nth-child(2) { font-weight: 700; }
.iv-distance-table td:nth-child(3) { font-weight: 600; color: var(--md-primary, #6366f1); }

/* ── Tier List Filters ─────────────────────────────────── */
.tier-filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 20px; display: flex; flex-direction: column; gap: 14px;
}
.filter-row { display: flex; gap: 24px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-label {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 2px; color: var(--muted);
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; border-radius: 20px; font-size: 0.78rem;
  font-weight: 600; font-family: var(--font);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: #5c6bc0; color: var(--text); }
.chip.active { background: #3949ab; border-color: #5c6bc0; color: #fff; }

/* Type-icon chip variant — used by the Tier List type filter to match the Meta picker */
.chip.type-chip {
  --chip-color: #666;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px 4px 7px;
  background: color-mix(in srgb, var(--chip-color) 10%, var(--surface2));
  color: var(--chip-color);
  border-color: transparent;
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .04em;
}
/* Global rule for partywhale type icons — self-contained colored circles, no recoloring. */
img.type-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  flex-shrink: 0;
  -webkit-user-drag: none;
}

.chip.type-chip .type-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.chip.type-chip:hover {
  background: color-mix(in srgb, var(--chip-color) 22%, var(--surface2));
  color: var(--chip-color);
  border-color: transparent;
}
.chip.type-chip.active {
  background: var(--chip-color);
  color: #fff;
  border-color: var(--chip-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--chip-color) 30%, transparent);
}
.chip.type-chip .type-chip-icon img.type-icon { width: 16px; height: 16px; }

/* ── Tier List ─────────────────────────────────────────── */
.tl-group { margin-bottom: 20px; }
.tl-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; margin-bottom: 8px;
  border-bottom: 1px solid;
}
.tl-group-badge {
  font-size: 0.8rem; font-weight: 900; padding: 3px 10px; border-radius: 6px;
}
.tl-group-name  { font-weight: 700; font-size: 0.9rem; }
.tl-group-count { font-size: 0.75rem; color: var(--muted); margin-left: auto; }

.tl-rows {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.tl-row {
  display: grid;
  grid-template-columns: 48px minmax(130px,1.2fr) minmax(100px,1fr) minmax(90px,auto) 48px minmax(0,1.5fr);
  align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 0.85rem;
  transition: background .12s;
  content-visibility: auto;
  contain-intrinsic-size: 64px;
}
.tl-row:last-child { border-bottom: none; }
.tl-row:hover { background: rgba(255,255,255,.03); }

.tl-sprite-cell { display: flex; align-items: center; justify-content: center; }
.tl-sprite {
  width: 40px; height: 40px; image-rendering: pixelated;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}
.sprite-shadow-sm {
  filter: drop-shadow(0 0 8px rgba(126, 64, 255, .95)) brightness(.86) saturate(.72) hue-rotate(240deg);
}

.shadow-sprite-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: max-content;
  height: max-content;
  flex-shrink: 0;
}

.shadow-sprite-wrap.is-shadow::before,
.shadow-sprite-wrap.is-shadow::after {
  content: '';
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.shadow-sprite-wrap.is-shadow::before {
  background:
    radial-gradient(circle, rgba(156, 85, 255, .42) 0 34%, rgba(105, 44, 199, .18) 45%, transparent 72%);
  filter: blur(5px);
}

.shadow-sprite-wrap.is-shadow::after {
  inset: -5%;
  border: 1px solid rgba(171, 104, 255, .42);
  box-shadow: 0 0 12px rgba(130, 65, 255, .58), inset 0 0 14px rgba(88, 44, 168, .28);
  animation: shadowPulse 2.4s ease-in-out infinite;
}

.shadow-sprite-wrap > img {
  position: relative;
  z-index: 1;
}
/* Modal hero aura — tuned wider/softer for the larger 96px sprite + label below */
.pm-shadow-aura.is-shadow::before {
  inset: 10%;
  filter: blur(8px);
}
.pm-shadow-aura.is-shadow::after {
  inset: -8%;
}

@keyframes shadowPulse {
  0%, 100% { opacity: .55; transform: scale(.95); }
  50% { opacity: .95; transform: scale(1.05); }
}

.tl-name-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-name      { font-weight: 600; }
.inline-ms-icon,
.material-symbols-rounded.inline-ms-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  line-height: 1;
  vertical-align: -0.14em;
  font-variation-settings: 'FILL' 1, 'wght' 600;
}

.toggle-btn .material-symbols-rounded,
.settings-header .material-symbols-rounded,
.settings-hint .material-symbols-rounded,
.iv-note-icon .material-symbols-rounded,
.tr-icon .material-symbols-rounded,
.ai-icon .material-symbols-rounded,
.ai-cta-icon .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 600;
}

.settings-header h3,
.settings-hint {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tl-form-badge {
  font-size: 0.58rem; font-weight: 800; letter-spacing: 1px;
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.form-mega   { background: #e91e63; color: #fff; }
.form-primal { background: #ff6b35; color: #fff; }
.form-shadow { background: rgba(138,43,226,.3); color: #ce93d8; border: 1px solid rgba(138,43,226,.5); }
.tl-no-trade { font-size: 0.85rem; opacity: .6; }

.tl-types-cell { display: flex; gap: 4px; flex-wrap: wrap; }
.tl-type {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.62rem; font-weight: 700; padding: 2px 7px;
  border-radius: 20px; color: #fff; text-transform: uppercase; letter-spacing: .5px;
  position: relative;
}
.tl-rarity-cell { font-size: 0.78rem; white-space: nowrap; display: flex; align-items: center; justify-content: center; }
.tl-rarity-icon { display: inline-flex; align-items: center; font-size: 1.1rem; }
.tl-rarity-text { display: none; }

.tl-tier-badge {
  font-size: 0.75rem; font-weight: 900; padding: 4px 10px;
  border-radius: 6px; white-space: nowrap;
}
.tl-notes-cell { font-size: 0.75rem; color: var(--muted); }

.tl-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ── Footer ────────────────────────────────────────────── */
footer {
  text-align: center; padding: 20px 24px; color: var(--muted);
  font-size: 0.73rem; border-top: 1px solid var(--border);
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 12px 14px; }
  .logo  { font-size: 1.6rem; }
  h1     { font-size: 1.2rem; }
  .subtitle { display: none; }
  .header-nav { gap: 2px; }
  .nav-link { padding: 6px 10px; font-size: 0.78rem; }

  .selectors { grid-template-columns: 1fr; }
  .vs-divider { flex-direction: row; padding: 10px 0; width: auto; justify-content: center; }

  .verdict-banner { padding: 14px 16px; gap: 12px; }
  .verdict-icon   { font-size: 1.8rem; flex-shrink: 0; }
  .verdict-title  { font-size: 1.05rem; }

  .comparison-grid { grid-template-columns: 1fr; }
  .compare-divider { display: block; height: 1px; width: auto; }

  .iv-row { grid-template-columns: 1fr auto; }
  .iv-desc { display: none; }

  .tl-row { grid-template-columns: 40px 1fr auto auto; }
  .tl-rarity-cell, .tl-notes-cell { display: none; }
  .tl-types-cell { display: flex; gap: 3px; flex-wrap: nowrap; align-items: center; }

  .tl-sprite,
  .att-sprite,
  .boss-sprite,
  .boss-tile-sprite,
  .team-sprite,
  .pm-sprite,
  .hist-sprite {
    filter: none;
  }

  .sprite-shadow-sm {
    filter: brightness(.9) saturate(.82) hue-rotate(240deg);
  }

  .shadow-sprite-wrap.is-shadow::before {
    filter: blur(3px);
  }

  .shadow-sprite-wrap.is-shadow::after {
    animation: none;
    box-shadow: 0 0 8px rgba(130, 65, 255, .36);
  }

  .filter-row { flex-direction: column; gap: 14px; }
  .iv-notes { grid-template-columns: 1fr; }
}

@media (min-width: 641px) {
  .tl-rarity-text { display: inline; }
}

/* ── Trade Setup ─────────────────────────────────────────── */
.trade-setup {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.setup-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.setup-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.setup-select-wrap { position: relative; flex: 1; display: flex; flex-direction: column; }
.setup-select-wrap .setup-select { flex: 1; height: 100%; }
.setup-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: .8rem;
}
.setup-select {
  width: 100%;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  padding: 9px 32px 9px 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.setup-select:hover  { border-color: #555a80; }
.setup-select:focus  { outline: none; border-color: #7b82b0; }
.setup-select option { background: var(--surface); }

/* ── Trade Results (Stardust + Lucky) ────────────────────── */
.trade-results {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0;
}
.tr-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex: 1;
}
.tr-icon { font-size: 1.2rem; flex-shrink: 0; }
.tr-body { display: flex; flex-direction: column; gap: 2px; }
.tr-value {
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
}
.tr-value.free  { color: var(--lucky-color); }
.tr-value.lucky { color: var(--lucky-color); }
.tr-label {
  font-size: .72rem;
  color: var(--muted);
}
.tr-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Move chips ───────────────────────────────────────────── */
.poke-moves, .tl-moves {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0 0;
}
.move-chip {
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid transparent;
  /* Inline style from moveChipHtml() drives background/border/color when type is known.
     The fallback below applies when the move type is unrecognised. */
}
/* Fallback colours (no inline style) */
.move-chip.fast:not([style])    { background: var(--move-fast-bg);    color: var(--move-fast-color);    border-color: var(--move-fast-border); }
.move-chip.charged:not([style]) { background: var(--move-charged-bg); color: var(--move-charged-color); border-color: var(--move-charged-border); }

/* ── Tier row clickable ──────────────────────────────────── */
.tl-row-clickable { cursor: pointer; }
.tl-row-clickable:hover { background: var(--surface2); }

/* ── Pokémon Info Modal ──────────────────────────────────── */
/* ── Modal overlay base (B4 consolidation) ────────────────────────────────
   Shared overlay structure for ALL app modals: poke-modal, settings-modal,
   record-modal, mega-picker, app-dialog, app-alert. Variants (z-index,
   align-items, sheet size/animation) live in their own rules below. */
.poke-modal,
.settings-modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s;
}
.poke-modal.open,
.settings-modal.open {
  pointer-events: all;
  opacity: 1;
}
.poke-modal-backdrop,
.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

/* Variant: Pokémon info modal — slides from bottom on phones, centered on desktop. */
.poke-modal {
  z-index: 200;
  align-items: flex-end;
}
/* Sheet base (shared between poke-modal-sheet and settings-sheet). Variants
   below override max-width, padding, animation entry point. */
.poke-modal-sheet,
.settings-sheet {
  position: relative;
  background: var(--surface);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.poke-modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: hidden;            /* clips content to border-radius — no more scrollbar on the card edge */
  border-radius: 24px 24px 0 0;
  padding: 0;
  transform: translateY(40px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.poke-modal.open .poke-modal-sheet {
  transform: translateY(0);
}
@media (min-width: 560px) {
  .poke-modal { align-items: center; }
  .poke-modal-sheet { border-radius: 20px; max-height: 82vh; }
}

/* Inner scroll wrapper — isolated from the card's border-radius */
.poke-modal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
@media (max-width: 440px) {
  /* Tight outer padding on phones — every px of content width matters */
  .poke-modal-scroll { padding: 14px 6px 24px; }
}
.poke-modal-scroll::-webkit-scrollbar { width: 4px; }
.poke-modal-scroll::-webkit-scrollbar-track { background: transparent; }
.poke-modal-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.poke-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 10;                 /* always above the tier sash */
}
.poke-modal-close:hover { background: var(--border); color: var(--text); }

/* Pokémon modal close: move to top-LEFT so it doesn't clash with the tier sash on the right */
#poke-modal-close { right: auto; left: 16px; }

/* Hero */
#poke-modal-content { position: static; }

/* Tier ribbon sash — diagonal banner anchored to the sheet corner (not scrollable content).
   sheet overflow:hidden clips it cleanly to the card's border-radius. */
.pm-tier-sash {
  position: absolute;
  top: 0;
  right: 0;
  width: 110px;
  height: 110px;
  overflow: hidden;
  pointer-events: none;        /* sash and all children must never block clicks */
  z-index: 2;                  /* below close button (z-index:10), above content */
}
.pm-tier-sash * { pointer-events: none; }
.pm-tier-sash-label {
  position: absolute;
  top: 22px;
  right: -42px;
  width: 150px;
  padding: 7px 0;
  background: linear-gradient(135deg, var(--sash-from, #6366f1), var(--sash-to, #818cf8));
  color: #fff;
  text-align: center;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: .08em;
  transform: rotate(45deg);
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.pm-tier-sash-plus       { --sash-from: #ef4444; --sash-to: #f59e0b; }   /* S+ god tier */
.pm-tier-sash-S          { --sash-from: #ec4899; --sash-to: #f472b6; }   /* S top tier */
.pm-tier-sash-A          { --sash-from: #8b5cf6; --sash-to: #a78bfa; }   /* A very strong */
.pm-tier-sash-B          { --sash-from: #3b82f6; --sash-to: #60a5fa; }   /* B solid */
.pm-tier-sash-C          { --sash-from: #10b981; --sash-to: #34d399; }   /* C decent */
.pm-tier-sash-D          { --sash-from: #6b7280; --sash-to: #9ca3af; }   /* D below */
@media (max-width: 480px) {
  .pm-tier-sash { width: 88px; height: 88px; }
  .pm-tier-sash-label { top: 16px; right: -38px; width: 130px; font-size: .9rem; padding: 5px 0; }
}

/* Icon-only form badge — no text label, just the orb/mega glyph */
.form-type-badge.form-icon-only {
  padding: 4px;
  min-height: 32px;
  min-width: 32px;
  justify-content: center;
}
.form-type-badge.form-icon-only .form-type-img { width: 22px; height: 22px; }

.pm-hero { text-align: center; margin-bottom: 20px; }
.pm-sprites {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
}
.pm-sprite-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pm-sprite { width: 88px; height: 88px; object-fit: contain; image-rendering: pixelated; }
.pm-sprite-label { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pm-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pm-name { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.pm-types { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pm-badges-row { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Sections */
.pm-section {
  border-top: 1px solid var(--border);
  padding: 14px 0 8px;
  margin-top: 4px;
}
.pm-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Tier row */
.pm-tier-row { display: flex; align-items: center; gap: 12px; }
.pm-tier-badge {
  font-size: 1.6rem;
  font-weight: 900;
  padding: 4px 16px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pm-tier-desc { font-size: .85rem; color: var(--muted); line-height: 1.4; }

/* Raid Intel — symmetrical tile grid (mirrors the stat card row) */
.pm-intel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pm-intel-tile {
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  min-height: 72px;
}
.pm-intel-lbl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  margin-bottom: 2px;
}
.pm-intel-lbl .material-symbols-rounded { font-size: 0.85rem; }
.pm-intel-val {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.pm-intel-sub {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}
.pm-intel-shadow { color: #a855f7; }
.pm-weather-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
  padding: 3px;
}
[data-theme="light"] .pm-weather-icon {
  background: rgba(30, 41, 59, 0.85);
}

/* ── Events Calendar (Meta sub-tab) ────────────────────────────────────── */
.ev-status-banner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  color: var(--muted);
  padding: 6px 10px;
  background: color-mix(in srgb, #10b981 8%, transparent);
  border: 1px solid color-mix(in srgb, #10b981 24%, var(--border));
  border-radius: 999px;
  margin-bottom: 12px;
}
.ev-status-banner a { color: #10b981; text-decoration: none; font-weight: 600; }
.ev-status-banner a:hover { text-decoration: underline; }

.ev-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.ev-filter {
  --ev-color: var(--md-primary, #6366f1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 600;
  font-family: var(--font);
  transition: all .12s;
}
.ev-filter:hover { border-color: var(--ev-color); color: var(--ev-color); }
.ev-filter.active {
  background: color-mix(in srgb, var(--ev-color) 22%, transparent);
  border-color: var(--ev-color);
  color: var(--ev-color);
}
.ev-filter-count {
  background: color-mix(in srgb, var(--ev-color) 14%, var(--surface));
  color: var(--ev-color);
  font-size: .62rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.ev-filter.active .ev-filter-count { background: rgba(255,255,255,.25); color: #fff; }

.ev-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 560px) {
  .ev-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

.ev-card {
  --ev-color: var(--md-primary, #6366f1);
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ev-color);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.ev-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--ev-color) 20%, transparent);
  border-color: var(--ev-color);
}
.ev-card-img {
  flex-shrink: 0;
  width: 84px;
  background-size: cover;
  background-position: center;
  background-color: var(--surface2);
}
.ev-card-body {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ev-card-type {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ev-color);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.ev-card-name {
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ev-card-dates {
  font-size: .68rem;
  color: var(--muted);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.ev-state {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .03em;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
}
.ev-state-active   { color: #10b981; }
.ev-state-upcoming { color: var(--md-primary, #6366f1); }
.ev-state-past     { color: var(--muted); }
.ev-card-past { opacity: 0.7; }

.ev-loading, .ev-error {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ev-error { color: #ef4444; }

/* ── Catch Rate Calculator (How to Obtain section) ─────────────────────── */
.pm-catch-calc { margin-top: 10px; }
.pm-catch-summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--md-primary, #6366f1) 10%, transparent);
  color: var(--md-primary, #6366f1);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
  list-style: none;
  transition: background .15s;
}
.pm-catch-summary::-webkit-details-marker { display: none; }
.pm-catch-summary:hover { background: color-mix(in srgb, var(--md-primary, #6366f1) 18%, transparent); }
.pm-catch-calc[open] > .pm-catch-summary .inline-ms-icon { transform: rotate(45deg); }
.pm-catch-summary .inline-ms-icon { transition: transform .15s; }

/* Contextual note — appears for raid-boss rarities to explain Premier-only rule */
.pm-catch-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 10px;
  font-size: .78rem;
  line-height: 1.4;
  color: var(--text);
  background: color-mix(in srgb, #f59e0b 14%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 50%, var(--border));
  border-radius: 8px;
}
.pm-catch-note .inline-ms-icon {
  color: #f59e0b;
  font-size: 1.05rem !important;
  flex: 0 0 auto;
  margin-top: 1px;
}
.pm-catch-note strong { font-weight: 700; }

/* Inline icons embedded in the raid-rule text. Inline-block so they flow with
   the words and wrap naturally; line-height bumped so the slightly taller
   icons don't crowd adjacent lines. */
.pm-catch-note-text {
  line-height: 1.55;
}
.pm-catch-note-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -4px;     /* center on x-height — cleaner than text baseline */
  margin: 0 2px;
  object-fit: contain;
}

/* Screen-reader-only label utility (used to give the inline icons spoken text) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pm-catch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 10px;
}
@media (min-width: 560px) {
  .pm-catch-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pm-catch-control {
  background: var(--surface2);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.pm-catch-lbl {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.pm-catch-opts {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.pm-catch-opt {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Icon-style option button — used for Ball + Berry choices */
.pm-catch-opt-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pm-catch-opt-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .55;
  transition: opacity .12s, transform .12s;
}
.pm-catch-opt-icon:hover img { opacity: .9; transform: scale(1.06); }
.pm-catch-opt-icon.active {
  background: color-mix(in srgb, var(--md-primary, #6366f1) 18%, transparent);
  border-color: var(--md-primary, #6366f1);
}
.pm-catch-opt-icon.active img { opacity: 1; transform: scale(1.06); }
/* "None" berry — inline SVG instead of a Material Symbols glyph so it renders
   independent of font loading (the previous icon was invisible while/if the
   icon font was still loading or failed). Strokes use currentColor so the
   active/hover states just retune the color. */
.pm-catch-none-svg {
  width: 22px;
  height: 22px;
  color: var(--text);
  opacity: .8;
  transition: color .12s, opacity .12s, transform .12s;
}
.pm-catch-opt-none:hover .pm-catch-none-svg {
  opacity: 1;
  transform: scale(1.08);
}
.pm-catch-opt-none.active .pm-catch-none-svg {
  color: var(--md-primary, #6366f1);
  opacity: 1;
  transform: scale(1.08);
}

/* Type Catch Medal selector — one row per Pokémon type (so dual-type mons get
   two rows). Same visual language as Ball / Berry / Throw rows above. */
.pm-catch-medal-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.pm-catch-medal-row .pm-catch-lbl {
  /* Label is type-colored (inline `style` on the span) — slightly bolder so
     "Fire Medal" reads as a category header rather than dimmed muted text. */
  font-weight: 800;
  opacity: .92;
}
.pm-catch-medal-chip { width: 32px !important; height: 32px !important; }
.pm-catch-medal-chip img { opacity: .82; }
.pm-catch-medal-chip:hover img { opacity: 1; }
.pm-catch-medal-chip.active img { opacity: 1; }
/* When inactive, the "None" medal should look explicitly faded — it represents
   "no bonus" rather than a competing medal tier. */
.pm-catch-medal-chip[data-val="none"] img { opacity: .5; }
.pm-catch-medal-chip[data-val="none"]:hover img,
.pm-catch-medal-chip[data-val="none"].active img { opacity: .85; }

/* Master Ball footnote — sits below the result row, small reference for the
   one ball that doesn't take the standard catch-rate formula. */
.pm-catch-footnote {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  font-size: .76rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pm-catch-foot-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  object-fit: contain;
}
.pm-catch-foot-text { line-height: 1.4; }
.pm-catch-foot-text strong { color: var(--text); font-weight: 700; }

/* Source provenance — tells the user whether the base capture rate came from
   the live GAME_MASTER (authoritative for Shadow forms) or a rarity-bucket
   estimate (fallback for regular forms, since Niantic doesn't ship those). */
.pm-catch-source {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 8px;
  font-size: .68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pm-catch-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 4px;
  flex-shrink: 0;
}
.pm-catch-source-gm  { background: #22c55e26; color: #16a34a; border: 1px solid #22c55e44; }
.pm-catch-source-est { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.pm-catch-opt:hover { border-color: var(--md-primary, #6366f1); color: var(--text); }
.pm-catch-opt.active {
  background: var(--md-primary, #6366f1);
  color: #fff;
  border-color: var(--md-primary, #6366f1);
}

.pm-catch-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--md-primary, #6366f1) 10%, var(--surface2)),
    color-mix(in srgb, var(--md-primary, #6366f1) 4%, var(--surface2)));
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--md-primary, #6366f1) 24%, var(--border));
}
.pm-catch-pct {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--md-primary, #6366f1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pm-catch-hint {
  margin-top: 4px;
  font-size: .72rem;
  color: var(--muted);
  font-style: italic;
}

/* Shadow Strategy panel — appears only on shadow Pokémon */
.pm-shadow-section {
  background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(99,102,241,0.05));
  border: 1px solid rgba(168,85,247,0.25);
}
.pm-shadow-section .pm-section-title { color: #a855f7; }
[data-theme="light"] .pm-shadow-section { background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(99,102,241,0.06)); }

.pm-shadow-dps-compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 10px;
  margin: 10px 0 12px;
  position: relative;
}
.pm-shadow-dps-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pm-shadow-dps-lbl {
  font-size: .58rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.pm-shadow-dps-val { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.pm-shadow-dps-cell.is-shadow .pm-shadow-dps-val { color: #a855f7; }
.pm-shadow-dps-arrow { color: var(--muted); display: inline-flex; align-items: center; }
.pm-shadow-dps-arrow .inline-ms-icon { font-size: 1.2rem; }
.pm-shadow-dps-delta {
  grid-column: 1 / -1;
  text-align: center;
  font-size: .68rem; font-weight: 700; color: #a855f7;
  padding: 3px 0 0;
  border-top: 1px dashed rgba(168,85,247,0.3);
  margin-top: 6px;
}

.pm-shadow-details { margin-top: 4px; }
.pm-shadow-details > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, #a855f7 10%, transparent);
  color: #a855f7;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
  transition: background .15s;
}
.pm-shadow-details > summary::-webkit-details-marker { display: none; }
.pm-shadow-details > summary:hover { background: color-mix(in srgb, #a855f7 18%, transparent); }
.pm-shadow-details[open] > summary .inline-ms-icon { transform: rotate(180deg); }
.pm-shadow-details > summary .inline-ms-icon { transition: transform .15s; }
.pm-shadow-notes {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 8px;
  padding: 12px 0 4px;
  margin: 0;
}
.pm-shadow-notes li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .82rem;
  line-height: 1.4;
  color: var(--text);
}
.pm-shadow-note-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: currentColor;
  margin-top: 1px;
}
.pm-shadow-note-icon .inline-ms-icon {
  color: #fff; font-size: .95rem;
  filter: drop-shadow(0 0 0 currentColor);
}
.pm-shadow-notes strong { font-weight: 700; }
.pm-shadow-notes li span:last-child { flex: 1; }

.pm-intel-shadow-avail { color: #94a3b8; font-weight: 600; }
.pm-dps-shadow-tag { color: #a855f7; font-weight: 700; }

/* Moves */
.pm-moves-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-move { display: flex; flex-direction: column; gap: 4px; }
.pm-move-label { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.pm-move-arrow { color: var(--muted); font-size: 1.1rem; margin-top: 14px; }

/* Type Effectiveness */
/* Type matchups — Pokémon GO formula. Two grouped panels (weak / resist) with
   one row per distinct damage multiplier (+60%, −37.5%, −60.9%, …). No "Immune"
   category because PoGo doesn't have true immunity. */
.pm-te-grid { display: flex; flex-direction: column; gap: 10px; }

.pm-te-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.pm-te-group-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: .76rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  border-bottom: 1px solid var(--border);
}
.pm-te-group-icon .inline-ms-icon { font-size: 1.05rem; }

.pm-te-weak             { border-color: color-mix(in srgb, #ef4444 32%, var(--border)); }
.pm-te-weak   .pm-te-group-hdr {
  background: color-mix(in srgb, #ef4444 8%, var(--surface));
  color: #b91c1c;
}
[data-theme="light"] .pm-te-weak .pm-te-group-hdr { color: #991b1b; }
.dark .pm-te-weak .pm-te-group-hdr,
[data-theme="dark"] .pm-te-weak .pm-te-group-hdr { color: #fca5a5; }

.pm-te-resist           { border-color: color-mix(in srgb, #10b981 28%, var(--border)); }
.pm-te-resist .pm-te-group-hdr {
  background: color-mix(in srgb, #10b981 8%, var(--surface));
  color: #047857;
}
.dark .pm-te-resist .pm-te-group-hdr,
[data-theme="dark"] .pm-te-resist .pm-te-group-hdr { color: #6ee7b7; }

.pm-te-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.pm-te-row:first-of-type { border-top: none; }

.pm-te-pct {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.pm-te-pct.pct-weak   { background: #dc2626; }
.pm-te-pct.pct-resist { background: #059669; }
.dark .pm-te-pct.pct-weak,
[data-theme="dark"] .pm-te-pct.pct-weak   { background: #b91c1c; }
.dark .pm-te-pct.pct-resist,
[data-theme="dark"] .pm-te-pct.pct-resist { background: #047857; }

.pm-te-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }

@media (max-width: 440px) {
  .pm-te-row { grid-template-columns: 64px 1fr; gap: 8px; padding: 8px 10px; }
  .pm-te-pct { padding: 3px 6px; font-size: .72rem; }
}

/* Type match chips — inline SVG so no lazy-loading issues in modals */
.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px 2px 4px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  white-space: nowrap;
}
.tm-chip-icon {
  display: flex;
  align-items: center;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.tm-chip-icon img.type-icon { width: 13px; height: 13px; }

/* PokéGO stats */
.pm-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.pm-stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pm-stat-cp { grid-column: span 1; }
.pm-stats-note { font-size: .74rem; color: var(--muted); margin-bottom: 8px; font-style: italic; }
.pm-stat-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.pm-stat-val   { font-size: 1.1rem; font-weight: 900; color: var(--text); line-height: 1; }
.pm-stat-sub   { font-size: .55rem; font-weight: 600; color: var(--muted); letter-spacing: .05em; margin-top: 3px; opacity: .75; }
.pm-shiny-row  { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.pm-shiny-row-icon { color: #facc15; font-size: 1.05rem; margin-right: 2px; }
.pm-shiny-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: help;
  transition: background .15s, border-color .15s;
}
.pm-shiny-badge:hover { border-color: #facc15; background: color-mix(in srgb, #facc15 12%, var(--surface2)); }
.pm-shiny-badge .inline-ms-icon { font-size: .95rem; }

/* Obtain */
.pm-obtain-text {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}
.pm-obtain-text .inline-ms-icon {
  vertical-align: -3px;
  margin-right: 4px;
}
.pm-obtain-text strong { color: var(--text); }

/* Primary moveset — two-column grid with column headers (replaces arrow layout) */
.pm-moves-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-moves-grid-header,
.pm-moves-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}
.pm-moves-grid-header {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 0 4px;
}
/* Move stat sub-line (power · energy · duration) shown under each move chip */
.pm-move-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  font-size: .68rem;
  color: var(--muted);
  line-height: 1.2;
}
.pm-move-stats { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; margin-top: 6px; font-size: .72rem; }
.pm-move-stat { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.pm-move-stat-val { font-weight: 700; color: var(--text); font-size: .74rem; }
.pm-move-stat-lbl { font-size: .58rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.pm-move-stat-sep { color: var(--border); font-weight: 700; }
.pm-move-stat-icon { font-size: .95rem; color: var(--muted); }
.pm-move-stat[title*="Damage"] .pm-move-stat-icon { color: #f97316; }
.pm-move-stat[title*="Energy"] .pm-move-stat-icon { color: #facc15; }
.pm-move-stat[title*="duration"] .pm-move-stat-icon { color: #94a3b8; }

.pm-moves-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
/* Top row inside the cell holds the chip + ETM/event badges side-by-side */
.pm-moves-cell > .move-chip,
.pm-moves-cell > .move-chip-wrap,
.pm-moves-cell > .pm-move-tag { align-self: flex-start; }

/* ETM corner badge on the move pill (replaces the "ELITE" text tag) */
.move-chip { position: relative; }
/* ETM corner sticker — wraps the chip so the badge sits outside the chip's bounds */
.move-chip-wrap {
  position: relative;
  display: inline-block;
}
.move-chip-etm {
  position: absolute;
  top: -7px;
  right: -10px;
  font-size: .54rem;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 2px 5px;
  border-radius: 4px;
  background: #8b5cf6;
  color: #fff;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  z-index: 2;
}
.dark .move-chip-etm { background: rgba(167, 139, 250, .95); }

/* Event/signature-move corner star — same pattern as ETM, but orange + ★ glyph */
.move-chip-event {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  line-height: 1;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  box-shadow: 0 1px 3px rgba(245, 158, 11, .5);
  font-weight: 700;
  z-index: 2;
}
.dark .move-chip-event { background: rgba(251, 191, 36, .95); color: #1f1500; }
/* When both ETM and Event are present, nudge the event badge so they don't overlap */
.move-chip-wrap .move-chip-etm + .move-chip-event { right: -4px; top: 14px; }

/* DPS score line below the moveset chips */
.pm-dps-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--card-bg, rgba(0,0,0,.04));
  border: 1px solid var(--border);
  border-radius: 8px;
}
.dark .pm-dps-line { background: rgba(255,255,255,.05); }
.pm-dps-score {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.pm-dps-unit {
  font-size: .65rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .05em;
}
.pm-dps-note {
  font-size: .7rem;
  color: var(--muted);
  font-style: italic;
}

/* Defender-type picker block */
.pm-def-picker-block {
  margin-top: 10px;
}
.pm-def-picker-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.pm-def-reset {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 4px;
  display: inline-flex;
  align-items: center;
  font-size: .75rem;
  line-height: 1;
}
.pm-def-reset:hover { color: var(--text); border-color: var(--text); }
.pm-def-picker {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}
@media (max-width: 720px) {
  .pm-def-picker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
  .pm-def-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pm-def-pill { padding: 6px 2px; }
  .pm-def-pill-label { font-size: .55rem; }
}
.pm-def-pill {
  min-width: 0;
  overflow: hidden;
  --def-color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  border: 1.5px solid transparent;
  border-radius: 6px;
  background: color-mix(in srgb, var(--def-color) 12%, transparent);
  cursor: pointer;
  transition: all .12s ease;
  font-size: .55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--def-color);
  min-height: 38px;
}
.pm-def-pill:hover {
  background: color-mix(in srgb, var(--def-color) 22%, transparent);
}
.pm-def-pill.is-active {
  background: var(--def-color);
  color: #fff;
  border-color: var(--def-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--def-color) 30%, transparent);
}
.pm-def-pill-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
}
.pm-def-pill-icon img.type-icon { width: 14px; height: 14px; }
.pm-def-pill-label { line-height: 1; }

/* Elite TM / Event move tags */
.pm-move-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}
.pm-move-tag .inline-ms-icon { font-size: .85rem; }
.tag-elite { background: rgba(139, 92, 246, .15); color: #8b5cf6; }
.tag-event { background: rgba(245, 158, 11, .15); color: #d97706; }
.dark .tag-elite { background: rgba(139, 92, 246, .25); color: #c4b5fd; }
.dark .tag-event { background: rgba(245, 158, 11, .25); color: #fbbf24; }

/* Alternative movesets expander */
.pm-alt-details { margin-top: 12px; }
.pm-alt-summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 4px;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}
.pm-alt-summary::-webkit-details-marker { display: none; }
.pm-alt-summary:hover { color: var(--text); }
.pm-alt-details[open] .pm-alt-summary .inline-ms-icon { transform: rotate(180deg); }
.pm-alt-summary .inline-ms-icon { transition: transform .15s ease; }

.pm-alt-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.pm-alt-row {
  display: grid;
  grid-template-columns: 1.35fr 1.35fr minmax(0, 1fr) 28px;
  align-items: center;
  gap: 4px;
  padding: 5px 4px;
  border-radius: 6px;
  background: var(--card-bg, rgba(0,0,0,.03));
}
.dark .pm-alt-row { background: rgba(255,255,255,.04); }
.pm-alt-header {
  background: transparent !important;
  padding: 4px 8px 2px;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.pm-alt-cell {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
  gap: 4px;
}
.pm-alt-role { justify-content: center; }
.pm-alt-chip { font-size: .68rem; padding: 2px 5px; }
.pm-alt-chip.has-etm { padding-right: 26px; }
.pm-alt-chip .move-chip-etm { font-size: .5rem; padding: 1px 3px; top: -5px; right: -7px; }
.pm-alt-chip.has-etm { padding-right: 6px; } /* counter old rule */
@media (max-width: 440px) {
  .pm-alt-chip { font-size: .62rem; padding: 2px 4px; }
  .pm-alt-row { grid-template-columns: 1.4fr 1.4fr minmax(0, 0.9fr) 24px; gap: 3px; padding: 5px 2px; }
  .pm-alt-role-icon { width: 22px; height: 22px; }
  .pm-alt-role-icon img.type-icon { width: 14px; height: 14px; }
  .pm-alt-dps { font-size: .72rem; gap: 2px; }
  .pm-alt-pct { font-size: .56rem; }
}
.pm-alt-dps { font-weight: 700; color: var(--text); font-size: .76rem; gap: 4px; white-space: nowrap; }
.pm-alt-pct { color: var(--muted); font-size: .62rem; font-weight: 500; }
.pm-alt-role-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.pm-alt-role-icon img.type-icon { width: 16px; height: 16px; }

/* Section title row — legacy wrapper kept for backwards compatibility with any
   non-moveset sections that still pair a title with a side widget. */
.pm-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.pm-section-title-row .pm-section-title { margin-bottom: 0; }
/* Type-colored role banner — sits between the section title and the moves grid.
   The icon + crossed-swords stack reinforces the "attacker" semantic; the
   full-width tinted band reads as a clear identity label for the moveset. */
.pm-role-banner {
  --role-color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  margin: 4px 0 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--role-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--role-color) 32%, var(--border));
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--role-color);
  white-space: nowrap;
}
.pm-role-banner-label {
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 color-mix(in srgb, var(--role-color) 8%, transparent);
}

.pm-role-icon-stack {
  position: relative;
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
.pm-role-icon-stack img.type-icon { width: 26px; height: 26px; }
.pm-role-sword {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--surface2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 11px;
}
.pm-role-sword .material-symbols-rounded { font-size: 10px; line-height: 1; }
.pm-role-badge-icon img.type-icon { width: 14px; height: 14px; }

/* Mega Energy obtain cards */
.pm-mega-obtain { display: flex; flex-direction: column; gap: 12px; }
.pm-mega-obtain-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pm-mega-energy-card {
  display: grid;
  grid-template-areas:
    "icon label"
    "icon val"
    "icon unit";
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 0 8px;
  background: var(--card-bg, rgba(0,0,0,.04));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.dark .pm-mega-energy-card { background: rgba(255,255,255,.05); }
.pm-mega-energy-icon {
  grid-area: icon;
  font-size: 1.4rem;
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}
.pm-mega-energy-label {
  grid-area: label;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
}
.pm-mega-energy-val {
  grid-area: val;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.pm-mega-energy-unit {
  grid-area: unit;
  font-size: .72rem;
  color: var(--muted);
  line-height: 1;
}
.pm-mega-obtain-note {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.pm-mega-obtain-note strong { color: var(--text); }

/* Trade cost table */
.pm-trade-badge {
  font-size: .84rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.pm-trade-badge.no-trade  { background: rgba(255,70,70,.1); color: #ff5252; border: 1px solid rgba(255,70,70,.25); }
[data-theme="light"] .pm-trade-badge.no-trade { background: rgba(200,0,0,.06); color: #b71c1c; border-color: rgba(200,0,0,.2); }
.pm-cost-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: .82rem;
}
.pm-cost-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(127, 127, 127, .08);
  align-items: center;
  gap: 8px;
}
.pm-cost-row:last-child { border-bottom: none; }
/* Right-align cost columns in BOTH header and body so the column headers line up
   with their values. Previously headers were left-aligned vs right-aligned values. */
.pm-cost-row > :nth-child(2),
.pm-cost-row > :nth-child(3) {
  text-align: right;
}
.pm-cost-hdr {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.pm-cost-friend { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.pm-cost-hearts { flex-shrink: 0; display: inline-flex; gap: 2px; }
.pm-cost-hearts .friend-heart { width: 16px; height: 16px; font-size: 11px; }
.pm-cost-friend-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 440px) {
  .pm-cost-row { grid-template-columns: auto 1fr 1fr; padding: 9px 10px; gap: 10px; }
  .pm-cost-friend-lbl { display: none; }
}
.pm-cost-hi { font-weight: 700; color: var(--text); }
.pm-cost-lo { color: var(--muted); font-weight: 500; }

/* Notes */
.pm-notes { font-size: .88rem; color: var(--muted); line-height: 1.5; }

/* ── Theme Toggle ────────────────────────────────────────── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, transform .15s;
  margin-left: 4px;
}
.theme-toggle:hover { background: var(--border); transform: scale(1.08); }

/* ── Light mode surface / component overrides ────────────── */
[data-theme="light"] footer              { background: var(--surface); border-top: 1px solid var(--border); }
[data-theme="light"] .selector-card      { background: var(--surface); }
[data-theme="light"] .tl-row:hover       { background: var(--surface2); }
[data-theme="light"] .chip               { color: var(--muted); }
[data-theme="light"] .chip.active        {
  background: var(--md-primary-container);
  border-color: color-mix(in srgb, var(--md-primary) 54%, transparent);
  color: var(--md-on-primary-container);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-primary) 18%, transparent);
}
[data-theme="light"] .dropdown           { background: var(--surface); border-color: var(--border); }
[data-theme="light"] .dropdown li:hover  { background: var(--surface2); }

/* Verdict banners — higher contrast text for light mode */
[data-theme="light"] .verdict-great { background: rgba(0,150,60,.08);   border-color: rgba(0,150,60,.3);   color: #1b5e20; }
[data-theme="light"] .verdict-fair  { background: rgba(200,100,0,.08);  border-color: rgba(200,100,0,.3);  color: #bf360c; }
[data-theme="light"] .verdict-bad   { background: rgba(200,0,0,.08);    border-color: rgba(200,0,0,.25);   color: #b71c1c; }
[data-theme="light"] .verdict-even  { background: rgba(50,60,220,.08);  border-color: rgba(50,60,220,.25); color: #1a237e; }

/* Smooth theme transition */
body, header, .selector-card, .analysis, .trade-setup,
.trade-results, .comparison-grid, .tips-box, .compare-col,
.tl-row, .tl-group, .tl-group-header, .iv-row, .iv-note-card,
.setup-select, .tier-bar-track, .dropdown, .chip {
  transition: background .2s, border-color .2s, color .2s;
}

@media (max-width: 640px) {
  .trade-setup { flex-direction: column; gap: 8px; }
  .tr-stat { padding: 10px 12px; }
}

/* ── Settings Button ────────────────────────────────────── */
.ai-settings-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, transform .15s;
  margin-left: 0;
}
.ai-settings-btn:hover { background: var(--border); transform: scale(1.08); }

/* ── Settings Modal ─────────────────────────────────────── */
/* Variant: settings/record/mega-picker/app-dialog — always centered, above
   .poke-modal so a confirm can sit on top of an open settings sheet. Base
   overlay + backdrop properties are shared above; only the variant-specific
   bits live here. */
.settings-modal {
  z-index: 300;
  align-items: center;
}
.settings-sheet {
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  transform: translateY(20px) scale(.97);
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.settings-modal.open .settings-sheet { transform: translateY(0) scale(1); }
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.settings-header h3 { font-size: 1.05rem; font-weight: 700; }
.settings-body { display: flex; flex-direction: column; gap: 10px; }
.settings-hint {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.55;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.settings-actions { display: flex; gap: 8px; margin-top: 4px; }
.settings-save {
  flex: 1;
  padding: 10px 16px;
  background: #3949ab;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.settings-save:hover { background: #5c6bc0; }
.settings-cancel {
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.settings-cancel:hover { background: var(--border); color: var(--text); }

/* ── AI Analysis Card ───────────────────────────────────── */
.ai-analysis-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* CTA card — shown before analysis is triggered */
.ai-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.ai-cta-icon  { font-size: 1.8rem; flex-shrink: 0; }
.ai-cta-body  { flex: 1; min-width: 0; }
.ai-cta-title { font-weight: 700; font-size: .9rem; margin-bottom: 3px; }
.ai-cta-sub   { font-size: .8rem; color: var(--muted); line-height: 1.5; }

.ai-analyze-btn {
  padding: 9px 18px;
  background: #3949ab;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, transform .12s;
}
.ai-analyze-btn:hover  { background: #5c6bc0; transform: translateY(-1px); }
.ai-analyze-btn:active { transform: translateY(0); }

/* Shimmer animation */
.ai-shimmer {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: ai-shimmer 1.4s infinite;
  border-radius: 6px;
  display: block;
}
@keyframes ai-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Result */
.ai-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}
.ai-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.ai-icon { font-size: 1.2rem; color: var(--primary, #6366f1); }
.ai-label { font-weight: 700; font-size: 0.95rem; flex: 1; }
.ai-model-chip {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 20px;
}
.ai-refresh-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.ai-refresh-btn:hover { background: var(--surface2); color: var(--text); }
.ai-refresh-btn .material-symbols-rounded { font-size: 0.95rem; }
.ai-sections { display: flex; flex-direction: column; gap: 10px; }
.ai-section {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 14px;
}
.ai-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ai-section-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary, #6366f1);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-section-icon { font-size: 1rem; color: var(--muted); }
.ai-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text);
}
.ai-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-point {
  font-size: 0.83rem;
  color: var(--text-secondary, var(--muted));
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}
.ai-point::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--primary, #6366f1);
  font-weight: 700;
}
.ai-text {
  font-size: .88rem;
  line-height: 1.68;
  color: var(--text);
}
.ai-cache-note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Error */
.ai-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 20px;
  font-size: .84rem;
  color: #ff5252;
  background: rgba(255,70,70,.06);
  line-height: 1.5;
}
[data-theme="light"] .ai-error { color: #b71c1c; background: rgba(200,0,0,.05); }

/* ══════════════════════════════════════════════════
   META HUB
══════════════════════════════════════════════════ */

/* Inner section tabs */
.meta-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  margin-bottom: 22px;
}
/* On phones the 4 sub-tabs swap their long label for the short alias (data-short)
   so all four stay visible without horizontal scroll. */
@media (max-width: 720px) {
  .meta-tab { padding: 8px 6px; font-size: .7rem; gap: 4px; }
  .meta-tab .material-symbols-rounded { font-size: 1.05rem; }
  /* Hide the long label text; render the short alias via generated content */
  .meta-tab .meta-tab-label { font-size: 0; }
  .meta-tab .meta-tab-label::before {
    content: attr(data-short);
    font-size: .7rem;
    white-space: nowrap;
  }
}
@media (max-width: 440px) {
  .meta-tab { padding: 7px 3px; gap: 3px; }
  .meta-tab .meta-tab-label::before { font-size: .62rem; }
  .meta-tab .material-symbols-rounded { font-size: .95rem; }
}
.meta-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 14px;
  border-radius: 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.meta-tab:hover  { background: var(--surface2); color: var(--text); }
.meta-tab.active { background: #3949ab; color: #fff; }

/* Shared panel utilities */
.meta-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.meta-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--muted);
  font-size: .88rem;
}
.meta-spin {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: #5c6bc0;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── By Type — Live Counters ─────────────────────────────────── */
/* Status banner at the top of the panel */
.lc-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.lc-banner.live     { background: rgba(34, 197, 94, .12); color: #16a34a; border-color: rgba(34, 197, 94, .3); }
.lc-banner.fallback { background: rgba(245, 158, 11, .12); color: #d97706; border-color: rgba(245, 158, 11, .3); }
.lc-banner.muted    { background: var(--surface2); color: var(--muted); }
.dark .lc-banner.live     { color: #4ade80; }
.dark .lc-banner.fallback { color: #fbbf24; }
.lc-banner > span { flex: 1; }
.lc-refresh {
  background: none;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .85;
}
.lc-refresh:hover { opacity: 1; }

/* Urgency styling on type pills */
.type-att-pill.urgent {
  box-shadow: 0 0 0 1px rgba(239, 68, 68, .4), 0 1px 4px rgba(239, 68, 68, .15);
}
.type-att-pill.dim { opacity: .45; }
.type-att-pill.dim:hover { opacity: 1; }
.lc-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 9px;
  background: rgba(239, 68, 68, .9);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  line-height: 1;
}
.type-att-pill.active .lc-pill-count {
  background: rgba(255, 255, 255, .3);
}

/* Active-boss strip shown when a type is selected */
.lc-boss-strip {
  margin: 10px 0 14px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.lc-boss-strip-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lc-boss-strip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lc-boss-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .75rem;
  cursor: pointer;
  transition: transform .1s ease;
}
.lc-boss-chip:hover { transform: translateY(-1px); border-color: var(--text); }
.lc-boss-chip img { width: 26px; height: 26px; }
.lc-boss-chip-name { font-weight: 600; }
.lc-boss-chip-tier {
  font-size: .58rem;
  font-weight: 800;
  background: rgba(139, 92, 246, .2);
  color: #8b5cf6;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: .03em;
}
.dark .lc-boss-chip-tier { background: rgba(167, 139, 250, .25); color: #c4b5fd; }
.lc-boss-chip-se {
  font-size: .6rem;
  font-weight: 800;
  color: #ef4444;
  background: rgba(239, 68, 68, .12);
  padding: 2px 5px;
  border-radius: 4px;
}

/* Per-attacker DPS badge + counter line */
.att-dps-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(34, 197, 94, .15);
  color: #16a34a;
  font-size: .65rem;
  font-weight: 800;
  border-radius: 4px;
  letter-spacing: .03em;
  vertical-align: middle;
}
.dark .att-dps-badge { color: #4ade80; }
.att-counters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: .68rem;
}
.att-counters-label {
  color: var(--muted);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.att-counter-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
/* Mark shadow variants so users can tell them apart when a shadow + regular
   of the same species are both active raid bosses at the same time. */
.att-counter-chip.is-shadow {
  background: color-mix(in srgb, #a855f7 16%, var(--surface2));
  border-color: color-mix(in srgb, #a855f7 45%, var(--border));
}
.att-counter-shadow-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a855f7;
}
.att-counter-shadow-tag .inline-ms-icon { font-size: .9rem; }
/* Same treatment for the active-bosses strip chip */
.lc-boss-chip.is-shadow {
  background: color-mix(in srgb, #a855f7 12%, var(--surface));
  border-color: color-mix(in srgb, #a855f7 40%, var(--border));
}
.lc-boss-shadow-tag {
  display: inline-flex;
  align-items: center;
  color: #a855f7;
}
.lc-boss-shadow-tag .inline-ms-icon { font-size: .95rem; }
.att-counter-dps {
  font-weight: 700;
  color: #16a34a;
  font-size: .62rem;
}
.dark .att-counter-dps { color: #4ade80; }
.att-counter-more {
  color: var(--muted);
  font-style: italic;
}

/* Equal-width SVG-icon grid replacing the old flex-wrap pill row */
.type-pill-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}
.type-att-pill {
  --pill-color: #666;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px 6px;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1.5px solid transparent;
  background: color-mix(in srgb, var(--pill-color) 10%, var(--surface2));
  color: var(--pill-color);
  font-family: var(--font);
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  transition: all .12s ease;
  min-height: 52px;
}
.type-att-pill .type-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.type-att-pill .type-pill-icon img.type-icon { width: 22px; height: 22px; }
.type-att-pill .type-pill-name { line-height: 1; }
.type-att-pill:hover {
  background: color-mix(in srgb, var(--pill-color) 22%, var(--surface2));
}
.type-att-pill.active {
  background: var(--pill-color);
  color: #fff;
  border-color: var(--pill-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--pill-color) 30%, transparent);
}
/* Active pill: solid color bg + bigger icon glow for contrast (icon is self-colored now) */
.type-att-pill.active .type-pill-icon img.type-icon { filter: drop-shadow(0 0 4px rgba(255,255,255,.7)); }
.type-att-pill svg { flex-shrink: 0; }

/* Mobile: collapse to 6 columns so pills stay tappable; 4 cols on phones */
@media (max-width: 720px) {
  .type-pill-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
  .type-pill-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .type-att-pill { padding: 8px 3px; }
  .type-att-pill .type-pill-name { font-size: .55rem; }
}

/* Unified info card replacing the old result header + boss strip */
.lc-info-card {
  --card-accent: #666;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lc-info-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lc-info-head-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lc-info-head-icon img.type-icon { width: 100%; height: 100%; }
.lc-info-head-eyebrow {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  line-height: 1.2;
}
.lc-info-head-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 2px;
}
.lc-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.lc-info-row.lc-info-quiet {
  color: var(--muted);
  font-size: .8rem;
  font-style: italic;
}
.lc-info-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 140px;
  flex-shrink: 0;
}
.lc-info-value {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  align-items: center;
}
@media (max-width: 600px) {
  .lc-info-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .lc-info-label { min-width: 0; }
}

.type-result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.type-result-badge {
  font-size: .8rem;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.type-covers {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.type-covers-label {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Attacker list */
.att-list { display: flex; flex-direction: column; gap: 16px; }
.att-group {}
.att-group-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid;
  font-size: .85rem;
  font-weight: 700;
}
.att-tier-badge {
  font-size: .75rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 6px;
}
.att-group-lbl { flex: 1; }
.att-group-cnt {
  font-size: .72rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
}
.att-rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.att-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .12s;
}
.att-row:last-child { border-bottom: none; }
.att-row:hover      { background: var(--surface2); }
.att-sprite {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
.att-info { min-width: 0; }
.att-name { font-weight: 600; font-size: .87rem; display: block; }
.att-sub  { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.att-moves { display: flex; gap: 4px; flex-wrap: wrap; }
.att-tier-sm {
  font-size: .72rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.att-rarity { font-size: .9rem; flex-shrink: 0; }
.att-rarity .material-symbols-rounded {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 650;
}
.att-hl {
  outline: 1px solid rgba(255,255,255,.5);
  outline-offset: 1px;
}

/* ── Raid Bosses ─────────────────────────────── */
.boss-status {
  font-size: .78rem;
  padding: 8px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  display: inline-block;
}
.boss-status.live     { background: rgba(0,200,100,.08); color: #00c878; border: 1px solid rgba(0,200,100,.2); }
.boss-status.fallback { background: rgba(255,200,0,.08); color: #ffd740; border: 1px solid rgba(255,200,0,.2); }

/* Difficulty filter chips above the boss grid */
.boss-diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}
.boss-diff-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.boss-diff-chip:hover { border-color: var(--md-primary, #6366f1); color: var(--md-primary, #6366f1); }
.boss-diff-chip.active {
  background: color-mix(in srgb, var(--md-primary, #6366f1) 22%, transparent);
  border-color: var(--md-primary, #6366f1);
  color: var(--md-primary, #6366f1);
}
.boss-diff-count {
  background: color-mix(in srgb, currentColor 14%, var(--surface));
  font-size: .62rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.boss-diff-chip.active .boss-diff-count { background: rgba(255,255,255,.3); color: #fff; }
.boss-status a        { color: inherit; text-decoration: underline; }
[data-theme="light"] .boss-status.live    { background: rgba(0,150,60,.06); color: #1b5e20; border-color: rgba(0,150,60,.2); }
[data-theme="light"] .boss-status.fallback{ background: rgba(180,100,0,.06); color: #bf360c; border-color: rgba(180,100,0,.2); }

.boss-tier-title {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.boss-tier-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}
.boss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
/* Symmetric tile — fixed structure (header / sprite / name / types / stats / weather) */
.boss-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px 14px;
  transition: border-color .15s, transform .1s ease, box-shadow .15s ease;
  cursor: pointer;
  position: relative;
}
.boss-tile:hover {
  border-color: #5c6bc0;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(92, 107, 192, .12);
}
.boss-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 22px;
  margin-bottom: 6px;
}
.boss-tier-pill {
  font-size: .6rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: .05em;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.boss-tier-pill.tier-6 { background: rgba(244, 114, 182, .15); color: #db2777; border-color: rgba(244, 114, 182, .35); }
.boss-tier-pill.tier-5 { background: rgba(139, 92, 246, .15); color: #8b5cf6; border-color: rgba(139, 92, 246, .35); }
.boss-tier-pill.tier-3 { background: rgba(59, 130, 246, .15); color: #3b82f6; border-color: rgba(59, 130, 246, .35); }
.boss-tier-pill.tier-1 { background: rgba(107, 114, 128, .15); color: #6b7280; border-color: rgba(107, 114, 128, .35); }
.boss-tier-pill.is-shadow-tier {
  background: #1a0a2e;
  color: #b39ddb;
  border-color: #4a2a7a;
}
.dark .boss-tier-pill.tier-6 { color: #f9a8d4; }
.dark .boss-tier-pill.tier-5 { color: #c4b5fd; }
.dark .boss-tier-pill.tier-3 { color: #93c5fd; }
.boss-tile-sprite-wrap {
  margin: 4px 0 8px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boss-tile-sprite {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.35));
}
.boss-tile-name {
  font-weight: 700;
  font-size: .92rem;
  margin-bottom: 6px;
  line-height: 1.2;
}
.boss-tile-types {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  min-height: 22px;
}
.boss-tile-unknown { color: var(--muted); font-size: .7rem; font-style: italic; }
.boss-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: .72rem;
  padding: 2px 0;
  border-top: 1px dashed var(--border);
}
.boss-stat-row:first-of-type { margin-top: 2px; }
.boss-stat-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-weight: 600;
}
.boss-stat-val { font-weight: 700; color: var(--text); }
.boss-stat-boost {
  display: inline-block;
  margin-left: 4px;
  font-size: .62rem;
  color: #16a34a;
  font-weight: 700;
}
.dark .boss-stat-boost { color: #4ade80; }
.boss-weather-row {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.boss-weather-label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.boss-weather-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.boss-weather-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, .14);
  border: 1px solid rgba(251, 191, 36, .3);
  color: #d97706;
  font-size: .68rem;
  font-weight: 600;
}
.dark .boss-weather-chip { color: #fbbf24; }
.boss-weather-chip .inline-ms-icon { font-size: .9rem; }
.boss-weather-icon {
  width: 20px; height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
  padding: 2px;
}
[data-theme="light"] .boss-weather-icon { background: rgba(30, 41, 59, 0.85); }

/* Backwards compatibility (legacy class still defined elsewhere) */
.boss-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: border-color .15s;
}
.boss-card:hover { border-color: #5c6bc0; }
.boss-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.boss-sprite {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
.boss-info { min-width: 0; }
.boss-name { font-weight: 700; font-size: .95rem; }
.boss-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.boss-shiny-badge { font-size: .9rem; line-height: 1; }
.boss-shadow-badge {
  display: inline-block;
  margin-top: 5px;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: #1a0a2e;
  color: #b39ddb;
  border: 1px solid #4a2a7a;
  letter-spacing: .03em;
}
[data-theme="light"] .boss-shadow-badge { background: #ede7f6; color: #4527a0; border-color: #b39ddb; }
.boss-types { display: flex; gap: 4px; flex-wrap: wrap; }
.boss-counters-hdr {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.boss-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.counter-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .75rem;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.counter-chip:hover { border-color: #5c6bc0; background: var(--border); }
.counter-chip img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.counter-name { font-weight: 600; }
.counter-tier {
  font-size: .65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.boss-no-data { font-size: .78rem; color: var(--muted); font-style: italic; }

/* ── Team Builder ────────────────────────────── */
.team-builder { display: flex; flex-direction: column; gap: 20px; }
.team-search-wrap { position: relative; }

.team-slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.team-slot {
  border-radius: 12px;
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  min-height: 100px;
  position: relative;
  transition: border-color .15s;
}
.team-slot.empty {
  color: var(--muted);
  font-size: 1.4rem;
  cursor: default;
}
.team-slot.filled {
  background: var(--surface);
  border-color: var(--border);
  border-style: solid;
}
.team-slot.filled:hover { border-color: #5c6bc0; }
.team-sprite {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.4));
}
.team-slot-name {
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
  margin-top: 4px;
  line-height: 1.2;
}
.team-slot-types {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.team-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--muted);
  font-size: .65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.team-slot.filled:hover .team-remove { opacity: 1; }
.team-remove:hover { background: rgba(255,70,70,.25); color: #ff5252; }

.team-hint {
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
  padding: 20px;
}

/* Coverage grid */
.cov-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cov-title {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.cov-grid { padding: 8px 0; }
.cov-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  border-radius: 0;
  transition: background .1s;
}
.cov-row:hover       { background: rgba(255,255,255,.02); }
.cov-row.gap         { background: rgba(255,70,70,.04); }
.cov-row.gap:hover   { background: rgba(255,70,70,.07); }
.cov-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  color: #fff;
  position: relative;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.cov-type svg { flex-shrink: 0; }
.cov-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.cov-chip {
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff;
  white-space: nowrap;
  cursor: default;
  opacity: .9;
}
.cov-gap-label {
  font-size: .75rem;
  color: #ff5252;
  font-weight: 600;
}
[data-theme="light"] .cov-gap-label { color: #b71c1c; }

.cov-gaps-wrap  { padding: 12px 18px 14px; border-top: 1px solid var(--border); }
.cov-gaps-title { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.cov-gaps-row   { display: flex; flex-wrap: wrap; gap: 6px; }

.cov-perfect {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: .84rem;
  color: #00c878;
  font-weight: 600;
}
[data-theme="light"] .cov-perfect { color: #1b5e20; }

/* Responsive */
@media (max-width: 640px) {
  .meta-tab { padding: 7px 8px; font-size: .75rem; }
  .team-slots { grid-template-columns: repeat(3, 1fr); }
  .boss-grid  { grid-template-columns: 1fr; }
  .att-row    { grid-template-columns: 36px 1fr auto; }
  .att-moves, .att-rarity { display: none; }
  .cov-row    { grid-template-columns: 80px 1fr; }
}

/* ── Trade setup row ──────────────────────────────────────── */
.trade-setup-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}
.trade-setup-row .trade-setup { flex: 1; margin-bottom: 0; }

/* .setup-field-narrow and .setup-entry-btn removed — replaced by inline dex toggle */

/* ── Reset trade button ───────────────────────────────────── */
.reset-trade-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
}
.reset-trade-btn:hover { border-color: #ff5252; color: #ff5252; }

/* ── Tier list search ─────────────────────────────────────── */
.tier-search-wrap {
  margin-bottom: 16px;
}
.tier-search {
  width: 100%;
  max-width: 400px;
}

/* ── AI refresh button — see .ai-result rules above ──────── */

/* ── Bottom nav (mobile) ──────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  transition: transform .18s ease;
}
.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  color: var(--muted);
  transition: color .15s;
}
.bnav-btn.active { color: var(--receiving); }
.bnav-icon { font-size: 1.3rem; line-height: 1; }
.bnav-label { font-size: .65rem; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }

@media (max-width: 640px) {
  .bottom-nav { display: grid; }
  .header-nav { display: none; }
  main { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Type icon mobile rules ───────────────────────────────── */

/* On mobile: hide text inside compact badges (.tl-type, .cov-type) */
@media (max-width: 640px) {
  .tl-type .type-pill-name,
  .cov-type .type-pill-name { display: none; }

  /* Make icon-only pills more compact */
  .tl-type  { padding: 3px 4px; gap: 0; }
  .cov-type { padding: 3px 4px; gap: 0; }

  /* Long-press tooltip */
  .tl-type[data-type]::after,
  .cov-type[data-type]::after {
    content: attr(data-type);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .88);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
    z-index: 300;
    letter-spacing: .4px;
    text-transform: uppercase;
  }
  .tl-type.held::after,
  .cov-type.held::after { opacity: 1; }
}

/* ══════════════════════════════════════════════════
   TRADE HISTORY
══════════════════════════════════════════════════ */

/* Record trade button */
.record-trade-wrap {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}
.record-trade-btn {
  padding: 11px 28px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.record-trade-btn:hover {
  border-color: var(--receiving);
  color: var(--receiving);
  transform: translateY(-1px);
}

/* Record modal sheet */
.record-sheet {
  max-width: 480px;
  width: 94%;
}
.record-body { display: flex; flex-direction: column; gap: 16px; }

.record-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  font-weight: 600;
  flex-wrap: wrap;
}
.record-preview-giving   { color: var(--giving); }
.record-preview-receiving{ color: var(--receiving); }
.record-preview-arrow    { color: var(--muted); font-size: 1.1rem; }
.record-preview-verdict  { margin-left: auto; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.record-preview-verdict.favorable  { background: rgba(0,200,100,.12); color: #00c878; }
.record-preview-verdict.fair       { background: rgba(120,130,255,.12); color: #7c8dff; }
.record-preview-verdict.unfavorable{ background: rgba(255,70,70,.12); color: #ff5252; }
[data-theme="light"] .record-preview-verdict.favorable  { color: #1b5e20; }
[data-theme="light"] .record-preview-verdict.unfavorable{ color: #b71c1c; }
[data-theme="light"] .record-preview-verdict.fair       { color: #1a237e; }

.record-field { display: flex; flex-direction: column; gap: 6px; }
.record-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.record-optional { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7; }

.record-radio-row { display: flex; gap: 12px; }
.record-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  cursor: pointer;
}
.record-radio input { accent-color: var(--receiving); }

.record-toggle-lbl {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
}
.record-toggle-lbl input { accent-color: #ffd700; width: 16px; height: 16px; }
.record-toggle-text { transition: color .15s; }
.record-toggle-lbl input:checked ~ .record-toggle-text { color: #ffd700; }

.record-iv-row { display: flex; gap: 10px; }
.record-iv-group { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.record-iv-lbl { font-size: .65rem; font-weight: 800; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.record-iv-input {
  width: 60px;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 700;
  outline: none;
  transition: border-color .15s;
  -moz-appearance: textfield;
}
.record-iv-input::-webkit-outer-spin-button,
.record-iv-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.record-iv-input:focus { border-color: var(--receiving); }

.record-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: .88rem;
  outline: none;
  resize: vertical;
  transition: border-color .15s;
}
.record-textarea:focus { border-color: var(--receiving); }

/* ── History log ─────────────────────────────────── */
.hist-tabs { margin-bottom: 22px; }

.hist-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.hist-empty-icon { font-size: 3rem; opacity: .4; }
.hist-empty-cta {
  font-size: .82rem;
  color: var(--receiving);
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  text-decoration: underline;
}

.hist-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.hist-stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hist-stat-chip {
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.hist-stat-chip span { color: var(--text); }
.hist-clear-btn {
  font-size: .75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color .15s, color .15s;
}
.hist-clear-btn:hover { border-color: #ff5252; color: #ff5252; }

.hist-entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hist-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: start;
  transition: border-color .15s;
  position: relative;
}
.hist-entry:hover { border-color: #5c6bc0; }
.hist-entry.skipped { opacity: .6; }

.hist-entry-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; font-weight: 600; }
.hist-sprite { width: 38px; height: 38px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }
.hist-entry-giving   { color: var(--giving); }
.hist-entry-receiving{ color: var(--receiving); }
.hist-entry-arrow    { color: var(--muted); }

.hist-entry-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hist-badge {
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .03em;
}
.hist-badge-lucky   { background: rgba(255,215,0,.15); color: #ffd700; border: 1px solid rgba(255,215,0,.4); }
.hist-badge-shiny   { background: rgba(255,215,0,.1);  color: #ffd700; border: 1px solid rgba(255,215,0,.3); }
.hist-badge-verdict { }
.hist-badge-favorable  { background: rgba(0,200,100,.12); color: #00c878; }
.hist-badge-fair       { background: rgba(120,130,255,.12); color: #7c8dff; }
.hist-badge-unfavorable{ background: rgba(255,70,70,.12); color: #ff5252; }
.hist-badge-skipped    { background: rgba(120,120,120,.12); color: var(--muted); }
.hist-badge-legendary  { background: rgba(255,152,0,.12); color: #FF9800; }
.hist-badge-iv         { background: rgba(0,200,100,.12); color: #00c878; border: 1px solid rgba(0,200,100,.3); }

.hist-entry-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-right: 52px; }
.hist-entry-date  { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.hist-entry-dust  { font-size: .72rem; color: var(--muted); }
.hist-entry-partner { font-size: .72rem; color: var(--muted); font-style: italic; }
.hist-entry-notes   { font-size: .72rem; color: var(--muted); font-style: italic; grid-column: 1 / -1; }

.hist-delete-btn, .hist-edit-btn {
  position: absolute;
  top: 10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.hist-delete-btn { right: 10px; font-size: .65rem; }
.hist-edit-btn   { right: 36px; font-size: .72rem; }
.hist-entry:hover .hist-delete-btn,
.hist-entry:hover .hist-edit-btn   { opacity: 1; }
.hist-delete-btn:hover { background: rgba(255,70,70,.2); color: #ff5252; }
.hist-edit-btn:hover   { background: rgba(92,107,192,.2); color: #7c8dff; }

/* ── IV Pips ─────────────────────────────────────── */
.iv-pips { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.iv-pip-row { display: flex; align-items: center; gap: 6px; }
.iv-pip-label {
  font-size: .62rem; font-weight: 800; color: var(--muted);
  width: 26px; text-align: right; flex-shrink: 0;
  letter-spacing: .05em; text-transform: uppercase;
}
.iv-pip-track { display: flex; gap: 5px; }
.iv-pip-group { display: flex; gap: 2px; }
.iv-pip {
  width: 10px; height: 8px; border-radius: 2px;
  background: var(--surface2); border: 1px solid var(--border);
  flex-shrink: 0; transition: background .15s;
}
.iv-pip.filled { border-color: transparent; }
.iv-pip-val {
  font-size: .72rem; font-weight: 800; color: var(--text);
  width: 18px; text-align: right; flex-shrink: 0;
}
@media (max-width: 420px) {
  .iv-pip { width: 7px; height: 7px; }
}

/* ── Legendary note in trade info ────────────────── */
.tr-legend-note {
  font-size: .74rem;
  color: var(--muted);
  background: rgba(255,152,0,.07);
  border: 1px solid rgba(255,152,0,.2);
  border-radius: 8px;
  padding: 7px 12px;
  margin-top: 8px;
  line-height: 1.5;
}
[data-theme="light"] .tr-legend-note {
  background: rgba(230,120,0,.05);
  border-color: rgba(230,120,0,.25);
  color: #5d3a00;
}

/* ── Medals ──────────────────────────────────────── */
.medals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.medal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, transform .15s;
}
.medal-card:hover { border-color: #5c6bc0; transform: translateY(-2px); }
.medal-card.tier-bronze   { border-color: rgba(205,127,50,.4); }
.medal-card.tier-silver   { border-color: rgba(192,192,192,.5); }
.medal-card.tier-gold     { border-color: rgba(255,215,0,.5); }
.medal-card.tier-platinum { border-color: rgba(180,199,220,.6); box-shadow: 0 0 16px rgba(180,199,220,.15); }
.medal-card.tier-locked   { opacity: .5; }

.medal-top { display: flex; align-items: center; gap: 10px; }
.medal-icon { font-size: 2rem; flex-shrink: 0; line-height: 1; }
.medal-name { font-weight: 700; font-size: .9rem; }
.medal-desc { font-size: .73rem; color: var(--muted); }

.medal-tier-badge {
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  align-self: flex-start;
}
.medal-tier-badge.bronze   { background: rgba(205,127,50,.2); color: #cd7f32; border: 1px solid rgba(205,127,50,.4); }
.medal-tier-badge.silver   { background: rgba(192,192,192,.2); color: #aaa; border: 1px solid rgba(192,192,192,.4); }
.medal-tier-badge.gold     { background: rgba(255,215,0,.15); color: #ffd700; border: 1px solid rgba(255,215,0,.4); }
.medal-tier-badge.platinum { background: rgba(180,199,220,.15); color: #b4c7dc; border: 1px solid rgba(180,199,220,.4); }
.medal-tier-badge.locked   { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.medal-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.medal-progress-bar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.medal-progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}
.medal-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .68rem;
  color: var(--muted);
}
.medal-progress-label .current { color: var(--text); font-weight: 700; }

@media (max-width: 640px) {
  .medals-grid { grid-template-columns: repeat(2, 1fr); }
  .record-iv-row { gap: 6px; }
  .record-iv-input { width: 52px; }
}

/* ── Material 3 refresh ─────────────────────────────────── */
:root {
  color-scheme: light dark;
  --md-primary: #315ca8;
  --md-on-primary: #ffffff;
  --md-primary-container: #d7e3ff;
  --md-on-primary-container: #001b3f;
  --md-secondary: #566170;
  --md-secondary-container: #dae2f0;
  --md-tertiary: #77536d;
  --md-tertiary-container: #ffd7f0;
  --md-error: #ba1a1a;
  --md-success: #216d3a;
  --md-warning: #835400;
  --bg: #f8f9ff;
  --surface: #f8f9ff;
  --surface2: #eef1fa;
  --surface-container-low: #f2f4fc;
  --surface-container: #eceef6;
  --surface-container-high: #e6e8f0;
  --border: #c3c6d0;
  --text: #191c20;
  --muted: #5f636d;
  --giving: #a94316;
  --receiving: var(--md-primary);
  --radius: 8px;
  --font: 'Google Sans Flex', system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --md-primary: #a8c7fa;
  --md-on-primary: #003060;
  --md-primary-container: #17477f;
  --md-on-primary-container: #d7e3ff;
  --md-secondary: #bec6d5;
  --md-secondary-container: #3f4857;
  --md-tertiary: #e6bad7;
  --md-tertiary-container: #5d3c55;
  --md-error: #ffb4ab;
  --md-success: #8ed69d;
  --md-warning: #ffc875;
  --bg: #101418;
  --surface: #101418;
  --surface2: #1c2026;
  --surface-container-low: #191c22;
  --surface-container: #1f2329;
  --surface-container-high: #292d33;
  --border: #454952;
  --text: #e1e2e8;
  --muted: #c3c6d0;
  --giving: #ffb59a;
  --receiving: var(--md-primary);
}

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

h1, h2, h3, h4, p, button, input, select, textarea, label, span, li {
  letter-spacing: 0;
}

header {
  background: color-mix(in srgb, var(--surface-container-low) 92%, transparent);
  border-bottom: 1px solid transparent;
  box-shadow: none;
  backdrop-filter: blur(18px);
  min-height: 64px;
}

.header-inner {
  max-width: 1040px;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 0;
  color: var(--text);
}
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Theme-aware logo swap: transparent variant on dark, navy-backdrop variant on light */
.logo .logo-light { display: none; }
[data-theme="light"] .logo .logo-dark  { display: none; }
[data-theme="light"] .logo .logo-light { display: block; border-radius: 10px; }

.logo .material-symbols-rounded {
  font-size: 25px;
  font-variation-settings: 'FILL' 1;
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0;
}
@media (max-width: 540px) {
  h1 { font-size: 1.2rem; }
}
@media (max-width: 400px) {
  h1 { font-size: 1.05rem; }
}

.subtitle,
.section-sub,
.placeholder-text,
.stat-label,
.iv-desc,
.tl-notes-cell,
.poke-notes,
.hist-entry-date,
.hist-entry-dust,
.hist-entry-partner,
.hist-entry-notes,
.medal-desc {
  color: var(--muted);
}

.header-nav {
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-container);
}

.nav-link {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
}

.nav-link:hover,
.nav-link.active {
  background: var(--md-secondary-container);
  color: var(--text);
}

.theme-toggle,
.ai-settings-btn,
.poke-modal-close,
.hist-delete-btn,
.team-remove {
  border: none;
  background: transparent;
  color: var(--md-primary);
}

.theme-toggle,
.ai-settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 20px;
}

.theme-toggle:hover,
.ai-settings-btn:hover,
.poke-modal-close:hover {
  background: var(--surface-container-high);
  color: var(--md-primary);
  transform: none;
}

.slide {
  max-width: 1040px;
  padding-top: 28px;
}

.section-header h2 {
  font-size: 1.45rem;
  font-weight: 700;
}

.selector-card,
.comparison-grid,
.tips-box,
.iv-table,
.iv-note-card,
.tl-rows,
.trade-results,
.ai-analysis-card,
.boss-card,
.team-slot,
.cov-section,
.hist-entry,
.medal-card,
.record-preview,
.pm-section {
  background: var(--surface-container-low);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
}

.selector-card,
.compare-col,
.iv-note-card,
.boss-card,
.hist-entry,
.medal-card {
  transition: background .15s, border-color .15s;
}

.selector-card:hover,
.boss-card:hover,
.hist-entry:hover,
.medal-card:hover,
.tl-row-clickable:hover,
.att-row:hover {
  border-color: color-mix(in srgb, var(--md-primary) 48%, var(--border));
  background: var(--surface-container);
  transform: none;
}

.panel-label,
.setup-label,
.filter-label,
.record-label,
.pm-section-title {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0;
}

.panel-label {
  border-radius: 999px;
  padding: 5px 12px;
}

.panel-label.giving {
  background: color-mix(in srgb, var(--giving) 14%, transparent);
  color: var(--giving);
}

.panel-label.receiving {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.search-input,
.setup-select,
.record-iv-input,
.record-textarea {
  min-height: 40px;
  padding: 8px 12px;
  background: var(--surface-container);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  box-shadow: inset 0 -1px 0 var(--border);
}

.search-input:focus,
.setup-select:focus,
.record-iv-input:focus,
.record-textarea:focus {
  border-color: var(--md-primary);
  box-shadow: inset 0 -2px 0 var(--md-primary);
}

.dropdown {
  background: var(--surface-container-high);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
}

.dropdown li:hover {
  background: color-mix(in srgb, var(--md-primary) 10%, transparent);
}

.toggle-btn,
.chip,
.meta-tab,
.type-att-pill,
.counter-chip,
.cov-chip,
.hist-stat-chip,
.hist-badge,
.move-chip,
.modifier-badge {
  border-radius: 8px;
  background: var(--surface-container);
  border-color: var(--border);
  color: var(--text);
}

.toggle-btn:hover,
.chip:hover,
.meta-tab:hover,
.type-att-pill:hover,
.counter-chip:hover {
  border-color: var(--md-primary);
  color: var(--md-primary);
}

.toggle-btn.active,
.chip.active,
.meta-tab.active,
.type-att-pill.active {
  background: var(--md-secondary-container);
  border-color: color-mix(in srgb, var(--md-primary) 45%, transparent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-primary) 15%, transparent);
}

.settings-save,
.ai-analyze-btn,
.record-trade-btn {
  min-height: 40px;
  border-radius: 20px;
  border: none;
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: none;
}

.settings-save:hover,
.ai-analyze-btn:hover,
.record-trade-btn:hover {
  background: color-mix(in srgb, var(--md-primary) 88%, #000);
  color: var(--md-on-primary);
  transform: none;
}

.settings-cancel,
.setup-entry-btn,
.reset-trade-btn,
.ai-refresh-btn,
.hist-clear-btn {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--md-primary);
}

.settings-cancel:hover,
.setup-entry-btn:hover,
.reset-trade-btn:hover,
.ai-refresh-btn:hover,
.hist-clear-btn:hover {
  background: color-mix(in srgb, var(--md-primary) 8%, transparent);
  border-color: var(--md-primary);
  color: var(--md-primary);
}

.setup-entry-btn.active {
  background: var(--md-primary-container);
  border-color: transparent;
  color: var(--md-on-primary-container);
}

.vs-circle,
.placeholder-art {
  background: var(--surface-container);
  border: 1px solid var(--border);
  color: var(--md-primary);
}

.poke-sprite,
.tl-sprite,
.att-sprite,
.boss-sprite,
.team-sprite,
.pm-sprite {
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.18));
}

.verdict-banner {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-container);
  color: var(--text);
}

.verdict-great { border-color: color-mix(in srgb, var(--md-success) 55%, var(--border)); color: var(--md-success); }
.verdict-fair,
.verdict-even { border-color: color-mix(in srgb, var(--md-warning) 45%, var(--border)); color: var(--md-warning); }
.verdict-bad { border-color: color-mix(in srgb, var(--md-error) 55%, var(--border)); color: var(--md-error); }

.tier-bar-track,
.medal-progress-bar-track {
  background: var(--surface-container-high);
}

.settings-backdrop,
.poke-modal-backdrop {
  background: rgba(0,0,0,.38);
  backdrop-filter: none;
}

.settings-sheet,
.poke-modal-sheet {
  background: var(--surface-container);
  border: none;
  border-radius: 28px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
}

.bottom-nav {
  min-height: calc(80px + env(safe-area-inset-bottom, 0px));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-container);
  border-top: none;
  box-shadow: 0 -2px 16px rgba(0,0,0,.12);
}

.bnav-btn {
  position: relative;
  min-width: 0;
  min-height: 64px;
  border-radius: 0;
  color: var(--muted);
  gap: 4px;
}

.bnav-btn::before {
  content: '';
  position: absolute;
  top: 4px;
  width: 56px;
  height: 32px;
  border-radius: 16px;
  background: transparent;
  transition: background .15s;
}

.bnav-btn.active {
  color: var(--md-on-primary-container);
}

.bnav-btn.active::before {
  background: var(--md-primary-container);
}

.bnav-icon {
  position: relative;
  z-index: 1;
  font-size: 24px;
  font-variation-settings: 'FILL' 0;
}

.bnav-btn.active .bnav-icon {
  font-variation-settings: 'FILL' 1;
}

.bnav-label {
  position: relative;
  z-index: 1;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  header {
    min-height: 64px;
    padding: 12px 16px;
  }

  .header-inner {
    min-width: 0;
    gap: 10px;
  }

  .header-inner > div:nth-child(2) {
    min-width: 0;
  }

  h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .theme-toggle,
  .ai-settings-btn {
    flex: 0 0 40px;
  }

  .slide {
    padding: 20px 16px 72px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  main {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  .trade-setup-row {
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }

  .trade-setup,
  .setup-field,
  .setup-select-wrap,
  .search-wrap,
  .selectors,
  .selector-card {
    min-width: 0;
  }

  .selector-card {
    padding: 16px;
  }

  .bottom-nav {
    left: 0;
    right: 0;
    max-width: 100%;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }

  .bnav-btn::before {
    width: clamp(42px, 13vw, 56px);
  }

  .bnav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── Mobile Material polish ─────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --mobile-gutter: 20px;
  }

  body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  header {
    min-height: 64px;
    padding: max(10px, env(safe-area-inset-top, 0px)) var(--mobile-gutter) 10px;
    background: var(--bg);
    border-bottom: none;
    backdrop-filter: none;
  }

  .header-inner {
    gap: 12px;
  }

  .logo {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: clamp(1.05rem, 4.4vw, 1.45rem);
    line-height: 1.08;
    font-weight: 750;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .theme-toggle,
  .ai-settings-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .theme-toggle .material-symbols-rounded,
  .ai-settings-btn .material-symbols-rounded {
    font-size: 25px;
  }

  .slide {
    padding: 24px var(--mobile-gutter) 78px;
  }

  .section-header {
    margin-bottom: 22px;
  }

  .section-header h2 {
    font-size: clamp(1.55rem, 8vw, 2rem);
    line-height: 1.12;
  }

  .section-sub {
    font-size: 1rem;
    line-height: 1.45;
  }

  .trade-setup-row {
    margin-bottom: 26px;
  }

  .trade-setup {
    gap: 14px;
  }

  .setup-label,
  .filter-label,
  .record-label,
  .panel-label,
  .compare-col h4,
  .tips-box h4,
  .pm-section-title {
    font-size: .78rem;
    font-weight: 760;
    letter-spacing: .02em;
  }

  .search-input,
  .setup-select,
  .record-iv-input,
  .record-textarea {
    min-height: 52px;
    border-radius: 6px;
    background: var(--surface-container-low);
    box-shadow: none;
    font-size: 1rem;
  }

  .setup-select {
    padding: 12px 38px 12px 16px;
  }

  .setup-entry-btn,
  .reset-trade-btn,
  .settings-cancel,
  .ai-refresh-btn,
  .hist-clear-btn {
    min-height: 46px;
    padding-inline: 18px;
  }

  .selector-card,
  .comparison-grid,
  .tips-box,
  .ai-analysis-card,
  .iv-table,
  .iv-note-card,
  .tl-rows,
  .boss-card,
  .hist-entry,
  .medal-card {
    border-radius: 14px;
    border-color: color-mix(in srgb, var(--border) 70%, transparent);
  }

  .selector-card {
    padding: 20px;
  }

  .pokemon-display {
    min-height: 218px;
    padding: 22px 0 14px;
  }

  .placeholder-art {
    width: 76px;
    height: 76px;
    font-size: 2.15rem;
  }

  .placeholder-text {
    font-size: .95rem;
  }

  .toggle-row {
    margin: 12px 0 8px;
  }

  .toggle-btn {
    min-height: 44px;
    font-size: .95rem;
    border-radius: 10px;
  }

  .vs-divider {
    padding: 12px 0;
  }

  .vs-circle {
    width: 42px;
    height: 42px;
  }

  .trade-results {
    flex-direction: column;
  }

  .tr-stat {
    width: 100%;
  }

  .tr-divider {
    width: 100%;
    height: 1px;
  }

  .tips-box li {
    color: var(--muted);
    line-height: 1.45;
  }

  .record-trade-btn,
  .settings-save,
  .ai-analyze-btn {
    min-height: 48px;
    border-radius: 24px;
    padding-inline: 28px;
    font-size: 1rem;
  }

  .hist-log-header {
    align-items: flex-start;
    gap: 12px;
  }

  .hist-stats-row {
    gap: 8px;
  }

  .hist-stat-chip {
    border-radius: 10px;
    padding: 8px 12px;
    font-size: .9rem;
  }

  .hist-clear-btn {
    width: auto;
  }

  .hist-entry {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px;
  }

  .hist-entry-main {
    gap: 10px;
  }

  .hist-entry-right {
    align-items: flex-start;
    padding-right: 0;
  }

  .hist-edit-btn,
  .hist-delete-btn {
    opacity: 1;
    width: 36px;
    height: 36px;
    top: 14px;
    background: transparent;
  }

  .hist-edit-btn {
    right: 52px;
  }

  .hist-delete-btn {
    right: 12px;
  }

  .settings-sheet,
  .poke-modal-sheet {
    border-radius: 24px 24px 0 0;
  }

  .poke-modal-scroll {
    /* Tight outer padding on phones — first value leaves room for close button */
    padding: 48px 6px 24px;
  }

  .bottom-nav {
    min-height: calc(76px + env(safe-area-inset-bottom, 0px));
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .bnav-btn {
    min-height: 60px;
  }

  .bnav-btn::before {
    top: 3px;
    height: 30px;
  }

  .bnav-icon {
    font-size: 23px;
  }

  .bnav-label {
    font-size: .76rem;
  }
}

/* ── Revision polish: friendship, form badges, modal spacing, history ───── */
.native-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.friendship-picker {
  position: relative;
}

/* ── Age picker (mirrors friendship picker chrome for visual consistency) ── */
.age-picker { position: relative; }
.age-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-container-low);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.age-trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--md-primary) 24%, transparent);
  border-color: var(--md-primary);
}
.age-label { font-weight: 600; font-size: .88rem; }
.age-pct {
  background: color-mix(in srgb, var(--md-primary, #6366f1) 16%, transparent);
  color: var(--md-primary, #6366f1);
  font-size: .68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.age-caret { color: var(--muted); margin-left: auto; transition: transform .16s; font-size: 1.1rem; }
.age-picker.open .age-caret { transform: rotate(180deg); }
.age-menu {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 30;
  background: var(--surface-container-high);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.32);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.age-picker.open .age-menu { display: flex; }
.age-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .88rem;
  user-select: none;
}
.age-option:hover,
.age-option.selected {
  background: color-mix(in srgb, var(--md-primary) 12%, transparent);
}
.age-option.selected { font-weight: 700; }
.age-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--md-primary) 24%, transparent);
}

/* ── "Optimal Moveset" label above move chips in trade tile ────────────── */
.poke-moves-block {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.poke-moves-lbl {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.friendship-trigger,
.friendship-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-container-low);
  color: var(--text);
  font: inherit;
  text-align: left;
}

.friendship-trigger {
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 var(--border);
}

.friendship-trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--md-primary) 24%, transparent);
  border-color: var(--md-primary);
}

.friendship-hearts {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  white-space: nowrap;
}

.friend-heart {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, #b87521 16%, var(--surface-container));
  color: color-mix(in srgb, #b87521 28%, var(--muted));
  border: 1px solid color-mix(in srgb, #8f5a16 25%, var(--border));
  font-family: 'Material Symbols Rounded';
  font-size: 15px;
  font-variation-settings: 'FILL' 1, 'wght' 600;
  line-height: 1;
}

.friend-heart.filled {
  background: #b87521;
  color: #f4dcc0;
  border-color: #9a641c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}

.friendship-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.friendship-name {
  font-weight: 760;
  line-height: 1.15;
}

.friendship-detail {
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.2;
}

.friendship-caret {
  color: var(--muted);
  transition: transform .16s;
}

.friendship-picker.open .friendship-caret {
  transform: rotate(180deg);
}

.friendship-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--surface-container-high);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0,0,0,.22);
}

.friendship-picker.open .friendship-menu {
  display: flex;
}

.friendship-option {
  grid-template-columns: auto;
  justify-content: center;
  min-height: 54px;
  padding: 8px 10px;
  cursor: pointer;
  border-color: transparent;
  background: transparent;
}

.friendship-option:hover,
.friendship-option.selected {
  background: color-mix(in srgb, var(--md-primary) 10%, transparent);
  border-color: color-mix(in srgb, var(--md-primary) 28%, transparent);
}

.form-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 11px 4px 6px;
  border-radius: 999px;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: middle;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24);
}

.form-type-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  font-size: 15px;
  font-variation-settings: 'FILL' 1, 'wght' 650;
}

/* PokeMiners primal orb / mega icon — no background tint, lets the asset stand on its own */
.form-type-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: inline-block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
  flex-shrink: 0;
}
.tl-name-cell .form-type-img { width: 16px; height: 16px; }

.form-type-badge.form-mega {
  background: linear-gradient(135deg, #d81b60, #f06292);
}

.form-type-badge.form-primal {
  background: linear-gradient(135deg, #ef6c00, #ffb300);
}

.form-type-badge.form-shadow {
  background: linear-gradient(135deg, #5e35b1, #263238);
}

.tl-name-cell .form-type-badge {
  min-height: 24px;
  padding: 3px 8px 3px 4px;
  font-size: .62rem;
}

.tl-name-cell .form-type-icon {
  width: 16px;
  height: 16px;
  font-size: 12px;
}

.pm-section {
  padding: 18px 20px;
  margin-top: 12px;
}

.pm-section-title {
  margin-bottom: 14px;
}

.pm-tier-row,
.pm-moves-row {
  gap: 14px;
}

.pm-trade-badge {
  padding: 14px 16px;
}

.hist-log-header {
  align-items: center;
  gap: 10px;
}

.hist-stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 100%;
}

.hist-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hist-log-header-empty {
  justify-content: flex-end;
}

.hist-tool-btn,
.hist-clear-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-container);
  color: var(--md-primary);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}

.hist-tool-btn:hover,
.hist-clear-btn:hover {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.hist-stat-chip {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: .78rem;
  background: var(--surface-container-low);
}

.hist-stat-chip .hist-stat-label {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-stat-chip .hist-stat-value {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.hist-entry {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.hist-entry-top {
  position: relative;
  width: 100%;
  min-height: 38px;
}

.hist-entry-main {
  min-width: 0;
  gap: 6px;
  flex-wrap: nowrap;
  padding-right: 78px;
  max-width: 100%;
}

.hist-entry-giving,
.hist-entry-receiving {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-entry-actions {
  position: absolute;
  top: 2px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px;
  border-radius: 999px;
  background: var(--surface-container);
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.hist-icon-btn,
.hist-entry-actions .hist-delete-btn {
  position: static;
  opacity: 1;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--md-primary);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.hist-icon-btn .material-symbols-rounded {
  font-size: 18px;
}

.hist-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border: 1px solid var(--border);
  background: var(--surface-container);
  color: var(--text);
}

.hist-badge-icon {
  font-size: 15px;
  line-height: 1;
  font-variation-settings: 'FILL' 1, 'wght' 650;
}

.hist-badge-lucky,
.hist-badge-shiny,
.hist-badge-legendary,
.hist-badge-favorable,
.hist-badge-fair,
.hist-badge-unfavorable,
.hist-badge-skipped {
  border-width: 1px;
}

.hist-badge-lucky { background: color-mix(in srgb, #f9ab00 10%, var(--surface-container)); color: #8a5b00; border-color: color-mix(in srgb, #f9ab00 35%, var(--border)); }
.hist-badge-shiny { background: color-mix(in srgb, #d81b60 8%, var(--surface-container)); color: #a31545; border-color: color-mix(in srgb, #d81b60 30%, var(--border)); }
.hist-badge-legendary { background: color-mix(in srgb, #f57c00 10%, var(--surface-container)); color: #9a4b00; border-color: color-mix(in srgb, #f57c00 32%, var(--border)); }
.hist-badge-favorable { background: color-mix(in srgb, #188038 10%, var(--surface-container)); color: #0b6b2a; border-color: color-mix(in srgb, #188038 30%, var(--border)); }
.hist-badge-fair { background: color-mix(in srgb, var(--md-primary) 10%, var(--surface-container)); color: var(--md-primary); border-color: color-mix(in srgb, var(--md-primary) 30%, var(--border)); }
.hist-badge-unfavorable { background: color-mix(in srgb, #ba1a1a 9%, var(--surface-container)); color: #a31818; border-color: color-mix(in srgb, #ba1a1a 28%, var(--border)); }
.hist-badge-skipped { background: var(--surface-container); color: var(--muted); border-color: var(--border); }

[data-theme="dark"] .hist-badge-lucky { color: #fdd663; }
[data-theme="dark"] .hist-badge-shiny { color: #ff8ab5; }
[data-theme="dark"] .hist-badge-legendary { color: #ffb74d; }
[data-theme="dark"] .hist-badge-favorable { color: #81c995; }
[data-theme="dark"] .hist-badge-unfavorable { color: #f28b82; }

.hist-icon-btn:hover {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.hist-entry-actions .hist-delete-btn:hover {
  background: color-mix(in srgb, #ba1a1a 12%, transparent);
  color: #ba1a1a;
}

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

.hist-fact {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: 12px;
  background: var(--surface-container);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}

.hist-fact span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-fact .material-symbols-rounded {
  color: var(--md-primary);
  font-size: 18px;
}

.hist-country-flag {
  font-size: 1rem;
  line-height: 1;
}

.hist-entry-partner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-style: normal;
}

.hist-entry-partner .material-symbols-rounded {
  color: var(--md-primary);
  font-size: 18px;
}

@media (max-width: 640px) {
  .friendship-trigger {
    min-height: 60px;
  }

  .friend-heart {
    width: 20px;
    height: 20px;
    font-size: 14px;
  }

  .friendship-detail {
    font-size: .7rem;
  }

  .pm-section {
    padding: 18px;
  }

  .hist-stats-row {
    gap: 6px;
  }

  .hist-stat-chip {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 7px 5px;
    font-size: .72rem;
  }

  .hist-entry {
    padding: 16px;
  }

  .hist-entry-main {
    font-size: .86rem;
    padding-right: 66px;
  }

  .hist-sprite {
    width: 30px;
    height: 30px;
  }

  .hist-entry-facts {
    gap: 6px;
  }

  .hist-fact {
    min-height: 36px;
    padding-inline: 5px;
    font-size: .68rem;
  }
}

/* ── Review fixes: safer Material touch targets and icon alignment ──────── */
.chip,
.type-att-pill,
.meta-tab {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip,
.type-att-pill {
  padding-inline: 14px;
}

.meta-tab {
  gap: 6px;
}

.meta-tab .material-symbols-rounded,
.hist-clear-btn .material-symbols-rounded,
.hist-tool-btn .material-symbols-rounded {
  font-size: 18px;
  line-height: 1;
}

.hist-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.setup-entry-btn,
.record-trade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.setup-entry-btn .material-symbols-rounded,
.record-trade-btn .material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
}

.hist-icon-btn,
.hist-entry-actions .hist-delete-btn {
  width: 30px;
  height: 30px;
}

.friendship-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--md-primary) 24%, transparent);
  border-color: var(--md-primary);
}

.poke-modal-close {
  width: 44px;
  height: 44px;
}

.poke-modal-close .material-symbols-rounded {
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 640px) {
  .chip,
  .type-att-pill,
  .meta-tab {
    min-height: 44px;
  }
}

/* ── Mega Evolution Tracker (Dex › Mega sub-tab) ────────────────────────── */

/* Active type bonuses — label on its own line, chips below. */
.mega-bonus-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--md-primary, #6366f1) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--md-primary, #6366f1) 24%, var(--border));
  border-radius: 12px;
  margin-bottom: 14px;
}
.mega-bonus-lbl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.mega-bonus-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mega-bonus-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Controls bar */
.mega-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mega-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background: var(--md-primary, #6366f1);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s;
}
.mega-add-btn:hover { background: color-mix(in srgb, var(--md-primary, #6366f1) 80%, #000); }
.mega-tracked-count {
  font-size: .72rem;
  color: var(--muted);
  margin-left: auto;
}

/* Empty state */
.mega-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
}
.mega-empty-icon { font-size: 3rem !important; color: var(--muted); display: block; margin-bottom: 12px; }
.mega-empty-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.mega-empty-sub { font-size: .82rem; color: var(--muted); line-height: 1.5; max-width: 320px; margin: 0 auto; }

/* Card grid */
.mega-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Individual mega card */
.mega-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.mega-card-ready { border-color: color-mix(in srgb, #10b981 50%, var(--border)); }
.mega-card-soon  { border-color: color-mix(in srgb, #f59e0b 45%, var(--border)); }

.mega-card-head {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
}
.mega-sprite {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
}
.mega-card-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mega-card-title { font-size: .92rem; font-weight: 700; line-height: 1.2; }
.mega-types { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.mega-type-pill { font-size: .55rem !important; padding: 2px 6px !important; }

/* Level badge */
.mega-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 900;
  letter-spacing: .02em;
  color: #fff;
  flex-shrink: 0;
}
.mega-level-0 { background: #6b7280; }
.mega-level-1 { background: #4a90e2; }
.mega-level-2 { background: #a855f7; }
.mega-level-3 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1f1500; }

/* Progress bar */
.mega-progress { display: flex; flex-direction: column; gap: 4px; }
.mega-progress-bar {
  height: 6px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
}
.mega-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a90e2, #a855f7);
  border-radius: 999px;
  transition: width .3s;
}
.mega-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .68rem;
  color: var(--muted);
  font-weight: 600;
}
.mega-prog-label { letter-spacing: .04em; }
.mega-proj { color: var(--md-primary, #6366f1); font-weight: 700; cursor: help; }

/* Cooldown status pill */
.mega-cooldown {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  align-self: flex-start;
}
.mega-cooldown-ready { background: color-mix(in srgb, #10b981 18%, transparent); color: #10b981; }
.mega-cooldown-soon  { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #f59e0b; }
.mega-cooldown-cool  { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }

/* Card actions */
.mega-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.mega-evolve-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  background: color-mix(in srgb, #a855f7 16%, transparent);
  color: #a855f7;
  border: 1px solid color-mix(in srgb, #a855f7 40%, var(--border));
  border-radius: 8px;
  font-family: var(--font);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s;
}
.mega-evolve-btn:hover { background: color-mix(in srgb, #a855f7 28%, transparent); }
.mega-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.mega-icon-btn:hover { color: var(--text); border-color: var(--md-primary, #6366f1); }
.mega-remove-btn:hover { color: #ef4444; border-color: #ef4444; }

/* Picker modal */
.mega-picker-sheet { max-width: 520px; max-height: 80vh; display: flex; flex-direction: column; }
.mega-picker-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mega-picker-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .12s;
}
.mega-picker-row:hover { border-color: var(--md-primary, #6366f1); }
.mega-picker-sprite { width: 44px; height: 44px; image-rendering: pixelated; }
.mega-picker-name { font-size: .86rem; font-weight: 600; }
.mega-picker-types { display: inline-flex; gap: 3px; }

/* Pokémon sub-tab placeholder */
.dex-soon {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}
.dex-soon-icon { font-size: 3rem !important; color: var(--md-primary, #6366f1); display: block; margin-bottom: 14px; }
.dex-soon-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.dex-soon-sub { font-size: .85rem; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.dex-soon-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.dex-soon-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: .82rem;
  color: var(--muted);
}
.dex-soon-list .material-symbols-rounded { color: var(--md-primary, #6366f1); }

/* Active-mega banner — the one currently within its 8-hour Mega window */
.mega-active-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(90deg,
    color-mix(in srgb, #a855f7 18%, transparent),
    color-mix(in srgb, #facc15 12%, transparent));
  border: 1px solid color-mix(in srgb, #a855f7 40%, var(--border));
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: .85rem;
  color: var(--text);
}
.mega-active-banner .material-symbols-rounded { color: #facc15; font-size: 1.2rem; }
.mega-active-text { flex: 1; }
.mega-active-text strong { color: #a855f7; }
.mega-active-timer {
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 3px 9px;
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
  border-radius: 999px;
}

/* Card-level highlight for the currently active mega — a subtle pulsing glow
   in the same magenta/purple language as the Shadow Pokémon aura on the modal
   hero sprite. Intentionally soft: the banner above the grid is the primary
   "this one is active" cue; this is just a quiet echo. */
.mega-card-active {
  border-color: color-mix(in srgb, #c084fc 35%, var(--border)) !important;
  animation: megaActivePulse 3.2s ease-in-out infinite;
}
@keyframes megaActivePulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, #c084fc 30%, transparent),
      0 0 8px  color-mix(in srgb, #c084fc 14%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, #c084fc 45%, transparent),
      0 0 14px color-mix(in srgb, #c084fc 26%, transparent);
  }
}

/* Both icons sized identically so the banner Poké Ball and bonus-row Mega
   glyph read as a matched pair across the Mega tab. */
.mega-banner-icon,
.mega-bonus-glyph {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Inline SVG — flat black circle + white "M" glyph in light mode, inverts to
   white circle + black glyph in dark mode. Same shape language as ball-poke
   (square 128×128 viewBox, filled circle), so the two icons match in scale. */
.mega-bonus-glyph .mb-bg { fill: #1a1a1a; }
.mega-bonus-glyph .mb-fg { fill: #ffffff; }
[data-theme="dark"] .mega-bonus-glyph .mb-bg { fill: #ffffff; }
[data-theme="dark"] .mega-bonus-glyph .mb-fg { fill: #1a1a1a; }

/* Tighten the label so the icon sits cleanly with the uppercase text */
.mega-bonus-lbl { gap: 8px; }

/* ── Toasts / Snackbars ──────────────────────────────────────────────────── */
.app-toast-stack {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column-reverse;  /* newest toast on top of the stack */
  gap: 8px;
  pointer-events: none;             /* let clicks pass through the empty space */
  width: min(420px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
}
/* On mobile the bottom nav (~64px tall) eats the bottom strip — lift toasts above it */
@media (max-width: 900px) {
  .app-toast-stack {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
  font-size: .88rem;
  line-height: 1.35;
  /* Enter animation hook */
  opacity: 0;
  transform: translateY(8px) scale(.98);
  transition: opacity .2s ease, transform .2s cubic-bezier(.2,.7,.3,1);
}
.app-toast-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.app-toast-hide {
  opacity: 0;
  transform: translateY(8px) scale(.98);
}
.app-toast-icon {
  flex-shrink: 0;
  font-size: 1.2rem !important;
  color: var(--md-primary, #6366f1);
}
.app-toast-msg {
  flex: 1 1 auto;
  min-width: 0;
  /* allow long Pokemon names to wrap rather than push the action off-screen */
  overflow-wrap: anywhere;
}
.app-toast-action {
  flex-shrink: 0;
  appearance: none;
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: .84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  color: var(--md-primary, #6366f1);
  transition: background .12s;
}
.app-toast-action:hover {
  background: color-mix(in srgb, var(--md-primary, #6366f1) 12%, transparent);
}
.app-toast-action:focus-visible {
  outline: 2px solid var(--md-primary, #6366f1);
  outline-offset: 2px;
}
.app-toast-close {
  flex-shrink: 0;
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-toast-close:hover { color: var(--text); background: var(--border); }
.app-toast-close .inline-ms-icon { font-size: 1.05rem !important; }

/* Tone variants — color the leading icon to signal status at a glance */
.app-toast-success .app-toast-icon { color: #22c55e; }
.app-toast-danger  .app-toast-icon { color: #ef4444; }
.app-toast-warn    .app-toast-icon { color: #f59e0b; }

/* ── Global tooltip override ─────────────────────────────────────────────── */
/* Replaces the native OS `title` balloon with a themed in-app tooltip. The
   text/surface inversion automatically adapts to light vs dark mode. */
.app-tooltip {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .76rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: .005em;
  background: var(--text);
  color: var(--surface);
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  /* Hidden by default — opacity-based show/hide for smooth fade. */
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .14s ease, transform .14s ease;
  /* Word-wrap behaviour — long titles wrap, very long stay reasonable. */
  white-space: normal;
  text-align: center;
  /* Initial off-screen so the first measurement is sane. */
  top: -9999px;
  left: -9999px;
}
.app-tooltip-show {
  opacity: 1;
  transform: translateY(0);
}
/* Caret arrow — pseudo-element pointing at the trigger. `data-placement`
   flips it between top (tip below the trigger) and bottom (tip above). */
.app-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
}
.app-tooltip[data-placement="top"]::after {
  /* Tooltip is ABOVE the trigger — arrow points down from tooltip bottom. */
  top: 100%;
  border-top-color: var(--text);
}
.app-tooltip[data-placement="bottom"]::after {
  /* Tooltip is BELOW the trigger — arrow points up from tooltip top. */
  bottom: 100%;
  border-bottom-color: var(--text);
}

/* ── Search input affordances (B5) ───────────────────────────────────────── */
.search-affordance-input {
  padding-left: 36px !important;
  padding-right: 36px !important;
}
/* Hide the browser's native search-clear button — we provide our own so it
   looks identical on every platform (iOS/Safari, Android Chrome, desktop). */
.search-affordance-input::-webkit-search-cancel-button { display: none; }
.search-affordance-input::-webkit-search-decoration    { display: none; }

.search-affordance-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.15rem !important;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}
.search-affordance-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  z-index: 2;
}
.search-affordance-clear:hover   { background: var(--border); color: var(--text); }
.search-affordance-clear:focus-visible {
  outline: 2px solid var(--md-primary, #6366f1);
  outline-offset: 1px;
}
.search-affordance-clear .material-symbols-rounded {
  font-size: 18px;
}

/* ── Skeleton placeholders (B3) ──────────────────────────────────────────── */
/* Used by Pokémon-modal stats while PogoAPI is in-flight. After the load
   resolves, the modal re-renders with real values. */
.pm-skel-line {
  display: block;
  width: 60%;
  height: 1.1em;
  border-radius: 6px;
  background: linear-gradient(90deg,
    var(--surface2) 0%,
    color-mix(in srgb, var(--text) 8%, var(--surface2)) 50%,
    var(--surface2) 100%);
  background-size: 200% 100%;
  animation: pm-skel-shimmer 1.4s ease-in-out infinite;
}
.pm-stat-skel .pm-stat-label { opacity: .6; }
@keyframes pm-skel-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Phone polish */
@media (max-width: 540px) {
  .mega-grid { grid-template-columns: 1fr; }
  .mega-controls .mega-add-btn { padding: 10px 16px; }
  .mega-active-banner { flex-wrap: wrap; }
}

/* ── In-app confirm/prompt dialog ────────────────────────────────────────── */
/* Variant of .settings-sheet — only the dialog-specific size, padding and
   layout overrides live here; background/border come from the shared sheet
   base, and the shadow is slightly softer than the standard settings sheet. */
.app-dialog .app-dialog-sheet {
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.app-dialog-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-dialog-icon {
  font-size: 1.6rem !important;
  color: var(--md-primary, #6366f1);
  flex: 0 0 auto;
}
.app-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.app-dialog-body {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
}
.app-dialog-body strong { color: var(--text); font-weight: 700; }
.app-dialog-hint {
  display: inline-block;
  margin-top: 6px;
  font-size: .78rem;
  color: var(--muted);
  font-style: italic;
}
.app-dialog-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.app-dialog-input:focus {
  border-color: var(--md-primary, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-primary, #6366f1) 20%, transparent);
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.app-dialog-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  min-width: 84px;
}
.app-dialog-btn:hover { background: var(--border); }
.app-dialog-btn:active { transform: scale(.97); }
.app-dialog-btn:focus-visible {
  outline: 2px solid var(--md-primary, #6366f1);
  outline-offset: 2px;
}
.app-dialog-ok {
  background: var(--md-primary, #6366f1);
  border-color: var(--md-primary, #6366f1);
  color: #fff;
}
.app-dialog-ok:hover {
  background: color-mix(in srgb, var(--md-primary, #6366f1) 85%, #000);
  border-color: color-mix(in srgb, var(--md-primary, #6366f1) 85%, #000);
}
/* Tone variants */
.app-dialog-danger .app-dialog-icon { color: #ef4444; }
.app-dialog-ok-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.app-dialog-ok-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}
.app-dialog-warn .app-dialog-icon { color: #f59e0b; }
.app-dialog-ok-warn {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1f1f1f;
}
.app-dialog-ok-warn:hover {
  background: #d97706;
  border-color: #d97706;
  color: #fff;
}

@media (max-width: 540px) {
  .app-dialog .app-dialog-sheet { width: calc(100% - 24px); padding: 18px 18px 16px; }
  .app-dialog-actions { flex-direction: column-reverse; }
  .app-dialog-btn { width: 100%; padding: 12px 16px; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────────
   Honor the OS-level "Reduce motion" preference (vestibular accessibility).
   Slashes any animations and transitions down to effectively-instant rather
   than zeroing them out (some libraries rely on the transition firing once
   to know the layout settled — 0.01ms keeps that signal). Keeps essential
   transforms (opacity for modals, etc.) functional but non-distracting. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
