:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --ink: #3b2a20;
  --ink-soft: #7a6656;
  --line: #eadfd2;
  --brand: #6b4430;
  --accent: #c8773c;
  --accent-soft: #f6e6d6;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80, 50, 30, 0.07);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--brand); white-space: nowrap; }
.logo svg { width: 30px; height: 30px; }
.nav { margin-left: auto; display: flex; gap: 18px; font-size: .92rem; color: var(--ink-soft); }
.nav a:hover { color: var(--accent); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(1.4rem, 4vw, 2rem); margin: 0 0 6px; color: var(--brand); }
.hero p { margin: 0 0 22px; color: var(--ink-soft); font-size: .95rem; }
.search { display: flex; max-width: 560px; margin: 0 auto; background: var(--surface); border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; padding: 12px 20px; outline: none; background: transparent; min-width: 0; }
.search button { border: 0; background: var(--accent); color: #fff; padding: 0 22px; cursor: pointer; font-weight: 700; }

/* ---------- tags ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 22px auto 0; max-width: 900px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px; font-size: .85rem; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tag:hover { border-color: var(--accent); }
.tag.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag small { color: var(--ink-soft); font-size: .75rem; }
.tag.active small { color: #fff; }

.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button { flex: none; border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-soft); }
.cat-tabs button.active { background: var(--accent-soft); color: var(--brand); font-weight: 700; }

/* ---------- list ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin: 28px 0 14px; flex-wrap: wrap; }
.toolbar h2 { font-size: 1.1rem; margin: 0; }
.toolbar .count { color: var(--ink-soft); font-size: .85rem; }
.toolbar select { margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding-bottom: 60px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card .thumb { aspect-ratio: 1; background: #fff; display: grid; place-items: center; padding: 10px; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card .meta { padding: 8px 12px 12px; font-size: .85rem; border-top: 1px solid var(--line); }
.card .meta .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 0; color: var(--ink-soft); }

/* ---------- detail ---------- */
.breadcrumb { font-size: .82rem; color: var(--ink-soft); margin: 20px 0; }
.breadcrumb a:hover { color: var(--accent); }
.detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .detail { grid-template-columns: 1fr; } }
.detail .preview { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.detail .preview img { margin: 0 auto; max-height: 70vh; object-fit: contain; }
.detail h1 { font-size: 1.4rem; margin: 0 0 12px; }
.detail .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 28px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; width: 100%; font-size: 1rem;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.info { margin-top: 18px; font-size: .85rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 14px; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.info dt { font-weight: 700; color: var(--ink); }
.info dd { margin: 0; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; font-size: .82rem; margin-top: 16px; }
.notice a { text-decoration: underline; }
.related { margin: 48px 0 0; }

/* ---------- prose (terms) ---------- */
.prose { max-width: 760px; margin: 40px auto 80px; background: var(--surface); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.prose h1 { color: var(--brand); font-size: 1.5rem; margin-top: 0; }
.prose h2 { font-size: 1.1rem; border-left: 4px solid var(--accent); padding-left: 10px; margin-top: 32px; }
@media (max-width: 480px) { .prose { padding: 20px; } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; font-size: .82rem; color: var(--ink-soft); text-align: center; }
.site-footer nav { display: flex; gap: 18px; justify-content: center; margin-bottom: 8px; }
.demo-banner { background: #fff4c2; color: #6b5400; text-align: center; font-size: .8rem; padding: 6px 16px; }

@media (max-width: 560px) {
  .site-header .wrap { height: 56px; gap: 10px; }
  .logo { font-size: 1rem; }
  .nav { gap: 12px; font-size: .8rem; white-space: nowrap; }
  .nav a:first-child { display: none; }
  .hero { padding: 32px 0 20px; }
  .tag-cloud .tag:nth-child(n+13) { display: none; }
}

/* 透過PNGのプレビュー用 市松模様 */
.preview.checker { background-color: #fff; background-image: linear-gradient(45deg, #ece6de 25%, transparent 25%, transparent 75%, #ece6de 75%), linear-gradient(45deg, #ece6de 25%, transparent 25%, transparent 75%, #ece6de 75%); background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.badge { display: inline-block; font-size: .72rem; background: var(--accent-soft); color: var(--brand); border-radius: 999px; padding: 1px 10px; margin-left: 6px; vertical-align: middle; }

/* ダウンロード形式の選択 */
.formats { display: flex; gap: 8px; margin-bottom: 12px; }
.fmt { flex: 1; cursor: pointer; }
.fmt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt span { display: block; text-align: center; padding: 10px 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .88rem; font-weight: 700; }
.fmt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--brand); }
.fmt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* トップのセクション構成 */
.block { margin-bottom: 8px; }
.block .grid { padding-bottom: 20px; }
.more { text-align: center; padding-bottom: 40px; }
.more .btn { width: auto; min-width: 240px; padding: 12px 32px; }

/* カテゴリ切り替えは検索欄とタグ一覧の間に置く */
.hero .cat-tabs { width: fit-content; max-width: 100%; margin: 20px auto 0; padding: 4px 0; }
.hero .tag-cloud { margin-top: 8px; }
