:root {
  --bg: #ffffff;
  --bg-alt: #f8f9fb;
  --bg-code: #f3f4f6;
  --border: #e4e7ec;
  --text: #1f2937;
  --text-muted: #6b7280;
  --brand-deep: #1f3a68;
  --brand-mid: #3d6aa0;
  --brand-light: #e8f0fb;
  --warn: #b45309;
  --warn-light: #fef3e0;
  --danger: #9a1f2c;
  --danger-light: #fdecee;
  --tip: #1f3a68;
  --tip-light: #eaf1fb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 13px;
}

body {
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", "-apple-system", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-feature-settings: "palt";
  word-break: normal;
  overflow-wrap: anywhere;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28mm 22mm 22mm;
}

/* 表紙 */
.cover {
  page-break-after: always;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40mm 22mm 22mm;
}

.cover-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cover-top img {
  height: 28px;
  width: auto;
}

.cover-top .vendor {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.cover-mid {
  margin-top: 60mm;
}

.cover-mid .doc-kind {
  font-size: 13px;
  color: var(--brand-mid);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.cover-mid h1 {
  font-size: 30px;
  color: var(--brand-deep);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  margin-bottom: 14px;
}

.cover-mid h2 {
  font-size: 16px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.6;
}

.cover-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 24px;
  row-gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.cover-meta dt {
  font-weight: 600;
  color: var(--text);
}

.cover-bottom {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 2px solid var(--brand-deep);
  padding-top: 10px;
}

/* セクション */
section {
  page-break-inside: auto;
}

section + section {
  margin-top: 32px;
}

h1.section-title {
  font-size: 21px;
  color: var(--brand-deep);
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--brand-deep);
}

h2.subsection {
  font-size: 16px;
  color: var(--brand-deep);
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 10px;
}

h3.subsubsection {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 10px;
}

ul, ol {
  margin: 8px 0 14px 22px;
}

li {
  margin-bottom: 5px;
}

li > ul, li > ol {
  margin-top: 5px;
}

/* リンク */
a {
  color: var(--brand-mid);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* コード */
code {
  font-family: "SF Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 0.92em;
  background: var(--bg-code);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--brand-deep);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 11.5px;
  overflow-x: auto;
  margin: 10px 0;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

/* テーブル */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 12px;
}

thead {
  background: var(--bg-alt);
}

th, td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--brand-deep);
}

tr:nth-child(even) td {
  background: var(--bg-alt);
}

/* コールアウト */
.callout {
  margin: 14px 0;
  padding: 12px 16px;
  border-left: 4px solid;
  border-radius: 0 4px 4px 0;
  font-size: 12.5px;
}

.callout .label {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
}

.callout.tip {
  background: var(--tip-light);
  border-color: var(--tip);
}

.callout.tip .label {
  color: var(--tip);
}

.callout.warn {
  background: var(--warn-light);
  border-color: var(--warn);
}

.callout.warn .label {
  color: var(--warn);
}

.callout.danger {
  background: var(--danger-light);
  border-color: var(--danger);
}

.callout.danger .label {
  color: var(--danger);
}

.callout.note {
  background: var(--bg-alt);
  border-color: var(--border);
}

.callout.note .label {
  color: var(--text-muted);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout code {
  background: rgba(31, 58, 104, 0.07);
}

/* インラインアイコン（svg） */
.icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  display: inline-block;
}

/* バッジ */
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 4px;
  letter-spacing: 0.04em;
}

