:root {
  --bg: #0b0c0e;
  --bg-elevated: #111214;
  --bg-surface: #16171a;
  --bg-hover: #1c1d21;
  --border: #2a2b30;
  --border-strong: #3a3b42;
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #8f8f98;
  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-text: #042f2e;
  --accent-muted: rgba(20, 184, 166, 0.12);
  --focus: #5eead4;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --max: 1180px;
}

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

html {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-hover);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -40px;
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: var(--space-4);
}

.app {
  width: min(100% - var(--space-8), var(--max));
  margin: 0 auto;
  padding: var(--space-8) 0 var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Header */
.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.lede {
  margin-top: var(--space-2);
  max-width: 42rem;
  color: var(--text-secondary);
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(4.5rem, auto));
  gap: var(--space-6);
  flex-shrink: 0;
  padding-left: var(--space-6);
  border-left: 1px solid var(--border);
}

.stat {
  min-width: 0;
}

.stat dt {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.stat dd {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* Toolbar */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin: calc(var(--space-3) * -1) 0 0;
  background: var(--bg);
}

.search {
  position: relative;
  flex: 1 1 220px;
  min-width: 200px;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:hover {
  border-color: var(--border-strong);
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.search-clear:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.search-clear[hidden] {
  display: none;
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

.filter-group {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.filter-btn[aria-checked="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.filter-count {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.filter-btn[aria-checked="true"] .filter-count {
  color: var(--text-secondary);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sort-field label {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.sort-select {
  height: 36px;
  padding: 0 28px 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.sort-select:hover {
  border-color: var(--border-strong);
}

.view-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

.view-btn svg {
  width: 14px;
  height: 14px;
}

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

.view-btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.results-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: calc(var(--space-2) * -1);
  font-size: 13px;
  color: var(--text-tertiary);
}

.results-meta strong {
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.model-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  min-height: 100%;
}

.model-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.model-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.card-category {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.btn-view {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.btn-view svg {
  width: 12px;
  height: 12px;
}

.btn-view:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-hover);
  text-decoration: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.metric dt {
  font-size: 11px;
  color: var(--text-tertiary);
}

.metric dd {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.loc-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}

.loc-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.features {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 46px;
  margin-top: auto;
}

.feature-tag {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
}

.feature-more {
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
}

/* Table */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.model-table tbody tr:last-child td {
  border-bottom: 0;
}

.model-table thead th {
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.model-table tbody tr:hover {
  background: var(--bg-hover);
}

.sort-col {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-col::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.35;
}

.sort-col[data-dir="asc"]::after {
  border-top: 0;
  border-bottom: 5px solid currentColor;
  opacity: 1;
}

.sort-col[data-dir="desc"]::after {
  border-top: 5px solid currentColor;
  opacity: 1;
}

.cell-model {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cell-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-loc {
  min-width: 9rem;
}

.inline-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-bar .loc-bar {
  flex: 1;
  min-width: 56px;
  max-width: 88px;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

/* Empty */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty-state p {
  margin-top: var(--space-2);
}

.empty-state svg {
  width: 28px;
  height: 28px;
  opacity: 0.6;
}

/* Footer */
.site-footer {
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
}

@media (max-width: 900px) {
  .inline-bar .loc-bar {
    display: none;
  }
}

@media (max-width: 860px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-5);
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    padding-left: 0;
    border-left: 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
  }

  .toolbar-right {
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - var(--space-6), var(--max));
    padding-top: var(--space-6);
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4) var(--space-6);
  }

  .search {
    flex: 1 1 100%;
    max-width: none;
  }

  .filter-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .filter-btn {
    justify-content: space-between;
    min-width: 0;
  }

  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .sort-field {
    flex: 1;
  }

  .sort-select {
    width: 100%;
  }

  .view-toggle {
    display: none;
  }

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

  .table-wrap {
    display: none;
  }

  .site-header {
    padding-bottom: var(--space-4);
  }

  .lede {
    font-size: 13px;
  }

  .stat dd {
    font-size: 1.1rem;
  }

  .model-card {
    padding: var(--space-3);
    gap: var(--space-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
