/* 辞典の版面：見出し語（明朝）＋語釈（UDゴシック）。左に見出し、右に語釈を置く二段組を基本にし、
   作品の「箱の側面表示」（人数・時間・年齢）を帯で見せる。 */
:root {
  --paper: #f5f6f3;      /* 紙。わずかに緑みを持たせた白 */
  --surface: #ffffff;    /* 項目の地 */
  --ink: #1d2330;        /* 本文 */
  --ink-soft: #545c6b;   /* 補足 */
  --rule: #d9dcd4;       /* 罫線 */
  --entry: #a8322a;      /* 見出し語の朱。辞書の見出しに倣う */
  --ref: #2a5a9e;        /* 参照（→）の藍 */
  --band: #e9ece4;       /* 箱の側面表示の帯 */
  --note: #fff6dc;       /* 確認中の注記 */
  --note-ink: #6b5313;
  --font-head: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.125rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181e; --surface: #1c2028; --ink: #e6e8ec; --ink-soft: #a3aab6; --rule: #323844;
    --entry: #f08a7c; --ref: #8cb4ef; --band: #232833; --note: #3a3220; --note-ink: #f1d79a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15181e; --surface: #1c2028; --ink: #e6e8ec; --ink-soft: #a3aab6; --rule: #323844;
  --entry: #f08a7c; --ref: #8cb4ef; --band: #232833; --note: #3a3220; --note-ink: #f1d79a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: var(--step-0); line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--ref); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ref); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.35; text-wrap: balance; margin: 0; }
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 上の帯 */
.site-head { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; padding-block: 14px; }
.brand { font-family: var(--font-head); font-size: var(--step-2); font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: 0.04em; }
.brand small { font-family: var(--font-body); font-size: var(--step--1); font-weight: 400; color: var(--ink-soft); letter-spacing: 0; margin-left: 10px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: var(--step--1); }
.site-nav a { color: var(--ink); text-decoration: none; padding-block: 4px; border-bottom: 2px solid transparent; }
.site-nav a[aria-current="page"], .site-nav a:hover { border-bottom-color: var(--entry); }

.ad-bar { background: var(--band); color: var(--ink-soft); font-size: var(--step--1); border-bottom: 1px solid var(--rule); }
.ad-bar .wrap { padding-block: 6px; }
.buy { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.ad-label { margin: 0; font-size: var(--step--1); font-weight: 700; color: var(--ink-soft); letter-spacing: 0.08em; }
.buy-item { display: grid; gap: 8px; justify-items: start; }
.buy-img img { display: block; width: 128px; height: 128px; object-fit: contain; background: #fff; border: 1px solid var(--rule); border-radius: 4px; }
.buy-link { display: inline-block; font-weight: 700; text-decoration: none; padding: 6px 14px; border: 1px solid var(--ref); border-radius: 4px; }
.buy-link:hover { background: var(--band); }
.buy-note { margin: 0; font-size: var(--step--1); color: var(--ink-soft); }
.credit a { color: var(--ink-soft); }
.preview-bar { background: var(--note); color: var(--note-ink); font-size: var(--step--1); }
.preview-bar .wrap { padding-block: 8px; }

main { padding-block: 28px 64px; }
.lede { max-width: 42em; color: var(--ink-soft); margin: 8px 0 0; }
.crumbs { font-size: var(--step--1); color: var(--ink-soft); margin-bottom: 12px; }
.crumbs a { color: var(--ink-soft); }

/* 一覧ページ：左に引き方、右に項目 */
.finder { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; margin-top: 24px; align-items: start; }
.filters { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); display: grid; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.filters h2 { font-size: var(--step-1); }
.field { display: grid; gap: 4px; }
.field label, .field .label { font-size: var(--step--1); color: var(--ink-soft); letter-spacing: 0.04em; }
.field input, .field select {
  width: 100%; font: inherit; font-size: var(--step--1); color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px; padding: 7px 8px;
}
.weights { display: flex; flex-wrap: wrap; gap: 6px; }
.weights label { display: inline-flex; flex: none; white-space: nowrap; align-items: center; gap: 4px; font-size: var(--step--1); color: var(--ink); }
.reset { font: inherit; font-size: var(--step--1); background: none; border: 1px solid var(--rule); border-radius: 4px; padding: 6px 10px; color: var(--ink); cursor: pointer; }
.reset:hover { border-color: var(--ink-soft); }
.filters-toggle { display: none; }
.filters-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.filter-fields { display: grid; gap: 14px; }

.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
.results-head p { margin: 0; }
.count { font-family: var(--font-head); font-size: var(--step-1); }
.sort { display: flex; align-items: center; gap: 6px; font-size: var(--step--1); color: var(--ink-soft); }
.sort select { font: inherit; font-size: var(--step--1); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 4px 6px; }

/* 辞典の項目 */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 6px 28px; padding-block: 20px; border-bottom: 1px solid var(--rule); }
.entry-head { display: grid; gap: 2px; align-content: start; }
.entry-title { font-family: var(--font-head); font-size: 1.375rem; font-weight: 700; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.entry-title a { color: var(--entry); text-decoration: none; }
.entry-title a:hover { text-decoration: underline; }
.orig { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
.year { font-size: var(--step--1); color: var(--ink-soft); }
.entry-body { display: grid; gap: 8px; min-width: 0; }
.entry-body p { margin: 0; }

/* 箱の側面表示 */
.spec { display: flex; flex-wrap: wrap; gap: 0; width: fit-content; max-width: 100%; background: var(--band); border-radius: 4px; font-size: var(--step--1); }
.spec span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-right: 1px solid var(--rule); white-space: nowrap; }
.spec span:last-child { border-right: 0; }
.spec svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; }
.spec b { font-weight: 700; font-variant-numeric: tabular-nums; }

.tags { display: grid; gap: 2px; font-size: var(--step--1); }
.tags > div { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.tags .kind { min-width: 5.5em; }
.tags .kind { color: var(--ink-soft); }
.tags a { color: var(--ref); text-decoration: none; }
.tags a::before { content: "→"; margin-right: 2px; }
.tags a:hover { text-decoration: underline; }

.empty { padding: 32px 0; color: var(--ink-soft); }

/* 作品ページ */
.headword { display: grid; gap: 4px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); }
.headword h1 { font-size: var(--step-3); color: var(--entry); }
.headword .orig { font-size: var(--step-0); }
.article { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; margin-top: 24px; align-items: start; }
.article > * { min-width: 0; }
.intro { font-size: var(--step-1); line-height: 1.9; max-width: 36em; margin: 18px 0 0; }
.section { margin-top: 32px; }
.section h2 { font-size: var(--step-1); padding-bottom: 6px; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
dl.facts { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--ink-soft); font-size: var(--step--1); padding-top: 2px; }
dl.facts dd { margin: 0; }
.unknown { color: var(--ink-soft); }
.mech-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.mech-list li { display: grid; gap: 2px; }
.mech-list .group { font-size: var(--step--1); color: var(--ink-soft); }
.mech-list a { font-weight: 700; }
.mech-list p { margin: 0; font-size: var(--step--1); }
.sources { font-size: var(--step--1); color: var(--ink-soft); padding-left: 1.2em; margin: 0; display: grid; gap: 4px; }
.sources a { word-break: break-all; }
.aside { display: grid; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.aside h2 { font-size: var(--step-0); }
.checking { background: var(--note); color: var(--note-ink); border-radius: 6px; padding: 14px 16px; font-size: var(--step--1); }
.checking h2 { font-family: var(--font-body); font-size: var(--step--1); font-weight: 700; margin-bottom: 6px; }
.checking ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }

/* メカニクスのページ */
.groups { display: grid; gap: 28px; margin-top: 28px; }
.group-block { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px 28px; padding-top: 18px; border-top: 1px solid var(--rule); }
.group-block h2 { font-size: var(--step-1); color: var(--entry); }
.group-block .gdesc { margin: 4px 0 0; font-size: var(--step--1); color: var(--ink-soft); }
.mech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; margin: 0; padding: 0; list-style: none; }
.mech-grid li { display: grid; gap: 2px; }
.mech-grid p { margin: 0; font-size: var(--step--1); color: var(--ink-soft); }
.mech-grid .n { font-size: var(--step--1); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.def { font-size: var(--step-1); max-width: 36em; margin: 16px 0 0; }
.pending { margin-top: 20px; font-size: var(--step--1); color: var(--ink-soft); border-left: 3px solid var(--rule); padding-left: 12px; }

.prose { max-width: 40em; }
.prose h2 { font-size: var(--step-1); margin-top: 28px; }
.prose p, .prose li { margin: 8px 0 0; }

.site-foot { border-top: 1px solid var(--rule); font-size: var(--step--1); color: var(--ink-soft); }
.site-foot .wrap { padding-block: 20px 32px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-foot a { color: var(--ink-soft); }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }

@media (max-width: 820px) {
  .finder { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .filters { position: static; }
  .filters-toggle { display: inline-block; }
  .filters[data-open="false"] .filter-fields { display: none; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .article { grid-template-columns: minmax(0, 1fr); }
  .group-block { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .brand small { display: none; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
  .headword h1 { font-size: var(--step-2); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
