/* サヨナリペディア：百科事典風ページの共通スタイル */
:root {
  --bg: #ffffff;
  --bg-page: #f8f9fa;
  --bg-box: #f8f9fa;
  --bg-head: #eaecf0;
  --bg-accent: #cedff2;
  --text: #202122;
  --text-sub: #54595d;
  --border: #a2a9b1;
  --border-soft: #c8ccd1;
  --border-faint: #eaecf0;
  --link: #3366cc;
  --link-visited: #6b4ba1;
  --link-new: #d73333;
  --notice: #fef6e7;
  --notice-border: #fc3;
  --serif: "Linux Libertine", "Georgia", "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}
/* 既定は明るい配色（百科事典の見た目を優先）．暗い配色は data-theme="dark" で切り替える */
:root[data-theme="dark"] {
  --bg: #101418; --bg-page: #101418; --bg-box: #1a1f24; --bg-head: #27292d; --bg-accent: #233566;
  --text: #eaecf0; --text-sub: #a2a9b1; --border: #54595d; --border-soft: #404244; --border-faint: #27292d;
  --link: #88a3e8; --link-visited: #a799cd; --link-new: #fd7865; --notice: #2d2212; --notice-border: #987027;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body { margin: 0; background: var(--bg-page); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.7; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }
a.ext::after { content: "\2197"; font-size: .75em; margin-left: 1px; color: var(--text-sub); }
a.new { color: var(--link-new); }

/* 上部の帯 */
.w-header { background: var(--bg); border-bottom: 1px solid var(--border-faint); }
.w-header-in { max-width: 1596px; margin: 0 auto; padding: 8px 24px; display: flex; align-items: center; gap: 20px; }
.w-logo { display: flex; align-items: center; gap: 10px; color: var(--text); }
.w-logo:visited { color: var(--text); }
.w-logo:hover { text-decoration: none; }
.w-logo-mark { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-family: var(--serif); font-size: 26px; background: var(--bg-box); }
.w-logo-name { font-family: var(--serif); font-size: 21px; line-height: 1.15; letter-spacing: .02em; }
.w-logo-name small { display: block; font-family: var(--sans); font-size: 11px; color: var(--text-sub); letter-spacing: 0; }
.w-search { flex: 1; max-width: 500px; display: flex; }
.w-search input { flex: 1; min-width: 0; border: 1px solid var(--border); border-right: 0; border-radius: 2px 0 0 2px; padding: 6px 10px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); }
.w-search button { border: 1px solid var(--border); border-radius: 0 2px 2px 0; background: var(--bg-box); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; padding: 6px 12px; cursor: pointer; }
.w-user { margin-left: auto; font-size: 14px; display: flex; gap: 14px; white-space: nowrap; }

/* 本体の配置 */
.w-wrap { max-width: 1596px; margin: 0 auto; padding: 0 24px 48px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 36px; background: var(--bg); }
.w-side { padding-top: 24px; font-size: 14px; }
.w-toc { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; padding-right: 6px; }
.w-toc-title { font-weight: 700; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.w-toc ul { list-style: none; margin: 0; padding: 0; }
.w-toc li { margin: 0; }
.w-toc a { display: block; padding: 4px 0; line-height: 1.4; }
.w-toc ul ul { padding-left: 16px; }
.w-toc a.cur { color: var(--text); font-weight: 700; }
.w-main { padding-top: 20px; min-width: 0; }

/* 題名まわり */
.w-title { font-family: var(--serif); font-weight: 400; font-size: 29px; line-height: 1.3; margin: 0; padding-bottom: 2px; }
.w-tabs { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 20px; border-bottom: 1px solid var(--border); font-size: 14px; margin-bottom: 6px; }
.w-tabs div { display: flex; gap: 14px; }
.w-tabs span, .w-tabs a { padding: 8px 0 6px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.w-tabs .on { border-bottom-color: var(--text); color: var(--text); font-weight: 700; }
.w-tabs .off { color: var(--link); cursor: default; }
.w-from { font-size: 13px; color: var(--text-sub); margin: 0 0 10px; }
.w-hat { font-size: 14px; padding-left: 26px; margin: 0 0 10px; color: var(--text); }

/* 注意書きの箱 */
.w-notice { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-left: 10px solid var(--notice-border); background: var(--bg-box); padding: 8px 12px; margin: 10px 0 14px; font-size: 14px; line-height: 1.6; max-width: 900px; }
.w-notice b { display: block; }
.w-notice .ic { font-size: 22px; line-height: 1.2; }

/* 本文 */
.w-body { font-size: 16px; }
.w-body p { margin: 8px 0 12px; }
.w-body h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.3; margin: 28px 0 6px; padding-bottom: 2px; border-bottom: 1px solid var(--border); overflow: hidden; }
.w-body h3 { font-size: 19px; font-weight: 700; line-height: 1.4; margin: 20px 0 4px; }
.w-body h4 { font-size: 16px; font-weight: 700; margin: 14px 0 2px; }
.w-body ul, .w-body ol { margin: 6px 0 12px; padding-left: 28px; }
.w-body li { margin-bottom: 3px; }
.w-body dl { margin: 6px 0 12px; }
.w-body dt { font-weight: 700; margin-top: 6px; }
.w-body dd { margin-left: 24px; }
.w-body blockquote { margin: 12px 0; padding: 4px 20px; border-left: 4px solid var(--border-soft); color: var(--text); }
.w-body blockquote cite { display: block; font-size: 14px; color: var(--text-sub); font-style: normal; margin-top: 4px; }
.w-main-link { font-size: 14px; padding-left: 26px; margin: 2px 0 8px; }
sup.ref { font-size: 12px; line-height: 1; white-space: nowrap; font-weight: 400; }
sup.ref a:visited { color: var(--link); }
sup.need { font-size: 12px; line-height: 1; white-space: nowrap; color: var(--text-sub); }
:target { background: var(--bg-accent); }

/* 基礎情報の箱 */
.infobox { float: right; clear: right; width: 310px; margin: 4px 0 16px 24px; border: 1px solid var(--border); background: var(--bg-box); font-size: 14px; line-height: 1.5; border-spacing: 3px; }
.infobox caption, .infobox .ib-title { font-size: 17px; font-weight: 700; text-align: center; padding: 6px 4px; background: var(--bg-accent); }
.infobox .ib-sub { text-align: center; font-size: 13px; padding: 2px 4px 6px; }
.infobox .ib-img { text-align: center; padding: 8px 4px 2px; }
.infobox .ib-img img { max-width: 240px; width: 100%; height: auto; border: 1px solid var(--border-soft); background: var(--bg); }
.infobox .ib-cap { text-align: center; font-size: 13px; padding: 0 6px 8px; color: var(--text-sub); }
.infobox .ib-head { text-align: center; font-weight: 700; background: var(--bg-accent); padding: 3px 4px; }
.infobox th { text-align: left; vertical-align: top; padding: 3px 6px 3px 4px; width: 34%; font-weight: 700; }
.infobox td { vertical-align: top; padding: 3px 4px; }
.infobox ul { margin: 0; padding-left: 16px; }

/* 表 */
.wikitable { border-collapse: collapse; border: 1px solid var(--border); background: var(--bg-box); font-size: 14px; line-height: 1.5; margin: 10px 0 16px; }
.wikitable th, .wikitable td { border: 1px solid var(--border); padding: 5px 9px; vertical-align: top; }
.wikitable th { background: var(--bg-head); text-align: center; font-weight: 700; }
.wikitable caption { font-weight: 700; padding: 4px; text-align: left; }
.wikitable td.nw, .wikitable th.nw { white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* 図 */
.thumb { float: right; clear: right; margin: 6px 0 14px 22px; border: 1px solid var(--border-soft); background: var(--bg-box); padding: 4px; width: 230px; font-size: 13px; line-height: 1.45; }
.thumb img { width: 100%; height: auto; display: block; border: 1px solid var(--border-soft); }
.thumb figcaption { padding: 4px 2px 2px; }
figure { margin: 0; }

/* 出典 */
.reflist { font-size: 14px; line-height: 1.55; column-width: 34em; column-gap: 32px; }
.reflist ol { margin: 6px 0; padding-left: 34px; }
.reflist li { break-inside: avoid; margin-bottom: 4px; overflow-wrap: anywhere; }
.reflist .back { font-weight: 700; margin-right: 4px; }
.reflist .acc { color: var(--text-sub); }

/* 下部の関連項目の箱・分類 */
.navbox { clear: both; border: 1px solid var(--border); background: var(--bg-box); font-size: 14px; line-height: 1.6; margin: 24px 0 0; width: 100%; border-spacing: 2px; }
.navbox .nb-title { background: var(--bg-accent); text-align: center; font-weight: 700; padding: 4px; }
.navbox th { background: var(--bg-head); text-align: right; padding: 4px 10px; white-space: nowrap; width: 1%; vertical-align: top; }
.navbox td { padding: 4px 8px; }
.navbox td a + a::before, .navbox td span + a::before, .navbox td a + span::before { content: " · "; color: var(--text); font-weight: 700; }
.catlinks { clear: both; border: 1px solid var(--border); background: var(--bg-box); padding: 6px 10px; margin-top: 14px; font-size: 14px; }
.catlinks a + a::before { content: " | "; color: var(--text); }
.w-foot { clear: both; margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border-faint); font-size: 13px; color: var(--text-sub); line-height: 1.6; }
.clear { clear: both; }

/* 狭い画面 */
@media (max-width: 1000px) {
  .w-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px 40px; }
  .w-side { padding-top: 14px; }
  .w-toc { position: static; max-height: none; border: 1px solid var(--border); background: var(--bg-box); padding: 10px 14px; }
  .w-toc ul ul { display: none; }
  .w-header-in { padding: 8px 16px; flex-wrap: wrap; gap: 10px; }
  .w-user { display: none; }
  .w-search { order: 3; flex-basis: 100%; max-width: none; }
}
@media (max-width: 720px) {
  .infobox { float: none; width: 100%; margin: 8px 0 16px; }
  .thumb { float: none; width: 100%; max-width: 320px; margin: 10px auto; }
  .w-title { font-size: 26px; }
  .reflist { column-width: auto; }
}
@media print {
  .w-header, .w-side, .w-tabs { display: none; }
  .w-wrap { display: block; }
}
