:root {
  --bg: #faf7f2;
  --bg-2: #f1ece3;
  --surface: #ffffff;
  --ink: #1d1a2e;
  --ink-2: #5c5870;
  --line: #e4ddd0;
  --brand: #6d4aff;
  --brand-ink: #ffffff;
  --gold: #e0a526;
  --shadow: 0 1px 2px rgb(30 20 60 / .06), 0 6px 20px rgb(30 20 60 / .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12111c; --bg-2: #1a1828; --surface: #1f1d30; --ink: #f1eefc; --ink-2: #a7a2c2;
    --line: #2f2c46; --brand: #9b85ff; --brand-ink: #12111c; --gold: #f2c14e;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12111c; --bg-2: #1a1828; --surface: #1f1d30; --ink: #f1eefc; --ink-2: #a7a2c2;
  --line: #2f2c46; --brand: #9b85ff; --brand-ink: #12111c; --gold: #f2c14e;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.7 "Noto Sans JP", system-ui, sans-serif;
  /* --anchor-h: 画面下部に固定表示される広告(アンカー広告)の高さ。app.js が設定する */
  padding-bottom: calc(80px + var(--anchor-h, 0px));
}
a { color: var(--brand); }
h1, h2, h3, .logo, .cat-name, .stats dd { font-family: "Zen Maru Gothic", "Noto Sans JP", sans-serif; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-2); }
.section { padding: 48px 16px; }
.section h2 { font-size: 1.5rem; margin: 0 0 20px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 900; font-size: 1.25rem; }
.logo-mark { width: 26px; height: 26px; color: var(--gold); flex: none; }
.header-nav { display: flex; align-items: center; gap: 18px; }
.header-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.header-nav a:hover { color: var(--ink); }
.theme-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }

/* hero */
.hero { padding: 64px 0 40px; background:
  radial-gradient(600px 300px at 85% 10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%),
  radial-gradient(500px 260px at 5% 90%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%); }
.eyebrow { display: inline-block; margin: 0 0 12px; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.25; margin: 0 0 16px; font-weight: 900; }
.lead { font-size: 1.05rem; color: var(--ink-2); max-width: 640px; margin: 0 0 24px; }
.search-box input, .toolbar .filter {
  width: 100%; max-width: 560px; font: inherit; font-size: 1rem; padding: 14px 18px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.search-box input:focus, .toolbar .filter:focus { outline: none; border-color: var(--brand); }
.search-results { max-width: 560px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.search-results a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 18px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); }
.search-results a:first-child { border-top: 0; }
.search-results a:hover { background: var(--bg-2); }
.search-results .soon-tag { font-size: .8rem; color: var(--ink-2); white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 560px; margin: 32px 0 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.stats dt { font-size: .75rem; color: var(--ink-2); }
.stats dd { margin: 0; font-size: 1.5rem; font-weight: 900; }

/* category tiles */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 14px; }
.cat-tile {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s; overflow: hidden;
}
.cat-tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--c); }
.cat-tile:hover { transform: translateY(-3px); border-color: var(--c); }
.cat-emoji { font-size: 1.8rem; line-height: 1; }
.cat-name { font-weight: 900; font-size: 1.1rem; margin-top: 6px; }
.cat-desc { font-size: .85rem; color: var(--ink-2); flex: 1; }
.cat-count { font-size: .8rem; color: var(--ink-2); margin-top: 6px; }
.cat-count b { color: var(--ink); font-size: 1rem; }
.meter { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--c); min-width: 3px; }

