:root {
  --bg: #f6f7f9;
  --card-bg: #ffffff;
  --text: #1e2430;
  --text-sub: #5b6472;
  --line: #e3e6eb;
  --accent: #2563eb;
  --accent-weak: #eaf0fe;
  --badge-release: #157f3d;
  --badge-release-bg: #e3f6ea;
  --badge-dev: #92610a;
  --badge-dev-bg: #fdf1d8;
  --badge-exp: #6d3fb8;
  --badge-exp-bg: #f0e8fc;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 14px rgba(20, 30, 50, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card-bg: #1b202a;
    --text: #e8ebf0;
    --text-sub: #9aa4b2;
    --line: #2a3140;
    --accent: #6d9bff;
    --accent-weak: #22304a;
    --badge-release: #7fd8a2;
    --badge-release-bg: #16321f;
    --badge-dev: #ecc06b;
    --badge-dev-bg: #3a2d11;
    --badge-exp: #c4a2f5;
    --badge-exp-bg: #2c1f45;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  line-height: 1.7;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.site-header { padding: 48px 0 28px; border-bottom: 1px solid var(--line); }
.site-header h1 { margin: 0 0 6px; font-size: 1.9rem; letter-spacing: .02em; }
.tagline { margin: 0; color: var(--text-sub); }
.profile-link { margin: 10px 0 0; font-size: .92rem; }
.profile-link a { color: var(--accent); text-decoration: none; }
.profile-link a:hover { text-decoration: underline; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--text-sub);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.count { color: var(--text-sub); font-size: .85rem; margin: 4px 0 14px; }

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--accent); }

.thumb { aspect-ratio: 16 / 9; background: var(--accent-weak); position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; font-weight: 700; color: var(--accent);
  opacity: .55; letter-spacing: .04em;
}

.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }

.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1.12rem; }

.badge { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.badge.release { color: var(--badge-release); background: var(--badge-release-bg); }
.badge.dev { color: var(--badge-dev); background: var(--badge-dev-bg); }
.badge.exp { color: var(--badge-exp); background: var(--badge-exp-bg); }

.catch { margin: 6px 0 0; font-size: .92rem; font-weight: 600; }
.desc { margin: 8px 0 0; font-size: .88rem; color: var(--text-sub); flex: 1; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: .75rem; color: var(--text-sub); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; }

.links { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; text-align: center; text-decoration: none;
  font-size: .88rem; font-weight: 600;
  border-radius: 8px; padding: 8px 0;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn.github { background: var(--text); color: var(--bg); }
.btn.demo { background: var(--accent-weak); color: var(--accent); }

#detailDialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow);
}
#detailDialog::backdrop { background: rgba(10, 14, 22, .55); }

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 26, 36, .55);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover { background: rgba(20, 26, 36, .8); }

.detail-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.detail-body { padding: 18px 22px 22px; }
.detail-body h2 { margin: 0; font-size: 1.25rem; }
.detail-text { margin: 10px 0 0; font-size: .9rem; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--text-sub); font-size: .85rem; }
.site-footer p { margin: 4px 0; }
.site-footer code { background: var(--card-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

@media (max-width: 480px) {
  .site-header { padding: 32px 0 20px; }
  .site-header h1 { font-size: 1.5rem; }
}
