:root {
  --bg: #f5f5f3;
  --card: #ffffff;
  --ink: #23211e;
  --muted: #7a756d;
  --line: #e4e1db;
  --accent: #3f6b4f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.top {
  padding: 20px 16px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.top h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.top .sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 1em;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.filters input, .filters select {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

.filters input { flex: 1 1 auto; min-width: 0; }
.filters select { flex: 0 0 auto; }

main {
  padding: 14px 16px 40px;
  max-width: 960px;
  margin: 0 auto;
}

.cat h2 {
  font-size: 15px;
  color: var(--muted);
  margin: 18px 2px 10px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.card:active { transform: scale(0.985); }

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background:
    linear-gradient(135deg, #eceae5 25%, #f6f5f2 25%, #f6f5f2 50%, #eceae5 50%, #eceae5 75%, #f6f5f2 75%)
    0 0 / 16px 16px;
}

.card .cap {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.card .name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.detail {
  background: var(--card);
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 16px;
}

.detail img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  border-radius: 12px;
  background: var(--bg);
}

.detail dl {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: 76px 1fr;
  row-gap: 7px;
  font-size: 13.5px;
}

.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }

.detail .close-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.detail button {
  font: inherit;
  font-size: 14px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

@media (max-width: 400px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .filters { flex-wrap: wrap; }
  .filters select { flex: 1 1 40%; }
}