/* category page */
.cat-hero { padding: 40px 0 24px; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 16%, transparent), transparent); }
.cat-hero h1 { display: flex; align-items: center; gap: 12px; font-size: clamp(1.7rem, 5vw, 2.6rem); margin: 8px 0; font-weight: 900; }
.zip-btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 700; font-size: .9rem; box-shadow: var(--shadow);
}
.zip-btn svg { width: 18px; height: 18px; }
.zip-btn:hover { background: var(--brand); color: var(--brand-ink); }
.crumbs { font-size: .85rem; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 16px; scrollbar-width: thin; }
.pill { flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .88rem; }
.pill.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 18px; }
.toolbar .filter { flex: 1 1 260px; padding: 11px 16px; }
[hidden] { display: none !important; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.empty { text-align: center; padding: 40px 0; }

/* cards */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 12px; padding-bottom: 32px; }
.card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0;
}
.card.soon { box-shadow: none; background: transparent; border-style: dashed; grid-template-columns: auto 1fr; }
.card.soon h3 { color: var(--ink-2); }
.card.playing { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.card h3 { font-size: 1rem; line-height: 1.4; margin: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }  /* 長い名前(国歌・曲名)は2行まで */
.card-body { min-width: 0; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .78rem; margin-top: 2px; }
.chip { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--ink); }
.play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--c); color: #16121f; font-size: 18px; transition: transform .1s;
}
.play:hover { transform: scale(1.06); }
.play:focus-visible, .dl:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.play.disabled { background: var(--bg-2); color: var(--ink-2); cursor: default; transform: none; }
.wave { display: block; width: 100%; height: 36px; margin: 4px 0; cursor: pointer; }
.dl {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 10px; border-radius: 12px;
  color: var(--ink); text-decoration: none; font-size: .72rem; font-weight: 700; border: 1px solid var(--line);
}
.dl svg { width: 20px; height: 20px; }
.dl:hover { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* sticky player */
.player-bar {
  position: fixed; left: 50%; bottom: calc(16px + var(--anchor-h, 0px)); transform: translateX(-50%); z-index: 20;
  transition: bottom .2s;
  width: min(560px, calc(100% - 32px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--ink); color: var(--bg); border-radius: 999px; box-shadow: 0 10px 30px rgb(0 0 0 / .3);
}
.player-bar[hidden] { display: none; }
.pb-toggle { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--gold); color: #1d1a2e; cursor: pointer; flex: none; }
.pb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-time { font-size: .78rem; color: color-mix(in srgb, var(--bg) 70%, transparent); }
.pb-dl { color: var(--bg); border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); padding: 6px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .85rem; }

/* footer / prose */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; margin-top: 24px; font-size: .88rem; }
.site-footer p { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.site-footer .logo-mark { width: 18px; height: 18px; }
.prose { max-width: 760px; }
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.2rem; margin-top: 28px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 14px; }
.footer-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.footer-nav a:hover { color: var(--ink); text-decoration: underline; }
.footer-nav a[hidden] { display: none; }
.site-footer .copyright { font-size: .8rem; }

/* ZIP(分割時) */
.zip-parts { margin-top: 4px; }
.zip-note { margin: 0 0 8px; font-weight: 700; font-size: .9rem; }
.zip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.zip-btn.zip-part { margin-top: 0; padding: 8px 14px; font-size: .85rem; }
.zip-part small { font-weight: 500; opacity: .75; margin-left: 2px; }

/* ads: 素材カードと区別できる面・ラベル付き。CLS対策に高さを先に確保する */
.ad-slot {
  position: relative; margin: 40px 0; padding: 24px 12px 12px; min-height: 282px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; text-align: center;
}
.ad-label { position: absolute; top: 4px; left: 12px; margin: 0; font-size: .7rem; line-height: 1.6; letter-spacing: .1em; color: var(--ink-2); }
.ad-slot ins.adsbygoogle { width: 100%; }
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-infeed { grid-column: 1 / -1; margin: 28px 0; }   /* カード一覧の途中: 行全体を使い、上下に余白 */
.ad-cat-top { margin: 36px 0 32px; }  /* 任意枠: ZIPボタンから離す */
.ad-footer { margin: 48px 0 8px; }
.ad-placeholder {
  display: grid; place-items: center; border: 2px dashed color-mix(in srgb, var(--brand) 55%, var(--line));
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--brand) 6%, transparent) 14px 28px), var(--bg-2);
}
.ad-ph { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: .85rem; }
.ad-ph b { color: var(--ink); font-size: 1rem; font-family: ui-monospace, Consolas, monospace; }

/* top: 使い方・FAQ */
.guide h2 + .steps { margin-top: 0; }
.steps { list-style: none; padding: 0; margin: 0 0 44px; counter-reset: step;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 14px; }
.steps li {
  counter-increment: step; position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 18px 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.steps li::before {
  content: counter(step); position: absolute; left: 18px; top: 18px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--gold); color: #1d1a2e; font: 900 1rem "Zen Maru Gothic", sans-serif;
}
.steps b { font-family: "Zen Maru Gothic", "Noto Sans JP", sans-serif; font-size: 1.05rem; }
.steps span { color: var(--ink-2); font-size: .9rem; }
.faq { max-width: 760px; margin: 0; }
.faq dt { position: relative; margin-top: 18px; padding-left: 1.7em; font-weight: 700; }
.faq dt::before { content: "Q"; position: absolute; left: 0; color: var(--brand); font: 900 1.05rem "Zen Maru Gothic", sans-serif; }
.faq dd { margin: 4px 0 0; padding-left: 1.7em; color: var(--ink-2); }

