:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f9;
  --text: #162033;
  --muted: #607089;
  --line: #d8e0ec;
  --accent: #e33535;
  --accent-strong: #b8242f;
  --shadow: 0 20px 50px rgba(37, 51, 77, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141d;
  --surface: #171d29;
  --surface-strong: #202938;
  --text: #eef3fb;
  --muted: #9facbf;
  --line: #2c3749;
  --accent: #ff5a5f;
  --accent-strong: #ff7d6e;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(227, 53, 53, 0.12), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--surface-strong));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.toggle-track {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 180ms ease;
}

:root[data-theme="dark"] .toggle-thumb {
  transform: translateX(18px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 20px;
  align-items: start;
}

.browser-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.browser-panel {
  min-height: 72vh;
  padding: 18px;
}

.search-form {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.search-form label {
  color: var(--muted);
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-row input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

.search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(227, 53, 53, 0.14);
}

.search-row button,
.text-button {
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
}

.search-row button {
  min-width: 96px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
}

.text-button {
  padding: 8px 10px;
  background: transparent;
  color: var(--accent);
}

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  color: var(--muted);
  font-size: 0.95rem;
}

.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.pokemon-card {
  position: relative;
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.pokemon-card:hover,
.pokemon-card.active {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 14px 32px rgba(227, 53, 53, 0.14);
}

.card-number {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
}

.pokemon-card img {
  display: block;
  width: 104px;
  height: 104px;
  object-fit: contain;
  margin: 2px auto 4px;
}

.pokemon-card h3 {
  margin-bottom: 8px;
  font-size: 1.04rem;
}

.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.type-pill {
  --type-bg: var(--surface-strong);
  --type-text: var(--text);
  --type-border: transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid var(--type-border);
  background: var(--type-bg);
  color: var(--type-text);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.16);
}

.type-pill::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.type-normal {
  --type-bg: #a8a77a;
  --type-text: #171a12;
}

.type-fire {
  --type-bg: #ee8130;
  --type-text: #1f1005;
}

.type-water {
  --type-bg: #6390f0;
  --type-text: #07142f;
}

.type-electric {
  --type-bg: #f7d02c;
  --type-text: #211a00;
}

.type-grass {
  --type-bg: #7ac74c;
  --type-text: #092106;
}

.type-ice {
  --type-bg: #96d9d6;
  --type-text: #082221;
}

.type-fighting {
  --type-bg: #c22e28;
  --type-text: #ffffff;
}

.type-poison {
  --type-bg: #a33ea1;
  --type-text: #ffffff;
}

.type-ground {
  --type-bg: #e2bf65;
  --type-text: #251a05;
}

.type-flying {
  --type-bg: #a98ff3;
  --type-text: #180f31;
}

.type-psychic {
  --type-bg: #f95587;
  --type-text: #26040f;
}

.type-bug {
  --type-bg: #a6b91a;
  --type-text: #171b00;
}

.type-rock {
  --type-bg: #b6a136;
  --type-text: #211b04;
}

.type-ghost {
  --type-bg: #735797;
  --type-text: #ffffff;
}

.type-dragon {
  --type-bg: #6f35fc;
  --type-text: #ffffff;
}

.type-dark {
  --type-bg: #705746;
  --type-text: #ffffff;
}

.type-steel {
  --type-bg: #b7b7ce;
  --type-text: #171724;
}

.type-fairy {
  --type-bg: #d685ad;
  --type-text: #2b0616;
}

.type-stellar {
  --type-bg: #35ace7;
  --type-text: #031c28;
}

.type-unknown,
.type-shadow {
  --type-bg: #52606f;
  --type-text: #ffffff;
}

:root[data-theme="dark"] .type-pill {
  --type-border: color-mix(in srgb, var(--type-bg) 80%, white);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 -1px 0 rgba(0, 0, 0, 0.28);
}

.detail-panel {
  position: sticky;
  top: 20px;
  min-height: 620px;
  padding: 22px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 560px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  margin-bottom: 8px;
}

.empty-orb {
  width: 86px;
  height: 86px;
  border: 8px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(var(--accent) 0 48%, var(--text) 48% 54%, var(--surface) 54%);
}

.detail-hero {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}

.detail-hero img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.detail-number {
  color: var(--accent);
  font-weight: 900;
}

.detail-title {
  margin: 2px 0 12px;
  font-size: 2rem;
}

.flavor {
  margin: 18px 0;
  color: var(--muted);
  line-height: 1.55;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.fact {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-strong);
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 4px;
}

.stats {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: 112px 42px 1fr;
  align-items: center;
  gap: 10px;
}

.stat-row span:first-child {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: capitalize;
}

.stat-bar {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(96, 112, 137, 0.16);
}

.stat-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f87171, #ef4444);
  box-shadow: 0 0 14px color-mix(in srgb, currentColor 30%, transparent);
}

.stat-low {
  background: linear-gradient(90deg, #fb7185, #ef4444);
}

.stat-medium {
  background: linear-gradient(90deg, #facc15, #f97316);
}

.stat-high {
  background: linear-gradient(90deg, #34d399, #22c55e);
}

.source-link {
  display: inline-flex;
  margin-top: 20px;
  color: var(--accent);
  font-weight: 800;
}

.status-message {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

@media (max-width: 960px) {
  .app-shell {
    padding: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .topbar,
  .search-row,
  .detail-hero,
  .facts {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .theme-toggle {
    justify-self: start;
  }

  .pokemon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pokemon-card {
    min-height: 176px;
  }

  .pokemon-card img {
    width: 90px;
    height: 90px;
  }

  .stat-row {
    grid-template-columns: 92px 36px 1fr;
  }
}
