:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-card: #171b24;
  --bg-hover: #1e2430;
  --border: #2a3140;
  --text: #e8ecf4;
  --text-muted: #9aa3b5;
  --accent: #6ea8ff;
  --accent-2: #8b9cff;
  --crystal: #56c7ff;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --radius: 12px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef2f8;
  --border: #d5dbe8;
  --text: #151922;
  --text-muted: #5b657a;
  --accent: #2f6fed;
  --accent-2: #4b5fd6;
  --crystal: #0a7ea4;
  --shadow: 0 8px 24px rgba(30, 40, 70, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 20;
}
.sidebar.collapsed { display: none; }

.brand { padding: 1rem 1rem 0.75rem; border-bottom: 1px solid var(--border); }
.brand-link { display: flex; gap: 0.75rem; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2a4a7a, #163054);
  color: #dff4ff; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid #3d6aa0;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--text-muted); font-size: 0.75rem; }

.nav { padding: 0.75rem 0.65rem 2rem; }
.nav-group { margin-bottom: 1.1rem; }
.nav-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 0.25rem 0.6rem; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.65rem; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 0.92rem;
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-item.active { background: var(--bg-hover); color: var(--crystal); font-weight: 600; }
.nav-item.active-game { background: rgba(86, 199, 255, 0.08); color: var(--crystal); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--crystal); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 15;
}
.icon-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
}
.game-chip {
  font-size: 0.8rem; color: var(--text-muted); white-space: nowrap;
}
.game-chip strong { color: var(--text); }
.search-wrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search-wrap input {
  width: 100%; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  padding: 0 1rem;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; z-index: 30;
}
.search-hit {
  display: flex; gap: 0.65rem; align-items: center;
  padding: 0.55rem 0.75rem; color: inherit; text-decoration: none; border-bottom: 1px solid var(--border);
}
.search-hit:hover { background: var(--bg-hover); text-decoration: none; }
.search-hit .kind { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; width: 64px; }
.search-hit img { width: 28px; height: 28px; image-rendering: pixelated; }

.content { flex: 1; padding: 1.25rem 1.5rem 3rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.loading, .empty { color: var(--text-muted); padding: 2rem 0; }

.hero {
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.hero h1 { margin: 0 0 0.4rem; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--text-muted); max-width: 50rem; }
.hero-banner {
  height: 72px; border-radius: var(--radius); margin-bottom: 1rem;
  background:
    linear-gradient(90deg, rgba(22,48,84,0.95), rgba(40,70,120,0.4)),
    repeating-linear-gradient(90deg, #1a3048 0 12px, #16304a 12px 24px);
  border: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem;
  color: #cfe9ff; font-weight: 600;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: inherit; text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; background: var(--bg-hover); }
.card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.stat-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.stat-pill {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.85rem;
}
.stat-pill strong { color: var(--crystal); }

.toolbar {
  display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center;
  margin-bottom: 1rem;
}
.toolbar input, .toolbar select {
  height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); padding: 0 0.75rem;
}
.toolbar input { min-width: min(100%, 280px); flex: 1; }
.count { color: var(--text-muted); font-size: 0.85rem; margin-left: auto; }

.poke-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.poke-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem; text-align: center;
  color: inherit; text-decoration: none;
}
.poke-card:hover { border-color: var(--accent); text-decoration: none; background: var(--bg-hover); }
.poke-card img {
  width: 72px; height: 72px; image-rendering: pixelated; object-fit: contain;
}
.poke-card .num { color: var(--text-muted); font-family: var(--mono); font-size: 0.75rem; }
.poke-card .name { font-weight: 600; margin: 0.25rem 0 0.45rem; }

.type {
  display: inline-block; min-width: 4.2rem; text-align: center;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; border-radius: 999px; padding: 0.18rem 0.5rem;
  color: #fff; margin: 0 0.12rem;
}
.type.Normal { background: #a8a878; } .type.Fire { background: #f08030; }
.type.Water { background: #6890f0; } .type.Electric { background: #f8d030; color: #333; }
.type.Grass { background: #78c850; } .type.Ice { background: #98d8d8; color: #333; }
.type.Fighting { background: #c03028; } .type.Poison { background: #a040a0; }
.type.Ground { background: #e0c068; color: #333; } .type.Flying { background: #a890f0; }
.type.Psychic { background: #f85888; } .type.Bug { background: #a8b820; }
.type.Rock { background: #b8a038; } .type.Ghost { background: #705898; }
.type.Dragon { background: #7038f8; } .type.Dark { background: #705848; }
.type.Steel { background: #b8b8d0; color: #333; } .type.Fairy { background: #ee99ac; color: #333; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--bg-card);
}
table.data th, table.data td {
  padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left;
}
table.data th { background: var(--bg-elevated); color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; }
table.data tr:hover td { background: var(--bg-hover); }
table.data a { color: inherit; font-weight: 600; }

.detail-header {
  display: grid; grid-template-columns: 120px 1fr; gap: 1.25rem; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; margin-bottom: 1rem;
}
.detail-header img { width: 112px; height: 112px; image-rendering: pixelated; }
.detail-header h1 { margin: 0 0 0.35rem; }
.bars { display: grid; gap: 0.4rem; margin-top: 0.75rem; }
.bar-row { display: grid; grid-template-columns: 72px 36px 1fr; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.bar {
  height: 8px; border-radius: 999px; background: var(--border); overflow: hidden;
}
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--crystal)); }

.type-chart { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.type-chart table { border-collapse: collapse; font-size: 0.72rem; }
.type-chart th, .type-chart td {
  width: 34px; height: 34px; text-align: center; border: 1px solid var(--border);
}
.type-chart .m2 { background: #2f6b3a; color: #fff; font-weight: 700; }
.type-chart .m05 { background: #6b3a2f; color: #fff; }
.type-chart .m0 { background: #333; color: #aaa; }
.type-chart .m1 { color: var(--text-muted); }

.section { margin: 1.5rem 0; }
.section h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.muted { color: var(--text-muted); }
.footer {
  border-top: 1px solid var(--border); padding: 1rem 1.5rem; color: var(--text-muted); font-size: 0.82rem;
}
.footer a { color: var(--accent); }

@media (max-width: 860px) {
  .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .detail-header { grid-template-columns: 1fr; text-align: center; }
}