/* category: 使いどころ */
.cat-guide { max-width: none; margin: 16px 0 8px; padding: 8px 24px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cat-guide h2 { margin-top: 16px; }

.cat-guide h3 { font-size: 1.05rem; margin: 20px 0 4px; }
.index-intro { margin-bottom: 36px; }
.index-intro p { margin: 0 0 12px; }

/* カードの素材名 → 個別ページへのリンク */
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { color: var(--brand); text-decoration: underline; }

/* 素材の個別ページ */
.sound-hero h1 { display: block; font-size: clamp(1.5rem, 4.5vw, 2.3rem); line-height: 1.35; }
.sound-hero .lead { max-width: 760px; margin-bottom: 4px; }
.sound-main { padding-top: 8px; }
.sound-player { grid-template-columns: minmax(0, 640px); padding-bottom: 20px; }
.sound-spec { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 8px; max-width: 980px; margin: 0 0 8px; }
.sound-spec div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; min-width: 0; }
.sound-spec dt { font-size: .75rem; color: var(--ink-2); }
.sound-spec dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (min-width: 600px) { .sound-spec .wide { grid-column: span 2; } }
.sound-detail ul { padding-left: 1.3em; }
.tag-list { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list li { padding: 2px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .88rem; }
.section-sm { padding: 24px 0 0; }
.section-sm h2 { font-size: 1.25rem; margin: 0 0 14px; }
.prev-next { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 0; font-size: .92rem; }
.prev-next a { text-decoration: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prev-next a:hover { border-color: var(--brand); }
.more-cats .btn { margin-bottom: 8px; }
.ad-sound { margin: 48px 0; }  /* 任意枠: 上の再生カード・下の関連素材のボタンから離す */

/* 注意書き(国歌など) */
.notice { margin: 4px 0 20px; padding: 14px 18px; border: 1px solid color-mix(in srgb, var(--gold) 60%, var(--line)); border-left: 6px solid var(--gold);
  border-radius: 12px; background: color-mix(in srgb, var(--gold) 10%, var(--surface)); max-width: 980px; }
.notice h2 { font-size: 1.05rem; margin: 0 0 6px; }
.notice p { margin: 0 0 6px; font-size: .93rem; }
.notice p:last-child { margin-bottom: 0; }

/* 出典(個別ページ・出典ページ) */
.source-box { margin: 20px 0 8px; padding: 4px 20px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 980px; }
.source-box h2 { margin-top: 14px; }
.source-box h3 { font-size: .95rem; margin: 16px 0 4px; }
.source-list { margin: 0; }
.source-list div { display: grid; grid-template-columns: 11em 1fr; gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.source-list dt { color: var(--ink-2); font-size: .85rem; }
.source-list dd { margin: 0; overflow-wrap: anywhere; }
.sources-page { max-width: 1120px; }
.sources-page > p, .sources-page > ul { max-width: 760px; }
.sources-table { font-size: .85rem; }
.sources-table td { overflow-wrap: anywhere; }
.sources-table td:nth-child(2) { min-width: 11em; }
.sources-table { min-width: 760px; }
.nowrap { white-space: nowrap; }
@media (max-width: 560px) { .source-list div { grid-template-columns: 1fr; gap: 0; } .source-box { padding: 2px 14px 10px; } }

/* 固定ページ */
.table-scroll { overflow-x: auto; }
.table-scroll .table { min-width: 640px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 8px 0 16px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.table .num { text-align: right; white-space: nowrap; }
.contact-box { padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.contact-item { margin: 6px 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.btn { display: inline-block; padding: 10px 22px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); text-decoration: none; font-weight: 700; }
.btn:hover { filter: brightness(1.08); }
.config-missing {
  display: inline-block; padding: 2px 10px; border: 2px dashed #e5484d; border-radius: 8px; color: #e5484d;
  background: color-mix(in srgb, #e5484d 8%, transparent); font-weight: 700; font-size: .88rem;
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-list { grid-template-columns: 1fr; }
  .header-nav { gap: 12px; }
  .logo { font-size: 1.1rem; white-space: nowrap; }
  .header-nav a { white-space: nowrap; font-size: .9rem; }
  .header-nav .hide-xs { display: none; }
  .hero { padding-top: 40px; }
  .ad-slot { min-height: 312px; }
  .cat-guide { padding: 4px 16px 12px; }
}
@media (max-width: 440px) {
  .hide-xs { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
