/* 文献データベース ― 実在の学術データベースと同じ、事務的な画面 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.db {
  margin: 0; background: #fff; color: #222;
  font-family: Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px; line-height: 1.7; overflow-wrap: anywhere;
}
a { color: #1a4f9c; text-decoration: none; }
a:hover { text-decoration: underline; }
.db-body a:visited, .db-cite td:first-child a:visited, .db-list:not(.db-subs):not(.db-catalog) td:nth-child(2) a:visited { color: #5a3d8a; }

/* 枠 */
.db-util { background: #1d3a63; font-size: 12px; }
.db-util-in { max-width: 1120px; margin: 0 auto; padding: 4px 20px; display: flex; justify-content: flex-end; gap: 16px; }
.db-util a, .db-util a:visited { color: #dbe4f0; }
.db-head { border-bottom: 1px solid #c8d0db; }
.db-head-in { max-width: 1120px; margin: 0 auto; padding: 14px 20px; }
.db-name, .db-name:visited { font-size: 19px; font-weight: bold; color: #1d3a63; letter-spacing: .02em; }
.db-name:hover { text-decoration: none; }
.db-name { display: inline-flex; align-items: center; gap: 10px; }
.db-mark { display: block; flex: 0 0 auto; width: 30px; height: 30px; }
.db-sbar { background: #eef1f5; border-bottom: 1px solid #c8d0db; margin: 0; }
.db-sbar-in { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.db-sbar select, .db-sbar input { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid #aab4c2; background: #fff; color: #222; border-radius: 0; }
.db-sbar input { flex: 1 1 300px; min-width: 0; }
.db-sbar button { font: inherit; font-size: 13px; padding: 5px 18px; border: 1px solid #1d3a63; background: #1d3a63; color: #fff; cursor: pointer; border-radius: 0; }
.db-crumb { max-width: 1120px; margin: 0 auto; padding: 10px 20px 0; font-size: 12px; color: #555; }
.db-wrap { max-width: 1120px; margin: 0 auto; padding: 14px 20px 48px; display: flex; flex-wrap: wrap; gap: 28px; }
.db-main { flex: 999 1 620px; min-width: 0; }
.db-side { flex: 1 1 240px; min-width: 0; font-size: 13px; }
.db-foot { border-top: 1px solid #c8d0db; background: #eef1f5; }
.db-foot-in { max-width: 1120px; margin: 0 auto; padding: 14px 20px 24px; font-size: 12px; color: #555; }
.db-foot a, .db-foot a:visited { color: #1a4f9c; }
/* フッター：名前／運営・協力／案内のリンク／収録点数と最終更新／著作権／サイトポリシー */
.db-foot p { margin: 0; line-height: 1.8; }
.db-foot-name { font-size: 14px; font-weight: bold; color: #1d3a63; }
.db-foot-org { margin-bottom: 8px !important; }
.db-foot-links { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; }
.db-foot-links li { margin: 0; }
.db-foot-links li + li::before { content: "／"; margin: 0 .3em; color: #888; }
.db-foot-policy { margin-top: 10px !important; font-size: 11px; }
/* 手引きの一覧（五十音順） */
.db-index-note { margin: 0 0 12px; font-size: 13px; color: #555; }
.db-kana { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.db-kana a, .db-kana span { display: inline-block; min-width: 2.2em; padding: 3px 0; text-align: center; border: 1px solid #c8d0db; font-size: 13px; }
.db-kana a { background: #fff; color: #1a4f9c; }
.db-kana a:hover { background: #f1f5fa; text-decoration: none; }
.db-kana span { color: #aab4c2; background: #f6f7f9; }
.db-index { list-style: none; margin: 0 0 8px; padding: 0; columns: 3 12em; column-gap: 24px; }
.db-index li { margin: 0; padding: 3px 0; break-inside: avoid; font-size: 14px; }

/* 資料の詳細 */
.db-type { display: inline-block; font-size: 12px; padding: 0 8px; border: 1px solid #8c99ab; color: #3b4a5e; background: #f6f8fa; }
.db-title { font-size: 20px; line-height: 1.5; margin: 8px 0 14px; color: #111; font-weight: bold; }
.db-sub { margin: -6px 0 4px; font-size: 14px; }
.db-src { margin: 0 0 16px; font-size: 13px; color: #444; }
.db-count { font-size: 13px; color: #555; margin: -6px 0 14px; }
/* 目録の表の下の注 */
.db-note { font-size: 12px; color: #555; margin: 6px 0 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.db-meta { width: 100%; border-collapse: collapse; font-size: 13px; margin: 0 0 24px; }
.db-meta th, .db-meta td { border: 1px solid #d3d9e1; padding: 6px 10px; text-align: left; vertical-align: top; }
.db-meta th { width: 9em; background: #f0f3f7; font-weight: normal; color: #333; white-space: nowrap; }
.db-h {
  font-size: 14px; font-weight: bold; margin: 28px 0 12px; padding: 5px 10px; background: #e8edf3; color: #1d3a63;
}
.db-none { font-size: 13px; color: #555; }

/* 本文 */
.db-body { font-size: 14.5px; line-height: 1.9; }
.db-body p { margin: 0 0 1em; }
.db-body h1, .db-body h2, .db-body h3, .db-body h4, .db-body h5 { font-size: 14.5px; margin: 1.6em 0 .5em; line-height: 1.6; }
.db-body h4, .db-body h5 { font-size: 14px; }
.db-body ul, .db-body ol { margin: 0 0 1em; padding-left: 1.6em; }
.db-body li { margin: .25em 0; }
.db-body hr { border: 0; border-top: 1px solid #d3d9e1; margin: 1.6em 0; }
.db-body blockquote { margin: 0 0 1em; padding: 0 0 0 1em; border-left: 3px solid #d3d9e1; color: #444; }
.db-body blockquote p { margin: 0 0 .4em; }
.db-body table { border-collapse: collapse; font-size: 13px; line-height: 1.6; margin: 0 0 1.2em; min-width: 50%; }
.db-body th, .db-body td { border: 1px solid #d3d9e1; padding: 5px 9px; text-align: left; vertical-align: top; }
.db-body th { background: #f0f3f7; font-weight: normal; }
.db-body code { font-family: Consolas, "BIZ UDGothic", monospace; font-size: .92em; }
.db-body var.math { font-family: "Times New Roman", serif; font-style: italic; }
.db-body .callout { border: 1px solid #d3d9e1; background: #f7f8fa; padding: 8px 12px 2px; margin: 0 0 1em; }
.db-body .callout-title { font-weight: bold; font-size: 13px; margin-bottom: 4px; }
.db-body .addendum { border: 1px solid #d3d9e1; padding: 8px 12px 2px; margin: 0 0 1em; }
.db-body .addendum-label { font-weight: bold; font-size: 13px; color: #555; }
.db-body .footnotes { margin-top: 1.6em; padding-top: .8em; border-top: 1px solid #d3d9e1; font-size: 13px; line-height: 1.7; }
.db-body .footnotes p { margin: 0; }
.db-body .footnote-ref { font-size: .75em; }

/* 図 */
.db-body .fig { margin: 1.2em 0 1.6em; }
.db-body .fig img { display: block; max-width: 100%; height: auto; border: 1px solid #d3d9e1; }
.db-body .fig figcaption { margin-top: .5em; font-size: 13px; line-height: 1.7; color: #444; }
/* 表の題名（「表1 …」）は表のすぐ上 */
.db-body .tbl-cap { margin: 1.2em 0 .4em; font-size: 13px; line-height: 1.7; color: #444; }

/* 書庫の注記（本文の外の注記欄） */
.db-body .archivist-note { margin: 28px 0 0; padding: 0 16px 6px; background: #f7f8fa; border: 1px solid #d3d9e1; font-size: 13px; line-height: 1.8; }
.db-body .archivist-note > h2:first-child, .db-body .archivist-note > h3:first-child {
  margin: 0 -16px 10px; padding: 6px 12px; background: #e8edf3; color: #1d3a63; font-size: 14px; font-weight: bold; border-bottom: 1px solid #d3d9e1;
}
.db-body .archivist-note h3:not(:first-child), .db-body .archivist-note h4 { font-size: 13px; margin: 1.2em 0 .3em; }
.db-body .archivist-note p { margin: 0 0 .7em; }
.db-body .archivist-note ul, .db-body .archivist-note ol { margin: 0 0 .7em; padding-left: 1.4em; }
.db-body .archivist-note li { margin: .3em 0; }

/* 被参照・一覧 */
.db-grp { font-size: 13px; font-weight: bold; margin: 16px 0 4px; color: #333; }
.db-cite, .db-list { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-cite th, .db-cite td, .db-list th, .db-list td { border-bottom: 1px solid #e1e5eb; padding: 5px 8px; text-align: left; vertical-align: top; }
.db-cite th, .db-list th { background: #f0f3f7; font-weight: normal; color: #444; border-bottom: 1px solid #c8d0db; white-space: nowrap; }
.db-list th { border-top: 1px solid #c8d0db; }
.db-cite td.k, .db-cite td.y, .db-list td.k, .db-list td.y { color: #555; }
.db-list td.no { color: #777; text-align: right; }
.db-cite, .db-list:not(.db-subs):not(.db-catalog) { table-layout: fixed; }
.db-cite th:nth-child(2), .db-list:not(.db-subs):not(.db-catalog) th:nth-child(3) { width: 11em; }
.db-cite th:nth-child(3), .db-list:not(.db-subs):not(.db-catalog) th:nth-child(4) { width: 4.5em; }
.db-list:not(.db-subs):not(.db-catalog) th:nth-child(1) { width: 3.5em; }
.db-list:not(.db-subs):not(.db-catalog) th:nth-child(5) { width: 9em; }
.db-cite td.k, .db-list td.k { white-space: normal; }
.db-list:not(.db-catalog) tbody tr:hover, .db-cite tbody tr:hover { background: #f7f9fb; }
/* 被参照の「すべて表示」：11件目以降は同じ表の続き。JavaScript が動くときだけ畳んでおく */
.db-more { margin: 6px 0 0; }
.js-more .cite-group.has-more:not(.is-open) tr.cite-extra { display: none; }
.db-more-btn { font: inherit; font-size: 12.5px; padding: 4px 12px; border: 1px solid #c8d0db; background: #fff; color: #1a4f9c; cursor: pointer; border-radius: 0; }
.db-more-btn:hover { background: #eef1f5; }
.db-more-btn::before { content: "▾ "; color: #5b6b80; }
.db-more-btn[aria-expanded="true"]::before { content: "▴ "; }
.db-more-btn:focus-visible { outline: 2px solid #1a4f9c; outline-offset: 2px; }
.db-dirs { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; }
.db-snip { display: block; font-size: 12px; color: #555; margin-top: 2px; }
.db-snip mark { background: #fbe9a0; color: inherit; }

/* 右の欄 */
.db-box { border: 1px solid #d3d9e1; margin: 0 0 18px; }
.db-box h3 { font-size: 13px; margin: 0; padding: 6px 10px; background: #f0f3f7; border-bottom: 1px solid #d3d9e1; }
.db-box ul { list-style: none; margin: 0; padding: 8px 10px; }
.db-box li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.db-box li span:last-child { color: #555; }
.db-box li.sum { border-top: 1px solid #d3d9e1; margin-top: 4px; padding-top: 6px; font-weight: bold; }

@media (max-width: 640px) {
  .db-util-in, .db-head-in, .db-sbar-in, .db-crumb, .db-wrap, .db-foot-in { padding-left: 14px; padding-right: 14px; }
  .db-meta th { width: 6.5em; white-space: normal; }
  .db-body { font-size: 14px; }
}

/* 表のセルでは、数字や語を途中で折らない（全体の overflow-wrap: anywhere を打ち消す。入りきらないときだけ折る） */
table th, table td { overflow-wrap: break-word; }

/* 中身が短いページでも、フッターを画面の下端に置く */
body.db { min-height: 100vh; display: flex; flex-direction: column; }
.db-crumb, .db-wrap { width: 100%; }
.db-foot { margin-top: auto; }

/* 上の帯・ヘッダー・検索欄をまとめて固定（スマホでは画面を取りすぎるので固定しない）。右の欄も2段組みのときは追従。
   本文の流れには同じ高さの下敷き（.head-spacer）を置くので、省略ヘッダーに縮んでも本文はずれない */
:root { --head-full: 0px; --head-h: 0px; }
.head-spacer { display: none; }
.db-name-mini { display: none; }
@media (min-width: 641px) {
  :root { --head-full: 145px; --head-h: 145px; }
  .db-top { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: #fff; }
  .head-spacer { display: block; height: var(--head-full); }
  html { scroll-padding-top: calc(var(--head-h) + 12px); }
  .db-util, .db-head { overflow: hidden; max-height: 80px; transition: max-height .25s ease, opacity .2s ease, border-width .25s ease, visibility 0s; }
  .db-util-in, .db-head-in { transition: padding .25s ease; }
  /* 省略ヘッダー：上の帯と名前の段をたたみ、検索欄の左に名前を小さく出す */
  .db-name-mini { display: inline-flex; align-items: center; max-width: 0; margin-right: -6px; opacity: 0; visibility: hidden; overflow: hidden; white-space: nowrap; font-size: 14px; font-weight: bold; color: #1d3a63; text-decoration: none; transition: max-width .25s ease, margin .25s ease, opacity .2s ease, visibility 0s linear .25s; }
  .db-name-mini:visited { color: #1d3a63; }
  .head-compact .db-util, .head-compact .db-head { max-height: 0; opacity: 0; border-bottom-width: 0; visibility: hidden; transition: max-height .25s ease, opacity .2s ease, border-width .25s ease, visibility 0s linear .25s; }
  .head-compact .db-util-in, .head-compact .db-head-in { padding-top: 0; padding-bottom: 0; }
  .head-compact .db-name-mini { max-width: 18em; margin-right: 12px; opacity: 1; visibility: visible; transition: max-width .25s ease, margin .25s ease, opacity .2s ease .05s, visibility 0s; }
}
/* 資料ページの目次（右の欄。広い画面だけ。今読んでいる節を site.js が強調する） */
.side-toc { display: none; }
.side-toc .toc-list { list-style: none; margin: 0; padding: 6px 0; max-height: 50vh; overflow-y: auto; scrollbar-width: thin; }
.side-toc .toc-list { overflow-x: hidden; }
/* 右の欄の行の押せる範囲の広げ方（左右に -4px）は目次には使わない。横にはみ出して横スクロールが出るため */
.side-toc .toc-list li, .side-toc .toc-list li:has(a[href]) { display: block; margin: 0; padding: 0; }
.side-toc .toc-list a, .side-toc .toc-list a:visited { display: block; padding: 3px 10px; color: #1a4f9c; line-height: 1.55; border-left: 2px solid transparent; }
.side-toc .toc-h3 a, .side-toc .toc-h3 a:visited { padding-left: 22px; color: #3b5f8f; }
.side-toc .toc-list a:hover { background: #f1f5fa; }
.side-toc .toc-list a.is-current { color: #1d3a63; border-left-color: #1d3a63; background: #e8eef6; }
@media (min-width: 960px) {
  .db-side { position: sticky; top: calc(var(--head-h) + 14px); align-self: flex-start; transition: top .25s ease; }
  .side-toc { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .db-top *, .db-side { transition: none !important; }
}

/* 分類ページ：下位分類の表・表示件数・ページ送り */
.db-subs { max-width: 32rem; margin-bottom: 8px; }
.db-subs td.y { text-align: right; width: 6em; }
.db-range { font-size: 12.5px; color: #555; margin: 0 0 6px; }
.db-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 0; font-size: 13px; }
.db-pager ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.db-pager li a, .db-pager li span { display: inline-block; min-width: 32px; padding: 4px 8px; text-align: center; border: 1px solid #c8d0db; background: #fff; color: #1a4f9c; }
.db-pager li a:hover { background: #eef1f5; text-decoration: none; }
.db-pager li span[aria-current] { background: #1d3a63; border-color: #1d3a63; color: #fff; }
.db-pager li.gap { padding: 4px 2px; color: #777; }
.db-pager > a, .db-pager > .off { padding: 4px 10px; border: 1px solid #c8d0db; background: #fff; }
.db-pager > .off { color: #aab4c2; }

/* 行ごと押せる（site.js）。マウスを乗せると薄く色づく */
.db-list:not(.db-catalog) tbody tr:has(a[href]), .db-cite tbody tr:has(a[href]), .db-box li:has(a[href]) { cursor: pointer; }
.db-box li:has(a[href]) { padding-left: 4px; padding-right: 4px; margin: 0 -4px; }
.db-box li:has(a[href]):hover { background: #f1f5fa; }
.db-list:not(.db-catalog) tbody tr:has(a[href]):hover, .db-cite tbody tr:has(a[href]):hover { background: #eef3f9; }
.db-list:not(.db-subs):not(.db-catalog) tbody tr:hover td:nth-child(2) a, .db-cite tbody tr:hover td:first-child a, .db-subs tbody tr:hover td:first-child a, .db-box li:hover a { text-decoration: underline; }
/* 目録・手引きの表は行ごとには押せない。乗せたリンクだけに下線（a:hover の既定どおり） */

/* 手引き（人物・機関・用語・学説）：事典項目の体裁。書誌カードは出さず、上部に編者と版の1行だけ */
.db-edition { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid #d3d9e1; font-size: 12.5px; color: #555; }
/* 書庫トップの目録・手引きの表：名前の列は折り返さない幅、件数は右寄せ */
.db-catalog { table-layout: auto; }
.db-catalog th:first-child, .db-catalog td:first-child { white-space: nowrap; width: 1%; padding-right: 20px; }
.db-catalog td.y, .db-catalog th:last-child { text-align: right; white-space: nowrap; width: 5em; }
.db-guides { max-width: 44rem; }
.db-guides td.k { color: #555; }

/* 中身が短い列は折り返さない（build.mjs の tidyTables が付ける） */
th.nw, td.nw { white-space: nowrap; }
/* 表の寄せと最低幅（build.mjs の tidyTables が style 属性の代わりに付ける。CSP でインラインの style が使えないため） */
th.ta-l, td.ta-l { text-align: left !important; }
th.ta-c, td.ta-c { text-align: center !important; }
th.ta-r, td.ta-r { text-align: right !important; }
th.mw2 { min-width: 2em; }
th.mw3 { min-width: 3em; }
th.mw4 { min-width: 4em; }
th.mw5 { min-width: 5em; }
th.mw6 { min-width: 6em; }
th.mw7 { min-width: 7em; }
th.mw8 { min-width: 8em; }
th.mw9 { min-width: 9em; }
th.mw10 { min-width: 10em; }
th.mw11 { min-width: 11em; }

@media print {
  .db-util, .db-sbar, .db-side, .db-foot { display: none; }
}

/* ページの先頭へ */
.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); transition: opacity .2s, transform .2s; }
.to-top:hover { text-decoration: none; color: #fff; }
.to-top:focus-visible { outline: 3px solid #f0b400; outline-offset: 2px; }
.js-to-top .to-top:not(.is-shown) { opacity: 0; transform: translateY(8px); pointer-events: none; }
@media (max-width: 640px) { .to-top { right: 14px; bottom: 14px; } }
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } }
@media print { .to-top { display: none; } }
.to-top { background: #1d3a63; border-radius: 2px; }
.to-top:hover, .to-top:visited { background: #15304f; color: #fff; }

@media (max-width: 640px) {
  .db-cite th:nth-child(2), .db-list:not(.db-subs):not(.db-catalog) th:nth-child(3) { width: 7em; }
  .db-list:not(.db-subs):not(.db-catalog) th:nth-child(5) { width: 6em; }
}
