:root {
  color-scheme: dark;

  --bg: #101114;
  --panel: #16181c;
  --panel-hover: #1c1f24;
  --line: #26292f;
  --line-strong: #3a3e46;

  --text: #e6e7ea;
  --text-muted: #9a9fa8;
  --text-faint: #6b7079;

  --accent: #ffcb05;
  --accent-ink: #101114;

  --overlay: rgba(0, 0, 0, 0.75);

  --shell: 1400px;
  --header-height: 56px;
  --sidebar-width: 240px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg: #f4f4f5;
    --panel: #ffffff;
    --panel-hover: #eeeef0;
    --line: #dedfe3;
    --line-strong: #c4c6cc;

    --text: #121316;
    --text-muted: #5d626b;
    --text-faint: #8a8f98;

    --overlay: rgba(16, 17, 20, 0.6);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input,
select,
button {
  font: inherit;
  border-radius: 0;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 24px;
}

.hidden {
  display: none !important;
}

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

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand-mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.tab {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.12s ease, background 0.12s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.tab.active {
  color: var(--accent-ink);
  background: var(--accent);
}

main.shell {
  padding-top: 32px;
  padding-bottom: 72px;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.search {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 1.8;
  stroke-linecap: square;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
  appearance: none;
}

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

.search input:focus {
  border-color: var(--accent);
  outline: none;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 12px;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8f98' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-size: 10px 6px;
  background-repeat: no-repeat;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.85rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.12s ease;
}

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

select:focus {
  outline: none;
  border-color: var(--accent);
}

.text-button {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  min-height: 1.2em;
}

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

.sort select {
  width: auto;
  height: 32px;
  font-size: 0.8rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease;
}

.card:hover {
  border-color: var(--accent);
}

.card-art {
  aspect-ratio: 5 / 7;
  margin-bottom: 10px;
  background: var(--bg);
  overflow: hidden;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-name {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  color: var(--text-faint);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pagination button {
  height: 36px;
  padding: 0 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
}

.pagination button:disabled {
  color: var(--text-faint);
  background: transparent;
  cursor: default;
}

.page-heading {
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.set-banner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  margin-bottom: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.set-banner img {
  height: 48px;
  max-width: 160px;
  object-fit: contain;
}

.set-banner-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
  padding-right: 24px;
  border-right: 1px solid var(--line);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.back-link:hover {
  color: var(--text);
}

.sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.set-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease;
}

.set-card:hover {
  border-color: var(--accent);
}

.set-card img {
  width: 72px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.set-card-body {
  min-width: 0;
}

.set-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-card-meta {
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 2px;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
  padding: 72px 0;
  border: 1px dashed var(--line);
}

.modal .empty {
  border: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .sidebar {
    position: static;
    gap: 16px;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px 16px;
  }
}

@media (max-width: 600px) {
  .shell {
    padding: 0 16px;
  }

  main.shell {
    padding-top: 20px;
  }

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

  .card {
    padding: 8px;
  }

  .back-link {
    border-right: none;
    padding-right: 0;
  }
}
