:root {
  --bg: #0d0d0f;
  --bg-elevated: #17171b;
  --bg-card: #1b1b20;
  --bg-card-hover: #232329;
  --border: #2a2a31;
  --text: #f5f5f7;
  --text-dim: #9b9ba3;
  --text-dimmer: #6b6b74;
  --accent: #e63946;
  --accent-dark: #b3202c;
  --accent-grad: linear-gradient(135deg, #ef4444 0%, #7f1d1d 100%);
  --radius: 14px;
  --radius-sm: 8px;
  --stat-bar-bg: #2a2a31;
  --green: #4ade80;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f3;
  --border: #e2e2e7;
  --text: #17171b;
  --text-dim: #55555e;
  --text-dimmer: #8a8a93;
  --stat-bar-bg: #e2e2e7;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13,13,15,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] .site-header { background: rgba(255,255,255,0.9); }
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; white-space: nowrap; }
.brand-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(180deg, #fff 50%, var(--accent) 50%);
  border: 2px solid #222;
  flex-shrink: 0;
}
.header-actions { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px; max-width: 320px; width: 100%;
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text);
  width: 100%; font-size: 14px;
}
.search-box input::placeholder { color: var(--text-dimmer); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-card-hover); }
.lang-btn {
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); padding: 0 14px; height: 38px; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.lang-switch {
  display: flex; align-items: center; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); height: 38px; padding: 3px; flex-shrink: 0;
}
.lang-switch-btn {
  border: none; background: transparent; color: var(--text-dim); font-weight: 700; font-size: 12px;
  padding: 0 12px; height: 100%; border-radius: 999px;
}
.lang-switch-btn.active { background: var(--accent); color: #fff; }

/* Nav drawer */
.nav-drawer {
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0; background: var(--bg);
  height: calc(100vh - 64px);
  z-index: 40; overflow-y: auto; padding: 20px;
  display: none;
}
.nav-drawer.open { display: block; }
.nav-drawer-container { max-width: 1180px; margin: 0 auto; }
.nav-drawer .search-box { max-width: none; margin-bottom: 20px; }
.nav-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 40px;
  max-width: 640px;
}
.nav-grid a { padding: 12px 4px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--border); }

