:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-card: #161a23;
  --bg-hover: #1c212d;
  --border: #2a3142;
  --border-subtle: #1e2433;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --text-dim: #5c6578;
  --accent: #6ee7b7;
  --accent-dim: #34d399;
  --accent-bg: rgba(110, 231, 183, 0.08);
  --blue: #60a5fa;
  --purple: #a78bfa;
  --orange: #fb923c;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

.sidebar {
  width: 240px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.logo-mark {
  color: var(--accent);
  font-size: 1.3rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  font-size: 1rem;
  opacity: 0.9;
  width: 1.2rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

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

.small {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
}

#searchInput {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

#searchInput:focus {
  border-color: var(--accent-dim);
}

#searchInput::placeholder {
  color: var(--text-dim);
}

.filters {
  display: flex;
  gap: 0.5rem;
}

.filters select {
  padding: 0.55rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.filters select:focus {
  border-color: var(--accent-dim);
}

.content {
  padding: 1.5rem;
  flex: 1;
}

/* Hero */
.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #e8ecf4 0%, #6ee7b7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  max-width: 560px;
  font-size: 1.05rem;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  margin-top: 0.5rem;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-header .link {
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  background: none;
  border: none;
}

.section-header .link:hover {
  text-decoration: underline;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.15rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.card:hover {
  border-color: var(--border);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

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

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  font-family: var(--mono);
}

.badge-coding { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.badge-productivity { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.badge-token { background: rgba(110, 231, 183, 0.15); color: var(--accent); }
.badge-frontier { background: rgba(251, 146, 60, 0.15); color: var(--orange); }

.scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.score-item {
  text-align: center;
  padding: 0.5rem 0.25rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.score-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.score-value {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
}

.score-value.high { color: var(--accent); }
.score-value.mid { color: var(--yellow); }
.score-value.low { color: var(--text-muted); }

.price-row {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* Provider cards */
.provider-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.provider-card .provider-name {
  font-size: 1.2rem;
  font-weight: 600;
}

.provider-card .provider-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.provider-card .model-count {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

/* Leaderboard table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-card);
}

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

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-hover);
  cursor: pointer;
}

.rank {
  font-family: var(--mono);
  color: var(--text-dim);
  width: 2.5rem;
}

.model-cell {
  font-weight: 500;
}

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: var(--bg-hover);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text);
  background: var(--border);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  padding-right: 2rem;
}

.modal-provider {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.modal-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.spec {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.spec-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.spec-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
}

.modal-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.modal-score {
  text-align: center;
  padding: 1rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.modal-score .score-value {
  font-size: 1.5rem;
  display: block;
  margin: 0.35rem 0 0.55rem;
}

.modal-score .score-caption {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.tab-panel.hidden {
  display: none;
}

.compose-form {
  margin-top: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.15rem;
}

.compose-form h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field-group span {
  font-weight: 600;
  color: var(--text);
}

.field-group input,
.field-group select,
.field-group textarea,
.chat-input-row input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus,
.chat-input-row input:focus {
  border-color: var(--accent-dim);
}

.field-group.full-width {
  grid-column: 1 / -1;
}

.field-group textarea {
  min-height: 110px;
  resize: vertical;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.15rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #071011;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.chat-thread {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.chat-msg {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-meta strong {
  color: var(--text);
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.community-block {
  margin-top: 1.5rem;
}

.empty-inline {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.reviews {
  margin-top: 0.5rem;
}

.reviews h3 {
  font-size: 1rem;
  margin-bottom: 0.85rem;
  font-weight: 600;
}

.review {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--border);
}

.review.token { border-left-color: var(--accent); }
.review.coding { border-left-color: var(--blue); }
.review.productivity { border-left-color: var(--purple); }
.review.integration { border-left-color: var(--orange); }

.review-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.review-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.review p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.55;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1100px) {
  .scores {
    grid-template-columns: repeat(2, 1fr);
  }
  .modal-scores {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 800px) {
  .sidebar {
    display: none;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .search-wrap {
    max-width: none;
    width: 100%;
  }
  .modal-specs,
  .modal-scores {
    grid-template-columns: 1fr;
  }
  .scores {
    grid-template-columns: 1fr;
  }
}
