:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #242830;
  --border: #2e333d;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #7c9cff;
  --accent-dim: #5a7ae0;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 10px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding: 1.5rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  background: var(--accent);
  color: #0f1115;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--accent-dim);
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.card-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Controls */
.controls {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  min-width: 160px;
}

/* Table */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(124, 156, 255, 0.04);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}

.rank-1 { background: #fbbf24; color: #0f1115; }
.rank-2 { background: #9ca3af; color: #0f1115; }
.rank-3 { background: #b45309; color: #fff; }
.rank-other { background: var(--surface-2); color: var(--text-muted); }

.episode-title {
  font-weight: 600;
  max-width: 280px;
}

.score {
  font-weight: 700;
  color: var(--accent);
}

.positive { color: var(--green); }
.negative { color: var(--red); }

/* Weights info */
.weights-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.weights-info strong {
  color: var(--text);
}

/* Loading / empty states */
.loading, .empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

@media (max-width: 700px) {
  body { padding: 1rem; }
  h1 { font-size: 1.4rem; }
  .card-value { font-size: 1.35rem; }
  th, td { padding: 0.7rem 0.75rem; }
}

/* Mode toggle */
.mode-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.mode-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #0f1115;
}
