:root {
  /* Espionage logo palette */
  --logo-navy: #001b25;
  --logo-navy-2: #031e28;
  --logo-steel: #1d4456;
  --logo-sky: #87b9cd;
  --logo-sky-2: #72adc0;
  --logo-ice: #ddf3fb;

  --ink: #2a2a2a;
  --muted: #6a6f78;
  --line: #d9dde3;
  --soft: #f2f3f5;
  --soft-2: #e9ebee;
  --link: #1d6a87;
  --accent: #1d6a87;
  --shadow: 0 1px 3px rgba(0, 0, 0, .12);
  --max: 1180px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--logo-navy);
  font: 15px/1.55 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  box-shadow: 0 0 40px rgba(0, 0, 0, .35);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: var(--logo-navy-2);
  border-bottom: 3px solid var(--logo-sky);
}
.masthead-brand { display: flex; align-items: center; gap: 12px; }
.masthead-brand, .masthead-brand:hover { text-decoration: none; }
.masthead-logo { width: 38px; height: 38px; }
.home-link { color: var(--logo-ice); font: 700 22px "Segoe UI", Arial, sans-serif; letter-spacing: .5px; }
.home-link:hover { text-decoration: none; color: #fff; }
.dashboard-link { color: #9fc4d2; font-size: 13px; }
.dashboard-link:hover { color: var(--logo-ice); }

main { padding: 26px 30px 50px; }
.loading, .empty { padding: 60px; color: var(--muted); text-align: center; }

.page-title { margin: 6px 0 22px; font: 700 38px Georgia, "Times New Roman", serif; text-align: center; }

.intro {
  margin: 0 0 22px;
  padding: 18px 22px;
  background: var(--soft);
  border-radius: 6px;
  color: #3a3f47;
}
.intro p { margin: 0 0 8px; }
.intro p:last-child { margin: 0; }

/* ---------- List controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
}
.control { display: flex; align-items: center; gap: 9px; }
.control label { font-weight: 600; }
.control input, .control select {
  padding: 8px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9c0c9;
  border-radius: 5px;
  outline: none;
}
.control input { width: 240px; }
.control input:focus, .control select:focus { border-color: #5aa0e0; box-shadow: 0 0 0 2px rgba(90, 160, 224, .2); }
.result-count { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 12px; }

/* ---------- Pokédex table ---------- */
.dex-wrap { overflow-x: auto; }
table.dex {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.dex thead th {
  position: sticky;
  top: 0;
  padding: 11px 10px;
  background: var(--soft-2);
  border-bottom: 2px solid var(--line);
  color: #44484f;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.dex thead th.col-num,
table.dex thead th.col-name,
table.dex thead th.col-type { text-align: left; }
table.dex thead th .arrow { color: #aab0b8; font-size: 10px; margin-left: 4px; }
table.dex thead th.sorted-asc .arrow::after { content: "▲"; color: #555; }
table.dex thead th.sorted-desc .arrow::after { content: "▼"; color: #555; }
table.dex tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #eceef1;
  text-align: right;
  vertical-align: middle;
}
table.dex tbody tr:hover { background: #f7fbff; }
td.col-num { width: 92px; text-align: left; color: var(--muted); white-space: nowrap; }
.sprite { display: inline-block; background-repeat: no-repeat; background-position: 0 0; vertical-align: middle; }
td.col-num .icon { vertical-align: middle; margin-right: 6px; }
td.col-name { text-align: left; }
td.col-name a { font-weight: 700; }
td.col-name .form-name { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
td.col-type { text-align: left; white-space: nowrap; }
td.col-total { font-weight: 700; }

/* ---------- Type badges ---------- */
.type-badge {
  display: inline-block;
  min-width: 64px;
  margin: 1px 0;
  padding: 3px 0;
  color: #fff;
  font: 700 11px "Segoe UI", Arial, sans-serif;
  letter-spacing: .3px;
  text-align: center;
  text-transform: uppercase;
  border-radius: 4px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}
.type-stack .type-badge { display: block; }
.type-badge.small { min-width: 50px; padding: 2px 0; font-size: 10px; }

.type-NORMAL { background: #9099a1; }
.type-FIRE { background: #ff9d55; }
.type-WATER { background: #4d90d5; }
.type-ELECTRIC { background: #f4d23c; text-shadow: none; color: #3a3a1f; }
.type-GRASS { background: #63bc5a; }
.type-ICE { background: #73cec0; }
.type-FIGHTING { background: #ce4069; }
.type-POISON { background: #ab6ac8; }
.type-GROUND { background: #d97746; }
.type-FLYING { background: #8fa9de; }
.type-PSYCHIC { background: #fa7179; }
.type-BUG { background: #90c12c; }
.type-ROCK { background: #c7b78b; }
.type-GHOST { background: #5269ac; }
.type-DRAGON { background: #0b6dc3; }
.type-DARK { background: #5a5366; }
.type-STEEL { background: #5a8ea1; }
.type-FAIRY { background: #ec8fe6; }
.type-QMARKS { background: #6a8a82; }

/* ---------- Detail page ---------- */
.detail-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.detail-title { margin: 2px 0 4px; font: 700 34px Georgia, serif; text-align: center; }
.detail-sub { margin: 0 0 18px; color: var(--muted); text-align: center; }

.form-tabs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 0 0 22px; }
.form-tabs-label { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-right: 2px; }
.form-tab {
  padding: 6px 14px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.form-tab:hover { border-color: var(--accent); }
.form-tab.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.detail-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  margin-bottom: 30px;
}
.detail-art {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--soft);
  border-radius: 8px;
}
.detail-art .sprite { margin: 0 auto; }

h2.section {
  margin: 34px 0 14px;
  padding-bottom: 7px;
  font: 700 22px Georgia, serif;
  border-bottom: 2px solid var(--line);
}
h3.block { margin: 0 0 10px; font: 700 17px Georgia, serif; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 7px 6px; border-bottom: 1px solid #edeff2; text-align: left; vertical-align: top; }
table.data th { width: 38%; color: #50555c; font-weight: 600; }
.placeholder { color: #9aa0a8; font-style: italic; }
.note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- Stats ---------- */
.stat-row { display: grid; grid-template-columns: 92px 42px 1fr 124px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: 14px; }
.stat-row .stat-label { color: #50555c; font-weight: 600; }
.stat-row .stat-value { font-weight: 700; text-align: right; }
.stat-bar { height: 13px; background: #edeff2; border-radius: 7px; overflow: hidden; }
.stat-fill { display: block; height: 100%; border-radius: 7px; }
.stat-range { color: var(--muted); font-size: 12px; text-align: right; }
.stat-total { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 700; }

/* ---------- Type defenses ---------- */
.type-def-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.type-def {
  width: 58px;
  text-align: center;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #e3e5e9;
}
.type-def .t { padding: 3px 0; color: #fff; font: 700 10px Arial; text-transform: uppercase; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.type-def .m { padding: 3px 0; font: 700 12px Arial; background: #fff; }
.type-def .m.mult-0 { background: #4b4b4b; color: #fff; }
.type-def .m.mult-25 { background: #1d7a3a; color: #fff; }
.type-def .m.mult-50 { background: #5fb96f; color: #fff; }
.type-def .m.mult-1 { background: #fff; color: #888; }
.type-def .m.mult-2 { background: #f0a23c; color: #fff; }
.type-def .m.mult-4 { background: #d3502a; color: #fff; }

/* ---------- Evolution ---------- */
.evo-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.evo-stage { display: flex; flex-direction: column; align-items: center; width: 130px; text-align: center; }
.evo-stage .sprite { margin: 0 auto; }
.evo-stage .evo-name { font-weight: 700; }
.evo-stage .evo-types { display: flex; gap: 3px; justify-content: center; margin-top: 3px; }
.evo-arrow { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 12px; min-width: 84px; }
.evo-arrow .a { font-size: 20px; line-height: 1; }
.evo-branches { display: flex; flex-direction: column; gap: 12px; }
.evo-branch { display: flex; align-items: center; gap: 6px; }

/* ---------- Moves ---------- */
.moves-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; }
table.moves { width: 100%; border-collapse: collapse; font-size: 13px; }
table.moves th, table.moves td { padding: 6px 7px; border-bottom: 1px solid #edeff2; text-align: right; white-space: nowrap; }
table.moves th { background: var(--soft-2); color: #44484f; text-align: right; }
table.moves th.l, table.moves td.l { text-align: left; }
table.moves td.move-name { font-weight: 600; }
.cat-badge { display: inline-block; min-width: 56px; padding: 2px 6px; color: #fff; font: 700 10px Arial; text-align: center; border-radius: 3px; text-transform: uppercase; }
.cat-Physical { background: #c0392b; }
.cat-Special { background: #2e6da4; }
.cat-Status { background: #8a8f97; }

/* ---------- Forms ---------- */
.forms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.form-card { padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.form-card .form-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-card .form-head .sprite { flex: 0 0 auto; }
.form-card h3 { margin: 0; font: 700 16px Georgia, serif; }
.form-card .form-types { display: flex; gap: 4px; margin-top: 4px; }
.form-card table.data th { width: 46%; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .moves-columns { grid-template-columns: 1fr; }
  .control input { width: 180px; }
}

/* ---------- QoL: theme toggle ---------- */
.dex-theme {
  padding: 8px 14px;
  color: var(--logo-ice);
  background: var(--logo-steel);
  border: 1px solid var(--logo-sky-2);
  border-radius: 5px;
  cursor: pointer;
  font: 600 13px "Segoe UI", Arial, sans-serif;
}
.dex-theme:hover { background: var(--logo-sky-2); color: #04222c; }

/* ---------- QoL: comparison ---------- */
.cmp-toggle {
  margin-left: 8px;
  padding: 1px 7px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
}
.cmp-toggle:hover { border-color: var(--accent); color: var(--accent); }
.cmp-toggle.active { color: #fff; background: var(--accent); border-color: var(--accent); }

#compare-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(92vw, 1000px);
  padding: 10px 14px;
  color: var(--logo-ice);
  background: var(--logo-navy-2);
  border: 1px solid var(--logo-sky-2);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
}
.cmp-chips { display: flex; flex-wrap: wrap; gap: 7px; overflow: hidden; }
.cmp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 11px;
  background: var(--logo-steel);
  border-radius: 999px;
  font-size: 12px;
}
.cmp-chip button { border: 0; background: none; color: #cfe6ef; cursor: pointer; font-size: 12px; padding: 0 2px; }
.cmp-chip button:hover { color: #fff; }
.cmp-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.cmp-go {
  padding: 7px 15px;
  color: #04222c;
  background: var(--logo-sky);
  border-radius: 8px;
  font-weight: 700;
}
.cmp-go:hover { background: #a7d2e3; text-decoration: none; }
.cmp-clear { padding: 7px 12px; color: var(--logo-ice); background: transparent; border: 1px solid var(--logo-steel); border-radius: 8px; cursor: pointer; }
.cmp-clear:hover { border-color: var(--logo-sky); }

.cmp-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.cmp-table th, .cmp-table td { padding: 11px 12px; border: 1px solid var(--line); text-align: center; }
.cmp-table thead th { background: var(--soft); vertical-align: bottom; }
.cmp-table thead .sprite { margin: 0 auto; }
.cmp-name { display: block; margin: 4px 0 6px; font: 700 15px Georgia, serif; }
.cmp-table tbody th { text-align: left; background: var(--soft); width: 110px; }
.cmp-cell { min-width: 120px; }
.cmp-bar { display: block; height: 7px; margin-bottom: 4px; background: var(--soft-2); border-radius: 6px; overflow: hidden; }
.cmp-bar span { display: block; height: 100%; border-radius: 6px; }
.cmp-num { font-weight: 600; }
.cmp-cell.best, .cmp-total td.best { background: rgba(35, 205, 94, .16); outline: 2px solid #1f9d52; }
.cmp-cell.best .cmp-num, .cmp-total td.best { font-weight: 800; }

/* compare: section headers, abilities, type defenses, detail button */
.cmp-section td { text-align: left; background: var(--soft-2); font: 700 13px "Segoe UI", Arial, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cmp-section-note { font-weight: 400; text-transform: none; letter-spacing: 0; }
.cmp-abil { min-width: 120px; font-size: 13px; }
.cmp-hidden { margin-top: 4px; color: var(--muted); font-size: 12px; }
.cmp-deftype { text-align: center !important; width: 90px; }
.cmp-deftype .type-badge { display: inline-block; }
.cmp-def { min-width: 90px; }
.cmp-mult { display: inline-block; min-width: 40px; padding: 3px 8px; border-radius: 5px; font: 700 13px Arial; background: #fff; color: #888; }
.cmp-mult.mult-0 { background: #4b4b4b; color: #fff; }
.cmp-mult.mult-25 { background: #1d7a3a; color: #fff; }
.cmp-mult.mult-50 { background: #5fb96f; color: #fff; }
.cmp-mult.mult-1 { background: #eef0f2; color: #555; }
.cmp-mult.mult-2 { background: #f0a23c; color: #fff; }
.cmp-mult.mult-4 { background: #d3502a; color: #fff; }
.cmp-def.best { background: rgba(35, 205, 94, .16); outline: 2px solid #1f9d52; }

.detail-art { flex-direction: column; gap: 12px; }
.cmp-toggle-big {
  padding: 7px 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font: 600 13px "Segoe UI", Arial, sans-serif;
}
.cmp-toggle-big:hover { border-color: var(--accent); color: var(--accent); }
.cmp-toggle-big.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ---------- Dark theme (synced with Command Board) ---------- */
:root[data-theme="dark"] {
  --ink: #e6f4fb;
  --muted: #8aa9b6;
  --line: #1d4456;
  --soft: #0c2f3d;
  --soft-2: #11384a;
  --link: #87b9cd;
  --accent: #87b9cd;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] body { background: #00141c; }
:root[data-theme="dark"] .page { background: #052531; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .control input,
:root[data-theme="dark"] .control select { color: var(--ink); background: #04181f; border-color: #1d4456; }
:root[data-theme="dark"] .cmp-toggle { background: #04181f; }
:root[data-theme="dark"] .cmp-toggle.active { color: #04222c; }
:root[data-theme="dark"] .cmp-toggle-big { background: #04181f; }
:root[data-theme="dark"] .cmp-toggle-big.active { color: #04222c; }
:root[data-theme="dark"] .cmp-mult.mult-1 { background: #11384a; color: #cfe0e8; }
:root[data-theme="dark"] .dex th { background: #0c2f3d; }
:root[data-theme="dark"] .dex tbody tr:nth-child(even) { background: rgba(135, 185, 205, .05); }
:root[data-theme="dark"] .form-card,
:root[data-theme="dark"] .cmp-table thead th,
:root[data-theme="dark"] .cmp-table tbody th { background: #0c2f3d; }
:root[data-theme="dark"] table.data th { background: #0c2f3d; }

/* Plain text / borders that were hardcoded light — make them readable on dark */
:root[data-theme="dark"] .intro { color: var(--ink); }
:root[data-theme="dark"] table.dex thead th { color: var(--ink); }
:root[data-theme="dark"] table.dex thead th .arrow,
:root[data-theme="dark"] table.dex thead th.sorted-asc .arrow::after,
:root[data-theme="dark"] table.dex thead th.sorted-desc .arrow::after { color: var(--logo-sky); }
:root[data-theme="dark"] table.dex tbody td { border-bottom-color: var(--line); }
:root[data-theme="dark"] table.dex tbody tr:hover { background: #16465c; }
:root[data-theme="dark"] table.data th { color: var(--ink); }
:root[data-theme="dark"] table.data th,
:root[data-theme="dark"] table.data td { border-bottom-color: var(--line); }
:root[data-theme="dark"] .placeholder { color: #7f95a0; }
:root[data-theme="dark"] .stat-row .stat-label { color: var(--ink); }
:root[data-theme="dark"] .stat-bar { background: #11384a; }
:root[data-theme="dark"] table.moves th,
:root[data-theme="dark"] table.moves td { border-bottom-color: var(--line); }
:root[data-theme="dark"] table.moves th { color: var(--ink); background: #0c2f3d; }
:root[data-theme="dark"] .type-def { border-color: var(--line); }
:root[data-theme="dark"] .type-def .m.mult-1 { background: #11384a; color: #cfe0e8; }

/* ===== Promo card button + toast ===== */
.pdx-card-btn {
  margin-left: 10px;
  padding: 2px 10px;
  color: var(--accent);
  background: var(--soft);
  border: 1px solid var(--accent);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.pdx-card-btn:hover { color: #fff; background: var(--accent); }
.pdx-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #06222e; border: 1px solid #46e8e0; color: #ddf3fb;
  font-family: "Consolas", monospace; font-size: 13px; padding: 10px 18px; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 0 20px rgba(70, 232, 224, 0.25);
}
.pdx-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Showcase mode (clean public view) ===== */
.dex-showcase-toggle {
  background: transparent; color: #9fc4d2; border: 1px solid var(--logo-sky);
  border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer;
  font-family: "Consolas", monospace; letter-spacing: .04em;
}
.dex-showcase-toggle:hover { color: var(--logo-ice); border-color: var(--logo-ice); }
.dex-showcase-toggle[aria-pressed="true"] { color: #46e8e0; border-color: #46e8e0; }
body.showcase .dev-only { display: none !important; }
body.showcase .espio-fab, body.showcase .espio-panel { display: none !important; }

/* New / custom content badges in the list */
.new-badge { display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 3px; margin-left: 5px; vertical-align: middle; border: 1px solid currentColor; line-height: 1.5; }
.nb-New { color: #b8901a; }
.nb-Theta { color: #a640bd; }
.nb-Mega { color: #1c9c95; }
.nb-Regional { color: #3f78d0; }
[data-theme="dark"] .nb-New { color: #d1b235; }
[data-theme="dark"] .nb-Theta { color: #d07be0; }
[data-theme="dark"] .nb-Mega { color: #46e8e0; }
[data-theme="dark"] .nb-Regional { color: #7fb3ff; }
