/* ============================================================
   AtMarkPlus — 和文組版と印刷のCSS（§11）
   すべて .atmarkplus-doc の内側にだけ効く
   ============================================================ */
.atmarkplus-doc {
  --am-paper: #fbfaf7;
  --am-ink: #1b1b19;
  --am-dim: #55524c;
  --am-hair: #bfbab0;
  --am-link: #2f4f7f;
  --am-alert: #b03a2b;
  --am-code-bg: #f1efe9;
  --am-shade: #efece5;    /* 表の見出しと表側の網掛け（@table style=shade / stripe / boxed） */
  --am-stripe: #f7f5f0;   /* 表の1行おきの地色（@table style=stripe） */
  --am-mincho: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "BIZ UDPMincho", "Noto Serif JP", serif;
  --am-gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, "BIZ UDPGothic", "Noto Sans JP", Meiryo, sans-serif;
  /* UD: Mac はヒラギノ角ゴ、Windows は BIZ UD ゴシック（0.9.21） */
  --am-ud: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "BIZ UDGothic", "Yu Gothic", YuGothic, Meiryo, sans-serif;
  --am-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "BIZ UDGothic", monospace;
  /* プロポーショナル（0.9.21）。P付きのフォントを先に並べ、文字詰め（palt）も効かせる */
  --am-mincho-p: "Hiragino Mincho ProN", "BIZ UDPMincho", "MS PMincho", "Yu Mincho", YuMincho, "Noto Serif JP", serif;
  --am-gothic-p: "Hiragino Sans", "BIZ UDPGothic", "MS PGothic", "Yu Gothic", YuGothic, "Noto Sans JP", Meiryo, sans-serif;
  /* @doc の font / heading-font は、組版時に article の style で --am-body-font / --am-heading-font に入る */

  box-sizing: border-box;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  /* 左右の +1px は印刷の余白（@media print の padding: 0 1px）と同じ。行の幅をそろえ、改行位置を印刷と一致させる */
  /* 余白は @doc の margin-*（組版時に article の style で --am-mt / --am-mr / --am-mb / --am-ml に入る） */
  padding: var(--am-mt, 20mm) calc(var(--am-mr, 20mm) + 1px) var(--am-mb, 20mm) calc(var(--am-ml, 20mm) + 1px);
  background: var(--am-paper);
  color: var(--am-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 10px 34px rgba(0, 0, 0, .45);

  font-family: var(--am-body-font, var(--am-mincho));
  font-size: var(--am-fontsize, 10.5pt);
  line-height: 1.85;
  text-align: justify;
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
  font-kerning: normal;
}
.atmarkplus-doc[data-paper="A4-landscape"] { width: 297mm; min-height: 210mm; }
.atmarkplus-doc[data-paper="B5"] { width: 182mm; min-height: 257mm; }
.atmarkplus-doc[data-paper="B5-landscape"] { width: 257mm; min-height: 182mm; }
/* プロポーショナルの書体を選んだところだけ、かなや句読点の余白を詰める（0.9.21） */
.atmarkplus-doc[style*="--am-mincho-p"], .atmarkplus-doc[style*="--am-gothic-p"] { font-feature-settings: "palt" 1; }
/* 用紙なし: 画面の幅いっぱいに組む。am-fit は、用紙を指定した原稿を狭い画面で見るとき（editor.js、0.9.76） */
.atmarkplus-doc[data-paper="none"],
.atmarkplus-doc.am-fit { width: auto; min-height: 0; margin: 0; padding: 28px 36px; }
.atmarkplus-doc *, .atmarkplus-doc *::before, .atmarkplus-doc *::after { box-sizing: border-box; }

/* ---- 表題 ---- */
.atmarkplus-doc .am-titleblock { text-align: center; margin: 0 0 2.4em; }
.atmarkplus-doc .am-title {
  font-family: var(--am-heading-font, var(--am-gothic)); font-weight: 700; font-size: 1.6em;
  line-height: 1.5; letter-spacing: .04em; margin: .2em 0 .5em;
}
.atmarkplus-doc .am-author, .atmarkplus-doc .am-date { margin: 0; text-indent: 0; text-align: center; line-height: 1.8; }
.atmarkplus-doc .am-date { color: var(--am-dim); }

/* ---- 見出し（ゴシック）---- */
.atmarkplus-doc .am-h { font-family: var(--am-heading-font, var(--am-gothic)); font-weight: 700; line-height: 1.5; text-align: left; }
.atmarkplus-doc .am-h1 { font-size: 1.4em; margin: 1.9em 0 .7em; }
.atmarkplus-doc .am-h2 { font-size: 1.2em; margin: 1.6em 0 .55em; }
.atmarkplus-doc .am-h3 { font-size: 1.05em; margin: 1.3em 0 .4em; }
.atmarkplus-doc .am-titleblock + .am-h,
.atmarkplus-doc .am-toc + .am-h { margin-top: 1.2em; }
.atmarkplus-doc .am-secno { margin-right: 1em; font-variant-numeric: tabular-nums; }

/* ---- 段落: 段落の直後の段落だけ1字下げ、段落間の余白なし（§11.3）----
   見出し・図表・箇条書き・引用・囲み・段組み・コードなど、まとまりの直後の段落と、
   囲みなどの中の最初の段落は字下げしない。
   p + .am-gap + p は、プレビューのページの隙間（paginate.js）を挟んだ段落 */
.atmarkplus-doc p { margin: 0; text-indent: 0; }
/* 字下げはしない（0.9.39 で変更。以前は段落の1文字目を1文字分下げていた） */

/* ---- 箇条書き ---- */
.atmarkplus-doc .am-list { margin: .5em 0; padding-left: 2em; }
.atmarkplus-doc .am-list .am-list { margin: .1em 0; }
.atmarkplus-doc .am-list li { margin: .1em 0; }
.atmarkplus-doc .am-list li > p { text-indent: 0; }
.atmarkplus-doc ol.am-list ol.am-list { list-style-type: lower-alpha; }
.atmarkplus-doc ol.am-list ol.am-list ol.am-list { list-style-type: lower-roman; }

/* ---- 引用・囲み ---- */
.atmarkplus-doc .am-quote {
  margin: .9em 0 .9em 1em; padding: 0 0 0 1em;
  border-left: 2px solid var(--am-hair); color: #33322e;
}
.atmarkplus-doc .am-note {
  margin: 1em 0; padding: .7em 1.1em;
  text-align: left;   /* 図（@figure）の中に置いても、中身は中央に寄せない（1.3.2） */
  border: .6pt solid var(--am-ink);
  break-inside: avoid;
}
.atmarkplus-doc .am-note-title { font-family: var(--am-heading-font, var(--am-gothic)); font-weight: 700; margin-bottom: .3em; }

/* ---- 図・表の枠 ---- */
.atmarkplus-doc .am-float { margin: 1.3em 0; text-indent: 0; break-inside: avoid; }
/* 表だけは、長いときにページをまたいでよい（行の途中では割らない。0.9.15） */
.atmarkplus-doc .am-table { break-inside: auto; }
.atmarkplus-doc .am-tbl tr, .atmarkplus-doc .am-tbl thead { break-inside: avoid; }
.atmarkplus-doc .am-figure-body { text-align: center; }
.atmarkplus-doc .am-figure-body > p { text-indent: 0; }
.atmarkplus-doc .am-figure-body img, .atmarkplus-doc .am-figure-body svg { max-width: 100%; height: auto; }
.atmarkplus-doc .am-caption { font-size: .9em; line-height: 1.6; text-align: center; }
.atmarkplus-doc .am-figure .am-caption { margin-top: .5em; }
.atmarkplus-doc .am-table .am-caption { margin-bottom: .45em; }
.atmarkplus-doc .am-capno { font-family: var(--am-heading-font, var(--am-gothic)); font-weight: 700; margin-right: 1em; }

/* ---- 表 ---- */
.atmarkplus-doc .am-tbl {
  border-collapse: collapse; margin: 1em auto;
  font-size: .95em; line-height: 1.6; text-align: left;
}
.atmarkplus-doc .am-table .am-tbl { margin: 0 auto; }
.atmarkplus-doc .am-tbl th, .atmarkplus-doc .am-tbl td {
  padding: .3em .8em; vertical-align: top; text-align: left; overflow-wrap: anywhere;
}
.atmarkplus-doc .am-tbl th { font-family: var(--am-gothic); font-weight: 700; }
/* cols の * の列の見出し（1.2.3）。改行させず、見出しが1行に収まる幅を列に取らせる */
.atmarkplus-doc .am-tbl th.am-nowrap { white-space: nowrap; }
.atmarkplus-doc .am-tbl .am-al-center { text-align: center; }
.atmarkplus-doc .am-tbl .am-al-right { text-align: right; font-variant-numeric: tabular-nums; }
.atmarkplus-doc .am-rule-horizontal { border-top: 1pt solid var(--am-ink); border-bottom: 1pt solid var(--am-ink); }
/* 横に結合した見出し（下の行に小見出しがある）は、下に細い線を引いて範囲を示す */
.atmarkplus-doc .am-rule-horizontal thead th.am-span-col { border-bottom: .4pt solid var(--am-ink); }
/* 見出しが2段以上のときも、線は最後の見出し行の下だけ（上の行から結合して最後の行まで届くセルを含む） */
.atmarkplus-doc .am-rule-horizontal thead tr:last-child th,
.atmarkplus-doc .am-rule-horizontal thead th.am-head-last { border-bottom: .6pt solid var(--am-ink); }
/* 縦に結合したセルは上下の中央に置く */
.atmarkplus-doc .am-tbl .am-span-row { vertical-align: middle; }

/* 表の見た目（@table style / dense）。網掛けと地色は印刷でも出す */
.atmarkplus-doc .am-style-shade, .atmarkplus-doc .am-style-stripe, .atmarkplus-doc .am-style-boxed {
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.atmarkplus-doc .am-style-shade thead th, .atmarkplus-doc .am-style-stripe thead th, .atmarkplus-doc .am-style-boxed thead th,
.atmarkplus-doc .am-style-shade .am-rowhead, .atmarkplus-doc .am-style-stripe .am-rowhead, .atmarkplus-doc .am-style-boxed .am-rowhead {
  background: var(--am-shade);
}
.atmarkplus-doc .am-style-stripe tbody tr:nth-child(even) td { background: var(--am-stripe); }
.atmarkplus-doc .am-style-boxed { border: 1.2pt solid var(--am-ink); }
.atmarkplus-doc .am-style-boxed th, .atmarkplus-doc .am-style-boxed td { border: .6pt solid var(--am-ink); }
.atmarkplus-doc .am-dense th, .atmarkplus-doc .am-dense td { padding: .12em .5em; }

/* 合計行（@table foot）。上に線を引いて太字にし、網掛けのある表では地の色も付ける */
.atmarkplus-doc .am-tbl tfoot th, .atmarkplus-doc .am-tbl tfoot td { font-weight: 700; }
.atmarkplus-doc .am-rule-horizontal tfoot tr:first-child th,
.atmarkplus-doc .am-rule-horizontal tfoot tr:first-child td { border-top: .6pt solid var(--am-ink); }
.atmarkplus-doc .am-style-shade tfoot th, .atmarkplus-doc .am-style-shade tfoot td,
.atmarkplus-doc .am-style-stripe tfoot th, .atmarkplus-doc .am-style-stripe tfoot td,
.atmarkplus-doc .am-style-boxed tfoot th, .atmarkplus-doc .am-style-boxed tfoot td { background: var(--am-shade); }

/* ページをまたぐ表で、次のページの先頭に繰り返す見出しの行（画面だけ。paginate.js が差し込む） */
.atmarkplus-doc .am-rule-horizontal .am-repeat-head th { border-bottom: .6pt solid var(--am-ink); }
.atmarkplus-doc .am-style-shade .am-repeat-head th,
.atmarkplus-doc .am-style-stripe .am-repeat-head th,
.atmarkplus-doc .am-style-boxed .am-repeat-head th { background: var(--am-shade); }
/* 表側（@table rowhead）の右に縦の罫線 */
.atmarkplus-doc .am-rule-horizontal .am-rowhead-end { border-right: .6pt solid var(--am-ink); }
.atmarkplus-doc .am-rule-all th, .atmarkplus-doc .am-rule-all td { border: .6pt solid var(--am-ink); }

/* ---- コード ---- */
.atmarkplus-doc .am-code {
  margin: 1em 0; padding: .7em 1em;
  background: var(--am-code-bg); border-left: 2px solid var(--am-hair);
  font-family: var(--am-mono); font-size: .86em; line-height: 1.6;
  text-align: left; text-indent: 0;
  white-space: pre-wrap; overflow-wrap: anywhere;
  break-inside: avoid;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.atmarkplus-doc .am-code code { font: inherit; }
.atmarkplus-doc .am-c { font-family: var(--am-mono); font-size: .9em; }
/* チェックボックス {check:}（1.2.1）。塗りを使わず線だけで描く（印刷で「背景のグラフィック」を切っても刷れる） */
.atmarkplus-doc .am-check { display: inline-flex; align-items: baseline; gap: .3em; text-indent: 0; white-space: nowrap; }
.atmarkplus-doc .am-check-box {
  position: relative; display: inline-block; width: .9em; height: .9em; flex: none;
  border: 1px solid currentColor; border-radius: 2px; vertical-align: -.12em; box-sizing: border-box;
}
.atmarkplus-doc .am-checked .am-check-box::after {
  content: ''; position: absolute; left: 28%; top: 6%; width: 32%; height: 62%;
  border: solid currentColor; border-width: 0 .14em .14em 0; transform: rotate(45deg);
}
.atmarkplus-doc .am-check-date { font-size: .78em; color: var(--am-dim); font-variant-numeric: tabular-nums; }
/* ノート {note:}（1.2.4）。級名は am-memo（am-note は囲み @note のもの）。空は薄く、記入済みは色と番号を付ける。線だけで描くので印刷で背景を切っても刷れる */
.atmarkplus-doc .am-memo { display: inline-flex; align-items: center; gap: .08em; text-indent: 0; white-space: nowrap; color: var(--am-dim); }
.atmarkplus-doc .am-memo:not(.am-memo-on) { opacity: .55; }
.atmarkplus-doc .am-memo-on { color: var(--am-memo, #9a5a06); }
.atmarkplus-doc .am-memo-icon { width: 1em; height: 1em; flex: none; }
.atmarkplus-doc .am-memo-no { font-family: var(--am-gothic); font-size: .68em; font-weight: 700; font-variant-numeric: tabular-nums; }
/* 文書の末尾のノートの一覧（脚注と同じ組み） */
.atmarkplus-doc .am-memos {
  margin-top: 2em; padding-top: .6em;
  border-top: .6pt solid var(--am-hair);
  font-size: .85em; line-height: 1.7;
}
.atmarkplus-doc .am-memos-h { margin: 0 0 .3em; text-indent: 0; font-family: var(--am-gothic); font-weight: 700; }
.atmarkplus-doc .am-memos ol { list-style: none; margin: 0; padding: 0; }
.atmarkplus-doc .am-memos li { display: flex; gap: .6em; margin: .2em 0; }
.atmarkplus-doc .am-memos-no { flex: 0 0 auto; min-width: 1.2em; color: var(--am-memo, #9a5a06); font-family: var(--am-gothic); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- リンク・参照・脚注 ---- */
.atmarkplus-doc .am-link { color: var(--am-link); text-decoration: none; }
.atmarkplus-doc .am-link:hover { text-decoration: underline; }
.atmarkplus-doc .am-url { font-size: .9em; }
.atmarkplus-doc .am-ref { color: var(--am-link); text-decoration: underline dotted; text-underline-offset: .2em; }
.atmarkplus-doc .am-ref.am-missing { color: var(--am-alert); text-decoration: none; }
.atmarkplus-doc .am-fnref { font-size: .7em; line-height: 0; vertical-align: super; margin: 0 .1em; }
.atmarkplus-doc .am-fnref a { color: inherit; text-decoration: none; }
.atmarkplus-doc .am-footnotes {
  margin-top: 2.6em; padding-top: .6em;
  border-top: .6pt solid var(--am-hair);
  font-size: .85em; line-height: 1.7;
}
.atmarkplus-doc .am-footnotes ol { list-style: none; margin: 0; padding: 0; }
.atmarkplus-doc .am-footnotes li { display: flex; gap: .6em; margin: .2em 0; }
.atmarkplus-doc .am-fn-no { flex: 0 0 auto; min-width: 1.2em; font-variant-numeric: tabular-nums; }
.atmarkplus-doc .am-fn-no::after { content: ")"; }

/* ---- 目次 ---- */
.atmarkplus-doc .am-toc { margin: 1.2em 0 2.2em; text-indent: 0; }
.atmarkplus-doc .am-toc-title, .atmarkplus-doc .am-toc-sub {
  font-family: var(--am-heading-font, var(--am-gothic)); font-weight: 700; text-align: center; margin-bottom: .5em;
}
.atmarkplus-doc .am-toc-title { font-size: 1.2em; }
.atmarkplus-doc .am-toc-sub { margin-top: 1.2em; }
.atmarkplus-doc .am-toc ul { list-style: none; margin: 0; padding: 0; }
.atmarkplus-doc .am-toc a { display: block; padding: .1em 0; color: inherit; text-decoration: none; text-align: left; }
.atmarkplus-doc .am-toc .am-toc-l2 { padding-left: 1.6em; }
.atmarkplus-doc .am-toc .am-toc-l3 { padding-left: 3.2em; }

/* ---- 改ページ ---- */
.atmarkplus-doc .am-pagebreak { height: 0; margin: 1.8em 0; border-top: 1px dashed var(--am-hair); }
/* 空き（@spacer、0.9.47）。高さは原稿の height。前後の余白と重ならないように、自分の余白は持たない */
.atmarkplus-doc .am-spacer { margin: 0; padding: 0; }

/* ---- 解釈できなかった箇所 ---- */
.atmarkplus-doc .am-unknown {
  margin: 1em 0; padding: .45em .8em;
  border: 1px solid var(--am-alert); border-left-width: 3px;
  font-family: var(--am-mono); font-size: .8em; line-height: 1.55;
  text-align: left; text-indent: 0; break-inside: avoid;
}
.atmarkplus-doc .am-unknown-label { color: var(--am-alert); font-family: var(--am-gothic); margin-bottom: .2em; }
.atmarkplus-doc .am-unknown pre { margin: 0; white-space: pre-wrap; font: inherit; }
.atmarkplus-doc .am-error {
  margin: 1em 0; padding: .45em .8em; border: 1px dashed var(--am-alert);
  color: var(--am-alert); font-family: var(--am-gothic); font-size: .85em; text-indent: 0;
}

/* ---- プラグインの入れ物（hydrate を持つプラグインだけ）---- */
.atmarkplus-doc div.am-hydrate { display: contents; }
.atmarkplus-doc .am-hydrate-error { color: var(--am-alert); font-family: var(--am-gothic); font-size: .85em; }

@media screen {
  .atmarkplus-doc .am-unknown-inline { text-decoration: underline wavy var(--am-alert); text-underline-offset: .25em; }

  /* ---- ページ区切りのプレビュー（paginate.js）---- */
  .atmarkplus-doc.am-paged { min-height: 0; }
  .atmarkplus-doc.am-paged .am-pagebreak { height: 0; margin: 0; border: 0; }
  .atmarkplus-doc .am-page-top { margin-top: 0 !important; }
  /* 隙間の要素は「前のページの下余白・隙間・次のページの上余白」を1つで描く */
  .atmarkplus-doc .am-gap { display: block; height: 0; }
  /* 表の中の隙間は tr なので（display を変えると表の組みから外れる）、帯は中の div で描く（0.9.15） */
  .atmarkplus-doc .am-gap-row > td { padding: 0; border: 0; position: relative; }
  .atmarkplus-doc .am-gap-fill { position: absolute; top: 0; height: 100%; }
  .atmarkplus-doc .am-gap, .atmarkplus-doc .am-gap-fill {
    text-indent: 0;
    background: linear-gradient(to bottom,
      transparent 0,
      transparent calc(100% - var(--am-mt, 20mm) - 18px),
      var(--am-gap-color, #101215) calc(100% - var(--am-mt, 20mm) - 18px),
      var(--am-gap-color, #101215) calc(100% - var(--am-mt, 20mm)),
      transparent calc(100% - var(--am-mt, 20mm)));
  }
  .atmarkplus-doc .am-gap-end { background: none; }
}

/* ---- 印刷（§11.2）---- */
@media print {
  /* 空のノートは紙に刷らない。記入済みは、番号で末尾の一覧と結ぶので残す（1.2.4） */
  .atmarkplus-doc .am-memo:not(.am-memo-on) { display: none; }
  .atmarkplus-doc {
    /* 左右の 1px は、Safari が紙面の右端ちょうどにある罫線（囲みの枠など）を切り落とすのを防ぐため */
    width: auto; min-height: 0; margin: 0; padding: 0 1px;
    box-shadow: none; background: none;
  }
  .atmarkplus-doc .am-h { break-after: avoid; }
  /* 見出しを次の2行と同じページに置く。Safari は break-after: avoid を無視するので、
     見出しの下に本文2行分の見えない高さを足して、それごと途中で割らない（paginate.js の規則と同じ） */
  .atmarkplus-doc .am-h { break-inside: avoid; }
  .atmarkplus-doc .am-h::after { content: ""; display: block; }
  .atmarkplus-doc .am-h1::after { height: 2.65em; margin-bottom: -2.65em; }
  .atmarkplus-doc .am-h2::after { height: 3.1em; margin-bottom: -3.1em; }
  .atmarkplus-doc .am-h3::after { height: 3.55em; margin-bottom: -3.55em; }
  .atmarkplus-doc .am-float, .atmarkplus-doc .am-code { break-inside: avoid; }
  .atmarkplus-doc .am-ref { color: inherit; text-decoration: none; }
  .atmarkplus-doc .am-pagebreak { border: 0; margin: 0; break-after: page; }
  /* chapter-break（0.9.46）でプレビューが次のページに送った章は、印刷でもそこから始める */
  .atmarkplus-doc .am-chapter-top { break-before: page; }
  .atmarkplus-doc .am-gap, .atmarkplus-doc .am-gap-row, .atmarkplus-doc .am-repeat-head { display: none !important; }
}
