:root {
  --bg: #efeae2;
  --paper: #fbf8f3;
  --ink: #221e19;
  --muted: #6f675d;
  --line: #e3dbd0;
  --accent: #1d4a38;
  --accent-soft: #e5f0ea;
  --warn: #8a4b12;
  --warn-bg: #fbf1e4;
  --shadow: 0 10px 30px #3a2e2014;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "PingFang SC", serif;
}
button, input, select { font: inherit; color: inherit; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.path {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
}

.top {
  position: sticky;
  top: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--bg) 92%, white);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 16px 20px 12px;
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0.01em; }
.brand p { margin: 4px 0 12px; color: var(--muted); }
.search { display: block; }
.search input {
  width: min(720px, 100%);
  border: 1px solid #cfc4b4;
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
}
.search input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .group select {
  border: 1px solid #cfc4b4;
  background: white;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}
.chips button[aria-selected="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.group { color: var(--muted); display: flex; gap: 6px; align-items: center; }
.group select { border-radius: 8px; padding: 5px 8px; color: var(--ink); }
.count { margin: 0 0 0 auto; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 16px;
  padding: 16px 20px 32px;
  align-items: start;
}
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin: 0;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.card:hover { border-color: #b7aa98; }
.card.is-on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card img, .ph {
  width: 100%;
  height: 132px;
  object-fit: contain;
  background: #f4efe8;
  border-radius: 8px;
  display: block;
}
.ph { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.card .name { font-weight: 650; font-size: 14px; }
.card .meta, .card .id { color: var(--muted); font-size: 12px; }
.card .id { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0 7px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
}

#detail {
  position: sticky;
  top: 148px;
  max-height: calc(100vh - 164px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
#detail h2 { margin: 8px 0 4px; font-size: 22px; line-height: 1.25; }
#detail .id { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); font-size: 13px; }
.hero {
  width: 100%;
  max-height: 42vh;
  object-fit: contain;
  background: #f4efe8;
  border-radius: 10px;
}
.thumbs { display: flex; gap: 6px; margin-top: 8px; }
.thumbs button {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}
.thumbs img { width: 52px; height: 52px; object-fit: contain; display: block; }
.thumbs button.is-on { border-color: var(--accent); }
.facts { color: var(--muted); margin: 8px 0; }
.facts strong { color: var(--ink); font-weight: 650; }
.note {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0;
}
.block { margin-top: 14px; }
.block header, .iso header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.block h3, .iso h3 { margin: 0; font-size: 15px; }
.copy {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
}
.copy:disabled { opacity: 0.45; cursor: default; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0 0;
  max-height: 36vh;
  overflow: auto;
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
}
details { margin-top: 14px; }
details summary { cursor: pointer; font-weight: 650; }
.attr { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); margin: 8px 0; }
.none { grid-column: 1 / -1; color: var(--muted); padding: 24px 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  #detail { position: static; max-height: none; }
  .count { margin-left: 0; }
}
