:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f5f7;
  color: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #14161a;
    color: #eaeaea;
  }
}

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

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #d21e34;
  color: white;
}

.navbar a,
.navbar .brand {
  color: white;
  text-decoration: none;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.navbar button {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.app-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar,
.sync-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input,
.search-bar select,
.sync-form input,
.sync-form select {
  flex: 1;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #ccc;
}

button {
  border-radius: 6px;
  border: none;
  background: #d21e34;
  color: white;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.card-tile {
  text-decoration: none;
  color: inherit;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

@media (prefers-color-scheme: dark) {
  .card-tile {
    background: #21242b;
  }
}

.card-tile-media {
  position: relative;
}

.card-tile img {
  width: 100%;
  display: block;
}

.card-tile-placeholder {
  padding: 2rem 0.5rem;
  text-align: center;
  background: #eee;
}

.owned-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: #1f9d55;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card-tile-info {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
}

.rarity {
  color: #d21e34;
  font-weight: 600;
}

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
}

.auth-page,
.sync-page {
  max-width: 420px;
}

.sync-page {
  max-width: 640px;
}

.sync-section {
  margin-bottom: 2rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  .sync-section {
    background: #21242b;
  }
}

.set-checklist-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.set-checklist-controls button {
  background: transparent;
  color: #d21e34;
  border: 1px solid #d21e34;
  padding: 0.3rem 0.75rem;
}

.set-checklist {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  .set-checklist {
    border-color: #383835;
  }
}

.set-checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

.set-checklist-item input {
  flex-shrink: 0;
}

.auth-form label,
.add-to-collection-form label {
  display: block;
  margin-bottom: 0.75rem;
}

.auth-form input,
.add-to-collection-form input,
.add-to-collection-form select {
  display: block;
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.error-text {
  color: #d21e34;
  font-weight: 600;
}

.status-text {
  color: #666;
}

.card-detail-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  margin-top: 1rem;
}

.card-detail-image {
  width: 100%;
  border-radius: 8px;
}

.species-artwork {
  max-width: 150px;
}

.attack {
  margin-bottom: 0.5rem;
}

.community-stats,
.my-copies {
  margin-top: 1.5rem;
}

.community-stats ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.my-copies .collection-table {
  margin-top: 0.5rem;
}

.add-to-collection-form {
  margin-top: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  max-width: 320px;
}

@media (prefers-color-scheme: dark) {
  .add-to-collection-form {
    background: #21242b;
  }
}

.collection-table {
  width: 100%;
  border-collapse: collapse;
}

.collection-table th,
.collection-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
}

.collection-card-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.collection-card-link img {
  width: 40px;
  border-radius: 4px;
}

.collection-table input[type='number'] {
  width: 60px;
}

.visually-hidden {
  display: none;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.admin-tabs button {
  background: transparent;
  color: #d21e34;
  border: 1px solid #d21e34;
}

.admin-tabs button.active {
  background: #d21e34;
  color: white;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #ddd;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: #d21e34;
  transition: width 0.3s ease;
}

.sync-job-status {
  margin-top: 1rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.add-user-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.add-user-form input,
.add-user-form select {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.collection-table select,
.collection-table input[type='text'],
.collection-table input[type='email'] {
  padding: 0.3rem;
  border-radius: 4px;
  border: 1px solid #ccc;
}

@media (max-width: 700px) {
  .card-detail-grid {
    grid-template-columns: 1fr;
  }
}

.landing-page {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.landing-hero {
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #d21e34, #a3152a);
  color: white;
}

.landing-hero h1 {
  margin: 0.5rem 0;
  font-size: 2rem;
}

.landing-hero p {
  max-width: 520px;
  margin: 0 auto;
  opacity: 0.9;
}

.landing-hero-graphic {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.pokeball {
  display: inline-block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(to bottom, white 0%, white 46%, #1a1a1a 46%, #1a1a1a 54%, #d21e34 54%, #d21e34 100%);
  border: 3px solid white;
  box-shadow: 0 0 0 2px #1a1a1a;
  position: relative;
}

.pokeball::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 3px solid #1a1a1a;
  transform: translate(-50%, -50%);
}

.landing-cta {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.landing-cta-button {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  background: white;
  color: #d21e34;
  text-decoration: none;
  font-weight: 600;
}

.landing-cta-button.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.landing-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.stat-tile {
  background: white;
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-tile strong {
  font-size: 2rem;
  color: #d21e34;
}

.stat-tile span {
  color: #666;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .stat-tile {
    background: #21242b;
  }
  .stat-tile span {
    color: #aaa;
  }
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.feature-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
}

.feature-card h3 {
  margin-top: 0;
  color: #d21e34;
}

@media (prefers-color-scheme: dark) {
  .feature-card {
    background: #21242b;
  }
}

.status-text a,
.error-text a {
  color: inherit;
}

/* Collection stats: KPI tiles, coverage meters, magnitude bar charts.
   Sequential blue - single hue, more-is-darker - for meters/bars, kept
   separate from the app's red UI accent (data color vs chrome color). */
.collection-stats {
  --stat-fill: #2a78d6;
  --stat-fill-track: #cde2fb;
  margin-bottom: 2rem;
}

@media (prefers-color-scheme: dark) {
  .collection-stats {
    --stat-fill: #3987e5;
    --stat-fill-track: rgba(57, 135, 229, 0.25);
  }
}

.collection-stats h2 {
  margin-bottom: 0.75rem;
}

.stat-tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.meter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meter-tile {
  background: white;
  border-radius: 12px;
  padding: 1rem;
}

@media (prefers-color-scheme: dark) {
  .meter-tile {
    background: #21242b;
  }
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.meter-label .meter-value {
  color: #666;
}

@media (prefers-color-scheme: dark) {
  .meter-label .meter-value {
    color: #aaa;
  }
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  background: var(--stat-fill-track);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--stat-fill);
  border-radius: 999px;
}

.bar-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.bar-chart {
  background: white;
  border-radius: 12px;
  padding: 1rem;
}

@media (prefers-color-scheme: dark) {
  .bar-chart {
    background: #21242b;
  }
}

.bar-chart h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hbar-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.hbar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-track {
  display: block;
  height: 14px;
  border-radius: 4px;
  background: var(--stat-fill-track);
  overflow: hidden;
}

.hbar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--stat-fill);
  border-radius: 0 4px 4px 0;
}

.hbar-value {
  text-align: right;
  color: #666;
}

@media (prefers-color-scheme: dark) {
  .hbar-value {
    color: #aaa;
  }
}
