:root {
  --bg: #0b1020;
  --panel: #121a33;
  --text: #e9eeff;
  --muted: rgba(233, 238, 255, 0.7);
  --border: rgba(233, 238, 255, 0.12);
  --accent: #6aa8ff;
  --good: #38d9a9;
  --bad: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 20% 0%, #182454, var(--bg));
  color: var(--text);
}

a {
  color: var(--text);
  text-decoration: none;
  opacity: 0.9;
}
a:hover {
  opacity: 1;
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  padding: 16px;
  margin: 0 auto;
}

.header {
  position: sticky;
  top: 0;
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav a {
  white-space: nowrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(18, 26, 51, 0.65);
}

.status__item {
  font-weight: 600;
}

.status__error {
  color: var(--bad);
  font-weight: 600;
}

.grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

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

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(18, 26, 51, 0.75);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card--reference {
  margin-top: 16px;
  border-color: rgba(106, 168, 255, 0.45);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card__label {
  font-weight: 800;
}

.card__id {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.card__title {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.audio {
  width: 100%;
  margin: 8px 0 10px 0;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choices--single {
  grid-template-columns: 1fr;
}

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.1);
}

.choice input:disabled + span {
  opacity: 0.5;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(106, 168, 255, 0.24), rgba(106, 168, 255, 0.12));
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  background: rgba(255, 255, 255, 0.06);
}

.muted {
  color: var(--muted);
}

.footer {
  margin-top: 18px;
}

.start {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
}

.card.is-best {
  border-color: rgba(56, 217, 169, 0.65);
  box-shadow: 0 10px 30px rgba(56, 217, 169, 0.12);
}

.card.is-worst {
  border-color: rgba(255, 107, 107, 0.65);
  box-shadow: 0 10px 30px rgba(255, 107, 107, 0.12);
}

.list {
  margin: 0;
  padding-left: 18px;
}

.list__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}

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

.list__count {
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

/* Shrink numeric columns to their content so the System column takes the slack */
.table--compact th:not(:first-child),
.table--compact td:not(:first-child) {
  width: 1%;
  white-space: nowrap;
  padding-left: 16px;
}

/* Fallback: if a table still can't fit, scroll it inside the card rather than clip */
.table-wrap {
  overflow-x: auto;
}

@media (max-width: 520px) {
  .table th,
  .table td {
    padding: 10px 4px;
  }

  .table th {
    font-size: 11px;
    letter-spacing: 0;
  }

  .table--compact th:not(:first-child),
  .table--compact td:not(:first-child) {
    padding-left: 10px;
  }

  .hide-narrow {
    display: none;
  }
}

.table th {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

/* ── Model information page ── */

.model-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-jump a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
}

.model-info {
  margin-top: 16px;
  padding: 20px;
  /* keep the sticky header from covering the heading on #anchor jumps */
  scroll-margin-top: 80px;
}

.model-info__title {
  margin: 0 0 10px;
  font-size: 20px;
}

.model-summary {
  margin: 0 0 18px;
  max-width: 68ch;
  line-height: 1.6;
  font-size: 15px;
}

.model-info a:not(.btn) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 1;
}

.model-note {
  margin: 0 0 18px;
  padding: 12px 14px;
  max-width: 68ch;
  border: 1px solid rgba(255, 196, 87, 0.35);
  border-left: 3px solid #ffc457;
  border-radius: 10px;
  background: rgba(255, 196, 87, 0.06);
  line-height: 1.6;
}

.model-note p {
  margin: 0;
}

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

.model-note__samples figure {
  margin: 0;
}

.model-note__samples figcaption {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.model-note__samples .audio {
  margin: 4px 0 0;
}

.model-systems {
  margin: 0;
  border-top: 1px solid var(--border);
}

.model-systems > div {
  display: grid;
  grid-template-columns: minmax(150px, 190px) 1fr;
  gap: 4px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.model-systems > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.model-systems dt {
  font-weight: 700;
}

.model-systems dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 520px) {
  .model-info {
    padding: 16px;
  }

  .model-systems > div {
    grid-template-columns: 1fr;
  }

  .model-note__samples {
    grid-template-columns: 1fr;
  }
}
