:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #9ba6b2;
  --primary: #58a6ff;
  --primary-strong: #1f6feb;
  --secondary: #a371f7;
  --success: #3fb950;
  --danger: #f85149;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.22);
  --radius: 10px;
  --radius-small: 8px;
  --max-width: 1120px;
  font-family: "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100svh;
}

button,
a,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.shell-compact {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar-compact {
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.05;
  font-weight: 700;
}

.subtle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.section-kicker {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--muted);
  background: transparent;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text);
  background: var(--surface);
  border-color: #4a5561;
  outline: none;
}

.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.topbar-compact .nav-link {
  padding: 10px 16px;
  color: var(--text);
  background: var(--surface);
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.status-bar > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.status-bar strong {
  display: block;
  font-size: 1.1rem;
}

.compare-layout,
.ranking-layout {
  display: grid;
  gap: 20px;
}

.compare-layout-compact {
  min-height: 0;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.pair-grid-compact {
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.quote-card {
  min-height: 100%;
}

.pair-grid-compact .quote-card {
  min-height: 0;
}

.vote-surface {
  width: 100%;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  text-align: left;
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.pair-grid-compact .vote-surface {
  min-height: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 28px;
}

.vote-surface:hover,
.vote-surface:focus-visible {
  border-color: var(--primary);
  background: var(--surface-alt);
  outline: none;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--primary);
  border: 1px solid rgba(88, 166, 255, 0.35);
  font-weight: 600;
}

.quote-text {
  margin: 0;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.7rem, 4vw, 3.1rem);
  line-height: 1.18;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.pair-grid-compact .quote-text {
  font-size: clamp(2rem, 3.8vw, 4rem);
}

.card-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.action-row {
  display: flex;
  justify-content: center;
}

.button {
  min-width: 180px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background-color 140ms ease, border-color 140ms ease;
}

.button:hover,
.button:focus-visible {
  background: var(--surface-alt);
  border-color: #4a5561;
  outline: none;
}

.info-panel,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.info-panel {
  padding: 20px 22px;
}

.info-panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.info-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.table-panel {
  overflow: hidden;
}

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

thead {
  background: rgba(240, 246, 252, 0.03);
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

tbody tr:hover {
  background: rgba(240, 246, 252, 0.02);
}

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

.rank-cell,
.number-cell {
  white-space: nowrap;
}

.phrase-cell {
  min-width: 320px;
}

.small-note {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 3px;
}

.empty-state,
.error-state {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(240, 246, 252, 0.02);
}

@media (max-width: 900px) {
  .status-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pair-grid {
    grid-template-columns: 1fr;
  }

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

  .vote-surface {
    min-height: 280px;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 24px 14px 40px;
  }

  .shell-compact {
    padding: 12px;
    gap: 12px;
  }

  .status-bar {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px;
  }

  .quote-text {
    font-size: clamp(1.45rem, 7vw, 2.2rem);
  }

  .pair-grid-compact .vote-surface {
    padding: 20px 16px;
  }

  .pair-grid-compact .quote-text {
    font-size: clamp(1.5rem, 7vw, 2.5rem);
  }

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