:root {
  /* spacing scale: 4 8 12 16 24 32 48 64 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --r-box: 8px;
  --r-btn: 6px;
  --r-input: 4px;

  --bg: #0b1416;
  --surface: #111d20;
  --surface-2: #16262a;
  --border: #22363a;
  --text: #e6f2ef;
  --muted: #8fa7a3;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25);

  /* brand accents are overwritten from index.json */
  --a: #97fce4;
  --a-ink: #0f2b2a;
  --b: #ffd27a;
  --b-ink: #2b1f0a;

  --cell: 152px;
  --font: 'Inter', system-ui, sans-serif;
  --display: 'Lilita One', 'Inter', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f3f6f5;
    --surface: #ffffff;
    --surface-2: #eef3f2;
    --border: #d6e0de;
    --text: #102225;
    --muted: #5b7470;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color-scheme: light;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}

.topbar__vs {
  color: var(--muted);
  font-weight: 600;
}

.mark {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.5px;
  line-height: 1;
}

.mark--a {
  color: var(--a);
}

.mark--b {
  color: var(--b);
}

.tabs {
  display: flex;
  gap: var(--s1);
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
}

.tab {
  padding: var(--s1) var(--s3);
  border: 0;
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface-2);
  color: var(--text);
}

/* ------------------------------------------------------------- brand cards */

.brands {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--s4);
}

.brand {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--s3);
  align-items: center;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-box);
  box-shadow: var(--shadow);
}

.brand img {
  width: 72px;
  height: 72px;
  border-radius: var(--r-btn);
}

.brand__name {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.1;
  color: var(--accent);
}

.brand > div {
  min-width: 0;
}

.brand__meta {
  overflow-wrap: anywhere;
  margin: var(--s1) 0 0;
  color: var(--muted);
  font-size: 13px;
}

.brand__meta code {
  font-family: var(--mono);
  color: var(--text);
}

/* --------------------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--s4) var(--s4);
}

.field {
  display: grid;
  gap: var(--s1);
}

.field__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input {
  height: 32px;
  min-width: 120px;
  padding: 0 var(--s2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
}

.field--range input {
  width: 120px;
  height: 32px;
  accent-color: var(--a);
}

.btn {
  height: 32px;
  padding: 0 var(--s3);
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--muted);
}

.badge {
  min-width: 20px;
  padding: 0 var(--s1);
  border-radius: 10px;
  background: var(--a);
  color: var(--a-ink);
  font-size: 12px;
  text-align: center;
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- filters */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s3);
  max-width: 1600px;
  margin: 0 auto var(--s4);
  padding: 0 var(--s4);
}

.filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
}

.filter summary {
  display: flex;
  justify-content: space-between;
  padding: var(--s2) var(--s3);
  font-weight: 600;
  cursor: pointer;
}

.filter summary span {
  color: var(--muted);
  font-weight: 500;
}

.filter__list {
  max-height: 280px;
  overflow: auto;
  padding: 0 var(--s3) var(--s2);
}

.filter__opt {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: var(--s2);
  align-items: start;
  padding: var(--s1) 0;
  font-size: 13px;
  cursor: pointer;
}

.filter__opt small {
  display: block;
  color: var(--muted);
}

.filter__opt .count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ pairs */

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--s4) var(--s7);
}

.pairs-head,
.pairs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s4);
}

.pairs-head {
  position: sticky;
  top: 57px;
  z-index: 10;
  padding: var(--s2) 0;
  background: var(--bg);
}

.pairs-head div {
  padding: var(--s2) var(--s3);
  border-radius: var(--r-btn);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  font-family: var(--display);
  font-size: 18px;
  color: var(--accent);
}

[data-layout='0'] .pairs-head,
[data-layout='0'] .pairs,
[data-layout='1'] .pairs-head,
[data-layout='1'] .pairs {
  grid-template-columns: 1fr;
}

[data-layout='0'] .side--1,
[data-layout='1'] .side--0 {
  display: none;
}

.side {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--cell), 100%), 1fr));
  gap: var(--s2);
  align-content: start;
  min-width: 0;
}

.card {
  position: relative;
  display: block;
  min-width: 0;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface-2);
}

.card__cap {
  display: flex;
  justify-content: space-between;
  gap: var(--s1);
  padding: var(--s1) var(--s2);
  font-size: 12px;
}

.card__cap b {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__cap span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sentinel {
  height: 1px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: var(--s7) var(--s4);
}

/* ------------------------------------------------------------------ modal */

.modal {
  width: min(1200px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.modal::backdrop {
  background: rgba(4, 10, 12, 0.7);
}

.modal__inner {
  padding: var(--s5);
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s4);
}

.modal__head h2 {
  margin: 0;
  font-size: 18px;
}

.modal__nav {
  display: flex;
  gap: var(--s2);
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}

.compare__col {
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-box);
  overflow: hidden;
}

.compare__col img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface-2);
}

.compare__title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--s3);
}

.compare__title h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  color: var(--accent);
}

.compare__title span {
  color: var(--muted);
  font-size: 12px;
}

.compare__links {
  display: flex;
  gap: var(--s3);
  padding: 0 var(--s3) var(--s3);
  font-size: 12px;
}

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

.attrs {
  width: 100%;
  margin-top: var(--s4);
  border-collapse: collapse;
  font-size: 13px;
}

.attrs th,
.attrs td {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.attrs th {
  color: var(--muted);
  font-weight: 600;
  width: 18%;
}

.attrs td.diff {
  color: var(--accent);
  font-weight: 600;
}

.attrs td small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

/* ------------------------------------------------------------ stats/names */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--s4);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
  overflow: hidden;
}

.stat h3 {
  margin: 0;
  padding: var(--s3);
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.stat h3 span {
  color: var(--muted);
  font-weight: 500;
}

.stat ol {
  list-style: none;
  margin: 0;
  padding: var(--s2) var(--s3);
  max-height: 360px;
  overflow: auto;
}

.stat li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s2);
  padding: 2px 0;
  font-size: 13px;
}

.stat li .bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 2px;
  background: var(--a);
  opacity: 0.6;
}

.stat li small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.names {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-box);
  overflow: hidden;
}

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

.names thead th {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 400;
}

.names td:first-child {
  color: var(--muted);
  width: 24%;
}

.names code {
  font-family: var(--mono);
}

.section-title {
  margin: var(--s5) 0 var(--s3);
  font-size: 16px;
}

/* ----------------------------------------------------------------- mobile */

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

  .pairs-head,
  .pairs {
    gap: var(--s2);
  }

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

  .brands {
    padding: var(--s4) var(--s4) var(--s3);
  }

  .brand {
    grid-template-columns: 48px 1fr;
    padding: var(--s3);
  }

  .brand img {
    width: 48px;
    height: 48px;
  }

  .brand__name {
    font-size: 22px;
  }

  .pairs-head div {
    font-size: 15px;
    padding: var(--s1) var(--s2);
  }

  .card__cap {
    font-size: 11px;
    padding: var(--s1);
  }

  .card__cap span {
    display: none;
  }

  .attrs th {
    width: auto;
  }

  .names td:first-child {
    width: auto;
  }

  .mark {
    font-size: 20px;
  }

  .result-count {
    margin-left: 0;
    width: 100%;
  }

  .pairs-head {
    top: 101px;
  }
}

/* ------------------------------------------------------ single collection */

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

.single .pairs-head,
.single .pairs {
  grid-template-columns: minmax(0, 1fr);
}

.compare--single {
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
}
