:root {
  --gap: 16px;
  --card-size: 140px;
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
  color: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #0d0d0d;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  padding: 16px 24px 12px;
  background: #111;
  border-bottom: 1px solid #222;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.03em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: 100%;
  max-width: 600px;
  flex-wrap: wrap;
  justify-content: center;
}

#search {
  flex: 1;
  min-width: 160px;
  max-width: 360px;
  padding: 8px 14px;
  border: 1px solid #333;
  border-radius: 20px;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

#search::placeholder {
  color: #666;
}

#search:focus {
  border-color: #555;
}

#filter-xstock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #aaa;
  cursor: pointer;
  white-space: nowrap;
}

#filter-xstock input[type='checkbox'] {
  accent-color: #2962ff;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

#count {
  margin-left: auto;
  font-size: 0.8rem;
  color: #555;
  white-space: nowrap;
}

/* ── Grid ── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr));
  gap: var(--gap);
  padding: var(--gap) 24px;
  align-content: start;
}

/* ── Card ── */
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 12px;
  background: #161616;
  border: 1px solid #222;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.card:hover {
  background: #1e1e1e;
  border-color: #444;
}

.card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.card .name {
  font-size: 0.72rem;
  color: #ccc;
  text-align: center;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ── Empty state ── */
#empty {
  display: none;
  grid-column: 1 / -1;
  text-align: center;
  color: #555;
  padding: 60px 0;
  font-size: 0.95rem;
}