/* ---------- Hero ---------- */
.hero {
  background: var(--accent-grad);
  border-radius: var(--radius);
  padding: 48px 40px;
  margin: 24px 0 40px;
  position: relative; overflow: hidden;
  color: #fff;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.15); padding: 6px 14px; border-radius: 999px;
  font-size: 13px; margin-bottom: 16px;
}
.hero h1 { font-size: 48px; margin: 0 0 12px; font-weight: 900; }
.hero p { font-size: 16px; max-width: 480px; opacity: 0.92; margin: 0 0 24px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 14px;
  border: none;
}
.btn-white { background: #fff; color: #b3202c; }
.btn-ghost { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.hero-art {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  width: 220px; height: 220px; object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

/* ---------- Sections ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { font-size: 24px; margin: 0 0 2px; font-weight: 800; }
.section-head .sub { color: var(--text-dim); font-size: 14px; margin: 0; }
.section-head .view-all { color: var(--accent); font-weight: 700; font-size: 14px; white-space: nowrap; }

.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.category-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 12px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.category-card:hover { background: var(--bg-card-hover); }
.category-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff;
}
.category-card .label { font-weight: 700; font-size: 14px; }

.type-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip {
  padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 12px;
  letter-spacing: 0.03em; color: #1b1b20;
}

/* ---------- Pokemon cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.poke-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; position: relative; transition: transform .15s ease, background .15s ease;
  display: block;
}
.poke-card:hover { background: var(--bg-card-hover); transform: translateY(-2px); }
.poke-card .fav-btn {
  position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,0.3); border: none;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.poke-card .fav-btn.active { color: var(--accent); }
.poke-card img { width: 100%; height: 110px; object-fit: contain; margin-bottom: 6px; }
.poke-card .num-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dimmer); margin-bottom: 2px; }
.poke-card .name { font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.poke-card .types { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.poke-card .goto { font-size: 13px; color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.type-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800;
  color: #1b1b20; letter-spacing: 0.02em;
}

/* ---------- Regions ---------- */
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.region-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.region-card h3 { margin: 0 0 2px; font-size: 18px; }
.region-card .gen-tag { color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 8px; display:block; }
.region-card p { color: var(--text-dim); font-size: 13px; margin: 0; }

/* ---------- Pokedex list page ---------- */
.page-title { font-size: 34px; font-weight: 900; margin: 24px 0 4px; }
.page-sub { color: var(--text-dim); margin: 0 0 20px; }
.search-box.wide { max-width: none; margin-bottom: 20px; }
.filters-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 24px;
}
.filters-panel .filters-label { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip-row:last-child { margin-bottom: 0; }
.filter-chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
}
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-chip.type-filter.active { color: #1b1b20; }

/* ---------- Detail page ---------- */
.detail-back-row { display: flex; justify-content: space-between; align-items: center; margin: 20px 0; }
.detail-hero {
  background: linear-gradient(135deg, #24242c, #101013);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; display: flex; gap: 24px; align-items: center;
  position: relative; overflow: hidden; margin-bottom: 20px;
  color: #f5f5f7;
}
.detail-hero .big-num {
  position: absolute; right: 24px; top: 10px; font-size: 64px; font-weight: 900;
  color: rgba(255,255,255,0.08); user-select: none;
}
.detail-hero img { width: 160px; height: 160px; object-fit: contain; flex-shrink: 0; }
.detail-hero .info { flex: 1; min-width: 0; }
.detail-hero .dex-num { color: #b8b8c0; font-weight: 700; margin-right: 8px; }
.detail-hero h1 { font-size: 32px; margin: 4px 0 10px; display:inline-flex; align-items:center; gap:10px; color: #f5f5f7; }
.detail-hero .types { display: flex; gap: 8px; margin-bottom: 14px; }
.detail-hero .flavor-preview { max-width: 560px; color: #c7c7cf; font-size: 14px; margin-bottom: 10px; }
.detail-hero .meta-row { display: flex; gap: 20px; font-size: 13px; color: #c7c7cf; flex-wrap: wrap; }
.heart-toggle { background: none; border: none; color: #c7c7cf; font-size: 18px; }
.heart-toggle.active { color: var(--accent); }

.tab-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn {
  padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
}
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.tab-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}
.tab-panel h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; }

.story-box { display: flex; gap: 14px; align-items: center; background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px; }
.story-box img { width: 56px; height: 56px; object-fit: contain; }
.story-box .sname { font-weight: 800; }
.story-box .sgenus { font-size: 12px; color: var(--text-dim); }
.story-text { font-size: 15px; line-height: 1.6; margin-bottom: 16px; }
.notice { font-size: 12px; color: var(--text-dimmer); font-style: italic; margin-bottom: 10px; }
.story-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.voice-label { display: flex; align-items: center; gap: 6px; color: var(--text-dimmer); font-size: 12px; font-weight: 700; letter-spacing: .04em; }

.stat-row { display: grid; grid-template-columns: 80px 1fr 40px; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.stat-row .label { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 11px; }
.stat-track { height: 8px; border-radius: 999px; background: var(--stat-bar-bg); overflow: hidden; }
.stat-fill { height: 100%; border-radius: 999px; }
.stat-row .value { text-align: right; font-weight: 700; }
.stat-row.total .value, .stat-row.total .label { color: var(--text); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-item .l { font-size: 12px; color: var(--text-dimmer); text-transform: uppercase; margin-bottom: 4px; }
.info-item .v { font-weight: 700; }

.effect-group { margin-bottom: 18px; }
.effect-group .gt { font-weight: 700; margin-bottom: 8px; font-size: 13px; }
.effect-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.mult-badge { display:inline-flex; align-items:center; gap:6px; background: var(--bg-elevated); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700;}
.mult-badge .x { color: var(--text-dimmer); }

.ability-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.ability-item:last-child { border-bottom: none; }
.ability-item .an { font-weight: 800; display: flex; gap: 8px; align-items: center; }
.hidden-tag { font-size: 10px; background: var(--bg-elevated); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; color: var(--text-dim); }
.ability-item .ae { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.evo-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.evo-node { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 12px; text-align: center; width: 110px; }
.evo-node img { width: 72px; height: 72px; object-fit: contain; margin: 0 auto; }
.evo-node .n { font-size: 12px; font-weight: 700; margin-top: 4px; }
.evo-node.current { outline: 2px solid var(--accent); }
.evo-arrow { display: flex; flex-direction: column; align-items: center; color: var(--text-dimmer); font-size: 11px; gap: 2px; min-width: 70px; text-align:center; }

.moves-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.moves-table th { text-align: left; color: var(--text-dimmer); font-size: 11px; text-transform: uppercase; padding: 8px; border-bottom: 1px solid var(--border); }
.moves-table td { padding: 8px; border-bottom: 1px solid var(--border); }

.game-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.game-pill { background: var(--bg-elevated); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700; border: 1px solid var(--border); }

/* ---------- Compare page ---------- */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 640px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-slot {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; min-height: 220px; position: relative;
}
.compare-slot img { width: 120px; height: 120px; object-fit: contain; margin: 0 auto 8px; }
.compare-slot .num { color: var(--text-dimmer); font-size: 12px; }
.compare-slot h3 { margin: 4px 0 8px; }
.compare-slot .search-toggle {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
}
.compare-slot .picker-empty { color: var(--text-dimmer); padding: 40px 0; }
.compare-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.compare-table td, .compare-table th { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.compare-table th { text-align: left; color: var(--text-dimmer); text-transform: uppercase; font-size: 11px; width: 30%; }
.compare-table td { text-align: center; font-weight: 700; }
.compare-table td.win { color: var(--green); }
.picker-panel {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
}
.picker-box { background: var(--bg-elevated); border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 80vh; overflow: auto; padding: 16px; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.picker-row:hover { background: var(--bg-card-hover); }
.picker-row img { width: 36px; height: 36px; object-fit: contain; }

/* ---------- Favorites / generic list ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }

/* ---------- Trios ---------- */
.trio-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.trio-card h3 { margin: 0 0 12px; }
.trio-members { display: flex; gap: 14px; flex-wrap: wrap; }
.trio-member { text-align: center; width: 90px; }
.trio-member img { width: 64px; height: 64px; object-fit: contain; margin: 0 auto; }
.trio-member .n { font-size: 12px; font-weight: 700; margin-top: 4px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 32px 0; text-align: center; color: var(--text-dimmer); font-size: 12px; }
.site-footer p { margin: 4px 0; }
.site-footer strong { color: var(--text-dim); }

/* ---------- Loading / misc ---------- */
.loading-spinner { text-align: center; padding: 60px 0; color: var(--text-dimmer); }

@media (max-width: 720px) {
  .hero { padding: 32px 20px; }
  .hero h1 { font-size: 32px; }
  .hero-art { display: none; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-grid { grid-template-columns: 1fr; gap: 0; }
  .detail-hero { flex-direction: column; text-align: center; }
  .detail-hero .meta-row { justify-content: center; }
}
