/* ---------- Theme tokens ---------- */
:root {
  color-scheme: light;
  --surface-page:   #f9f9f7;
  --surface-card:   #fcfcfb;
  --surface-raised: #ffffff;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --border:         rgba(11, 11, 11, 0.10);
  --gridline:       #e1e0d9;
  --accent:         #2a78d6;
  --accent-ink:     #ffffff;

  --slot-1: #2a78d6; /* blue */
  --slot-2: #008300; /* green */
  --slot-3: #e87ba4; /* magenta */
  --slot-4: #eda100; /* yellow */
  --slot-5: #1baf7a; /* aqua */
  --slot-6: #eb6834; /* orange */
  --slot-7: #4a3aa7; /* violet */
  --slot-8: #e34948; /* red */
  --slot-other: #898781; /* neutral, 9th+ team */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-page:   #0d0d0d;
    --surface-card:   #1a1a19;
    --surface-raised: #202020;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --border:         rgba(255, 255, 255, 0.10);
    --gridline:       #2c2c2a;
    --accent:         #3987e5;
    --accent-ink:     #ffffff;

    --slot-1: #3987e5;
    --slot-2: #008300;
    --slot-3: #d55181;
    --slot-4: #c98500;
    --slot-5: #199e70;
    --slot-6: #d95926;
    --slot-7: #9085e9;
    --slot-8: #e66767;
    --slot-other: #898781;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-page:   #0d0d0d;
  --surface-card:   #1a1a19;
  --surface-raised: #202020;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --border:         rgba(255, 255, 255, 0.10);
  --gridline:       #2c2c2a;
  --accent:         #3987e5;
  --accent-ink:     #ffffff;

  --slot-1: #3987e5;
  --slot-2: #008300;
  --slot-3: #d55181;
  --slot-4: #c98500;
  --slot-5: #199e70;
  --slot-6: #d95926;
  --slot-7: #9085e9;
  --slot-8: #e66767;
  --slot-other: #898781;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-card);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 13px; color: var(--text-secondary); }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .theme-toggle .icon-sun { display: none; }
  :root:where(:not([data-theme="light"])) .theme-toggle .icon-moon { display: inline; }
}

/* ---------- Tab bar ---------- */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-card);
  overflow-x: auto;
}

.tab-button {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-button:hover { color: var(--text-primary); }
.tab-button.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ---------- Main / controls ---------- */
.app {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.tab-description {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 14px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.search-input {
  flex: 1 1 240px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 14px;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chip.active {
  color: var(--text-primary);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-raised));
}

/* ---------- Card grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--accent));
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-top { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.card-name { font-size: 15px; font-weight: 600; }

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  flex: 1;
}

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.card-link {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card-link:hover { text-decoration: underline; }

.empty-state, .loading, .error-state {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}
.error-state { color: #e34948; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 14px;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .site-header { padding: 12px 16px; }
  .app { padding: 18px 14px 36px; }
}
