:root {
  color-scheme: dark;
  --bg: #090b0f;
  --bg-elevated: #12161c;
  --bg-input: #080a0e;
  --text: #e8eaed;
  --text-soft: #c5cdd6;
  --muted: #8b949e;
  --line: #2a3139;
  --line-soft: #1a1f26;
  --accent: #6cb6ff;
  --accent-hover: #8ec7ff;
  --link: #c090ff;
  --radius: 4px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --max: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: #090b0f;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: #090b0f !important;
  color: #e8eaed !important;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line-soft);
}

.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.page-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-tag {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.catalog {
  padding-top: 0;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.filters select,
.filters input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.filters select:focus,
.filters input:focus {
  outline: 2px solid rgba(88, 166, 255, 0.4);
  outline-offset: 1px;
}

.results-bar {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.results-bar p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text-soft);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#page-label {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 5.5rem;
  text-align: center;
}

.table-wrap {
  margin-top: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.set-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 860px;
}

.set-table th,
.set-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

.set-table th {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: #12161c;
  position: sticky;
  top: 0;
}

.set-table tbody tr:hover {
  background: rgba(88, 166, 255, 0.06);
}

.set-link,
.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.set-link:hover,
.linkish:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-pill {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  white-space: nowrap;
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

/* Detail panel */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 1rem;
}

.detail-overlay[hidden] {
  display: none !important;
}

.detail-panel {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #12151a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.35rem;
}

.detail-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.detail-close:hover {
  color: var(--text);
}

.detail-heading h2 {
  margin: 0 2rem 0 0;
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 600;
  color: #fff;
}

.detail-meta {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-dark,
.btn-blue {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border-radius: 3px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}

.btn-dark {
  background: #2a3138;
  color: #fff;
}

.btn-dark:hover {
  background: #3a434c;
}

.btn-blue {
  background: #1a6fb5;
  color: #fff;
}

.btn-blue:hover {
  background: #2180ce;
  color: #fff;
}

.detail-body {
  margin-top: 1.15rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 1.15rem;
  align-items: start;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}

.slot-block h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.slot-items {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.item-link {
  color: var(--link) !important;
  text-decoration: none;
  font-size: 0.88rem;
}

.item-link:hover {
  text-decoration: underline;
}

.empty-slots {
  color: var(--muted);
}

.variant-row {
  margin-top: 1rem;
}

.variant-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.variant-row select {
  max-width: 16rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.detail-preview {
  position: sticky;
  top: 0.25rem;
}

.model-frame {
  position: relative;
  min-height: 420px;
  background: radial-gradient(ellipse at center, #1c222b 0%, #0d1014 70%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

#model_3d {
  width: 100%;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-preview-img {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: contain;
}

.icon-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 1rem;
  width: 100%;
}

.icon-preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #0a0c10;
}

.model-status {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.race-picker {
  position: relative;
  margin-top: 0.6rem;
}

.race-trigger {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 3px;
  font: inherit;
  cursor: pointer;
}

.race-trigger::after {
  content: " ▾";
  float: right;
  opacity: 0.7;
}

.race-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.35rem);
  z-index: 5;
  max-height: 320px;
  overflow: auto;
  background: #1a1f26;
  border: 1px solid #4a5560;
  border-radius: 4px;
  padding: 0.55rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.85rem;
}

.race-menu[hidden] {
  display: none !important;
}

.race-faction h4 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: #fff;
}

.race-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.35rem 0.4rem;
  color: #e7ba2f;
  font-size: 0.85rem;
  border-radius: 3px;
  cursor: default;
}

.race-item:hover {
  background: #2a3138;
}

.race-arrow {
  color: #fff;
  opacity: 0.7;
}

.race-sub {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 7rem;
  background: #1a1f26;
  border: 1px solid #4a5560;
  border-radius: 3px;
  padding: 0.25rem;
  z-index: 6;
}

.race-item:hover .race-sub {
  display: block;
}

.race-sub button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  border-radius: 2px;
}

.race-sub button:hover {
  background: #3a434c;
}

@media (max-width: 900px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-label {
    grid-column: span 2;
  }

  .detail-body {
    grid-template-columns: 1fr;
  }

  .slot-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-preview {
    position: static;
  }

  .race-menu {
    grid-template-columns: 1fr;
    bottom: auto;
    top: calc(100% + 0.35rem);
  }

  .race-sub {
    left: auto;
    right: 0;
    top: 100%;
  }
}

@media (max-width: 600px) {
  .filters {
    grid-template-columns: 1fr;
  }

  .search-label {
    grid-column: span 1;
  }

  .slot-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
  }
}