.badge.deep { background: var(--brand-deep); color: #fff; }
.badge.mid { background: var(--brand-mid); color: #fff; }
.badge.outline { background: transparent; border: 1px solid var(--text-muted); color: var(--text-muted); }
.badge.warn { background: var(--warn); color: #fff; }
.badge.danger { background: var(--danger); color: #fff; }

/* 引用URL末尾リスト */
.references {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.references h2 {
  font-size: 13px;
  color: var(--brand-deep);
  margin-bottom: 8px;
  font-weight: 600;
}

.references ol {
  margin-left: 20px;
}

.references li {
  margin-bottom: 4px;
}

.references a {
  word-break: break-all;
}

/* 画像 / SVGダイアグラム */
figure {
  margin: 14px 0;
  text-align: center;
}

figure img, figure svg {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
  padding: 10px;
}

figcaption {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.diagram {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin: 12px 0;
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px;
  white-space: pre;
  line-height: 1.5;
  overflow-x: auto;
}

/* キーボードショートカット */
kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: "SF Mono", monospace;
}

/* 印刷 */
@media print {
  html { font-size: 12px; }
  main { padding: 0 18mm 12mm; max-width: none; }
  .cover { padding: 40mm 18mm 18mm; height: 250mm; }
  pre { font-size: 10.5px; }
  table { font-size: 11px; }
  a { color: var(--brand-mid); }
  .no-print { display: none; }

  /* セクションごとに改ページ。最初のh1（表紙）は除外クラスで除外 */
  section {
    page-break-before: always !important;
    break-before: page !important;
    page-break-inside: auto;
    padding-top: 14mm !important;
  }
  /* 改ページ後の上余白を確保するため、セクション直下の余計なマージンは抑える */
  section > .section-num { margin-top: 0; }
  section > h1.section-title { margin-top: 0 !important; }
  section + section { margin-top: 0 !important; }

  /* 見出しの直後で改ページしない */
  h1.section-title { page-break-after: avoid; break-after: avoid-page; }
  h2.subsection { page-break-after: avoid; break-after: avoid-page; margin-top: 16px; }
  h3.subsubsection { page-break-after: avoid; break-after: avoid-page; }

  /* 大きなブロックは分断不可 */
  pre, table, .callout, figure,
  .kpi, .kpi-grid, .timeline-item, .quote-card, .card, .case-card,
  .step-card, .keyword, .exercise-step, .shot { page-break-inside: avoid; break-inside: avoid; }
  .exercise-block { page-break-inside: auto; break-inside: auto; }

  /* 余計な余白の引き締め */
  figure { margin: 10px 0; }
  figcaption { margin-top: 4px; }
  .references { margin-top: 18px; padding-top: 10px; }
}

@page {
  size: A4 portrait;
  margin: 0;
}

/* === 拡張コンポーネント === */

/* セクション番号ラベル（SECTION 01 等） */
.section-num {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--brand-mid);
  font-weight: 600;
  margin-bottom: 4px;
}

/* リード段落（セクション冒頭の太めな説明） */
.lead {
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 14px;
}

/* メタ情報行（形式 / 対象 / 題材 等） */
.meta-row {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 18px;
  row-gap: 4px;
  font-size: 12px;
  color: var(--text);
  margin: 10px 0 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.meta-row dt {
  font-weight: 600;
  color: var(--brand-deep);
}

/* KPI カードグリッド（数値カード） */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.kpi {
  border-left: 3px solid var(--brand-deep);
  padding: 10px 14px;
  background: var(--bg-alt);
}

.kpi .num {
  font-size: 26px;
  font-weight: 700;
  color: var(--brand-deep);
  line-height: 1.1;
}

.kpi .lbl {
  font-size: 11.5px;
  color: var(--text);
  margin-top: 4px;
  font-weight: 600;
}

.kpi .src {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* 縦軸タイムライン */
.timeline {
  margin: 14px 0;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding: 6px 0 14px 14px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 12px;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--brand-deep);
  border-radius: 50%;
  background: #fff;
}

.timeline-date {
  font-size: 11px;
  color: var(--brand-mid);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.timeline-title {
  font-size: 13px;
  color: var(--brand-deep);
  font-weight: 600;
  margin: 2px 0 4px;
}

.timeline-body {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.7;
}

.timeline-src {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 引用カード（Boris Cherny 等） */
.quote-card {
  border-left: 3px solid var(--brand-mid);
  background: var(--bg-alt);
  padding: 12px 16px;
  margin: 10px 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.quote-author {
  font-size: 11px;
  color: var(--brand-deep);
  font-weight: 600;
  margin-bottom: 4px;
}

.quote-author .handle {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.quote-text {
  font-size: 12.5px;
  color: var(--text);
  font-style: italic;
  line-height: 1.7;
  margin: 4px 0;
}

.quote-text::before {
  content: "“";
  font-size: 18px;
  color: var(--brand-mid);
  vertical-align: -2px;
  margin-right: 2px;
}

.quote-src {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* カードグリッド（2列） */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.card-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.card-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
  font-size: 11.5px;
  line-height: 1.6;
}

.card .card-tag {
  display: inline-block;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.card .card-title {
  font-size: 12.5px;
  color: var(--brand-deep);
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

.card .card-src {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  word-break: break-all;
}

.card.accent {
  border-left: 3px solid var(--brand-deep);
}

/* 事例カード（数値強調） */
.case-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}

.case-card .case-shot {
  width: 100%;
  height: 100px;
  object-fit: cover;
  object-position: top;
  border-radius: 3px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.case-card .case-title {
  font-size: 12px;
  color: var(--brand-deep);
  font-weight: 600;
}

.case-card .case-num {
  font-size: 18px;
  color: var(--brand-deep);
  font-weight: 700;
  margin: 4px 0 2px;
}

.case-card .case-body {
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
}

.case-card .case-src {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 6px;
  word-break: break-all;
}

/* 番号付きステップカード（ベストプラクティス5等） */
.step-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 10px 0 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.step-card:last-child {
  border-bottom: none;
}

.step-card .step-no {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-deep);
  letter-spacing: -0.02em;
  line-height: 1;
}

.step-card .step-body .step-title {
  font-size: 13px;
  color: var(--brand-deep);
  font-weight: 600;
  margin-bottom: 4px;
}

.step-card .step-body .step-text {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.7;
}

/* 演習ブロック（ハンズオンガイド向け） */
.exercise-block {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 16px 0;
  break-inside: auto;
  page-break-inside: auto;
}

.exercise-head {
  background: var(--brand-deep);
  color: #fff;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.exercise-head .ex-num {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #cbd5e1;
}

.exercise-body {
  padding: 12px 14px;
}

.exercise-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 3px;
  font-size: 11.5px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.exercise-meta dt {
  font-weight: 600;
  color: var(--brand-deep);
}

.exercise-meta dd code {
  font-size: 11px;
}

.exercise-step {
  margin-top: 10px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.exercise-step .step-label {
  font-size: 11px;
  color: var(--brand-mid);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.exercise-step .step-h {
  font-size: 12.5px;
  color: var(--brand-deep);
  font-weight: 600;
  margin: 6px 0;
}

/* スクショ枠 */
.shot {
  margin: 12px 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.shot img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
}

.shot .cap {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 5px;
  text-align: center;
}

/* キーワードグリッド */
.keyword-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.keyword {
  border-top: 2px solid var(--brand-deep);
  padding: 6px 10px 8px;
  background: #fff;
  break-inside: avoid;
}

.keyword .kw-en {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.keyword .kw-ja {
  font-size: 12px;
  color: var(--brand-deep);
  font-weight: 600;
  margin: 2px 0 4px;
}

.keyword .kw-body {
  font-size: 10.5px;
  color: var(--text);
  line-height: 1.5;
}

/* CTA ボックス（次の資料へ等） */
.cta {
  margin: 16px 0;
  padding: 14px 18px;
  background: var(--tip-light);
  border-left: 4px solid var(--brand-deep);
  break-inside: avoid;
}

.cta .cta-title {
  font-size: 13px;
  color: var(--brand-deep);
  font-weight: 600;
  margin-bottom: 6px;
}

.cta .cta-text {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.7;
}

/* ソース行（出典: ...） */
.src-line {
  font-size: 10.5px;
  color: var(--text-muted);
  margin: 6px 0 12px;
  word-break: break-all;
}
