/* ==========================================
   共通・ベース設定（note特有のフォントと色）
   ========================================== */
body {
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  /* note特有の、美しく読みやすいフォント指定 */
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Arial, sans-serif;
  /* 完全な黒(#000)ではなく、目に優しい微かな黒 */
  color: #222222;
  -webkit-font-smoothing: antialiased;
  line-height: 1.8;
  letter-spacing: 0.03em;
}

/* 1. ページ全体のスクロールをなめらかにする（お好みでhtmlタグに追加） */
html {
  scroll-behavior: smooth;
}

/* ==========================================
   ヘッダー（メニュー）
   ========================================== */
.note-header {
  border-bottom: 1px solid #eef0f4;
  background-color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
}

.header-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: #222222;
}

.nav-links a {
  color: #666666;
  text-decoration: none;
  font-size: 14px;
  margin-left: 20px;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: #222222;
}

/* ==========================================
   レイアウト・記事エリア
   ========================================== */
.note-container {
  max-width: 660px; /* noteの読みやすい絶妙な記事幅 */
  margin: 0 auto;
  padding: 60px 20px;
}

/* ==========================================
   大見出し・テキスト要素
   ========================================== */
/* 記事のメイントラック（タイトル） */
.article-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 48px;
  letter-spacing: -0.02em;
}

/* 記事内の大見出し (h2) */
.note-article h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.5;
  margin-top: 56px;
  margin-bottom: 24px;
  position: relative;

}

/* 1. 小見出し (h3)
------------------------------------------ */
.note-article h3 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  margin-top: 40px;
  margin-bottom: 20px;
  color: #222222;
}



/* 本文パラグラフ */
.note-article p {
  font-size: 16px;
  margin-top: 0;
  margin-bottom: 32px; /* 段落間の広い余白 */
  word-break: break-word;
}


/* 3. 太字強調・マーカー (strong / em)
------------------------------------------ */
/* noteの太字はパッと見を邪魔しない、ちょうどいい太さ */
.note-article strong {
  font-weight: 700;
  color: #000000; /* 強調部分は完全な黒に近づける */
}

/* 蛍光ペン風マーカー（もし使う場合用のカスタムクラス） */
.note-marker {
  background: linear-gradient(transparent 60%, #dbf4e7 60%); /* noteの緑に馴染む薄いクリップ色のマーカー */
  font-weight: 700;
}


/* ==========================================
   コードボックス（ソースコード表示）
   ========================================== */
.code-box {
  background-color: #1e1e1e; /* ダークモード風背景 */
  border-radius: 8px;
  overflow: hidden;
  margin-top: 24px;
  margin-bottom: 40px;
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}

/* コードボックス上部の言語名エリア */
.code-header {
  background-color: #2d2d2d;
  padding: 6px 16px;
  display: flex;
  align-items: center;
}

.code-lang {
  color: #aaaaaa;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
}

/* --- コード本文（折り返し対応版） --- */
.code-box pre {
  margin: 0;
  padding: 20px;
  /* 変更：横スクロールを消し、自動折り返しを有効にする */
  overflow-x: visible;
  white-space: pre-wrap;       /* CSS3（主要ブラウザすべて対応） */
  white-space: -moz-pre-wrap;  /* 古いFirefox用 */
  white-space: -prev-wrap;     /* 古いOpera用 */
  white-space: -o-pre-wrap;    /* 古いOpera用 */
  word-wrap: break-word;       /* Internet Explorer / Edge用 */
}

.code-box code {
  color: #f8f8f2;
  font-size: 14px;
  line-height: 1.6;
  /* 追加：英単語の途中でも容赦なく折り返す（URLや長い変数名の対策） */
  word-break: break-all;
}

/* --- コードボックスのヘッダーを調整 --- */
.code-header {
  background-color: #2d2d2d;
  padding: 6px 16px;
  display: flex;
  justify-content: space-between; /* 言語名とボタンを両端に分ける */
  align-items: center;
}

/* --- note風コピーボタンのスタイル --- */
.copy-btn {
  background: transparent;
  border: none;
  color: #aaaaaa; /* 通常時は控えめなグレー */
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px; /* アイコンと文字の間隔 */
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s ease;
}

/* ホバー時に少し白く浮かび上がるnoteの挙動 */
.copy-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

/* コピー完了時のスタイル（緑色にする場合。文字だけの変化でもOK） */
.copy-btn.copied {
  color: #47cb89; /* noteの「コピーしました」に近いグリーン */
}

/* SVGアイコンのサイズ微調整 */
.icon-copy {
  display: inline-block;
  vertical-align: middle;
}

/* ==========================================
   画像（note特有の角丸とキャプション）
   ========================================== */
.note-image {
  margin: 40px 0; /* 前後の文章との絶妙なディスタンス */
  padding: 0;
  width: 100%;
}

.note-image img {
  width: 100%;
  height: auto;
  display: block;
  /* note特有の、ほんの少しだけ角を丸くする設定（強すぎない丸み） */
  border-radius: 6px;
  /* 念のための画像保護や歪み防止 */
  object-fit: cover;
}

/* 画像の下につく説明文（キャプション） */
.note-image figcaption {
  font-size: 14px;
  color: #666666; /* 本文より少し薄いグレー */
  text-align: center; /* 中央寄せ */
  margin-top: 12px;
  line-height: 1.5;
  /* 飾りのないシンプルなフォント感 */
  letter-spacing: 0.02em;
}
/* ==========================================
   目次（note特有のミニマルデザイン）
   ========================================== */
.note-toc {
  background-color: #f5f8fa; /* note特有の、非常に薄い上品なグレー */
  border-radius: 8px;
  padding: 24px;
  margin-top: 40px;
  margin-bottom: 48px;
}

/* 「目次」のタイトル部分 */
.toc-title {
  font-size: 16px;
  font-weight: 700;
  color: #222222;
  margin-bottom: 16px;
  line-height: 1;
}

/* リスト全体のスタイル消去 */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* 各目次アイテム */
.toc-list li {
  margin-bottom: 12px;
  line-height: 1.5;
  position: relative;
  padding-left: 16px; /* 左側の縦線用の余白 */
}

/* 最後のアイテムだけ下の余白をゼロに */
.toc-list li:last-child {
  margin-bottom: 0;
}

/* 左側の「緑色の縦線」を擬似要素で再現 */
.toc-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px; /* 文字の高さに合わせる微調整 */
  bottom: 4px;
  width: 2px; /* 細い縦線 */
  background-color: #23c175; /* noteのブランドカラーに近いグリーン */
  border-radius: 1px;
}

/* 目次内のリンク */
.toc-list a {
  color: #333333;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s ease;
}

/* ホバー時に少し濃くなる（または下線が薄く出る）noteの挙動 */
.toc-list a:hover {
  color: #000000;
  text-decoration: underline;
}

/* ==========================================
   【追加】note風の仕切り線（一直線）
   ========================================== */
.note-divider {
  border: none;               /* ブラウザ標準の立体的な線を消す */
  border-top: 1px solid #c8cbcc; /* note特有の、非常に薄く上品なグレーの1本線 */
  margin: 56px 0;             /* 上下にnoteらしい広めの余白（56px）を設定 */
  width: 100%;                /* 記事幅いっぱいに広げる */
}

/* ==========================================
   ヘッダー内の全文コピーボタン（サイズ微調整版）
   ========================================== */
.header-copy-btn {
  background-color: transparent;
  border: 1px solid #23c175;     /* noteブランドのグリーン */
  color: #23c175;
  border-radius: 9999px;          /* きれいな丸み */
  padding: 4px 10px;              /* 文字長に合わせて余白を微調整 */
  font-size: 12px;                /* 少しだけコンパクトに */
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
  vertical-align: middle;
}

/* ホバー時に緑色で塗りつぶす */
.header-copy-btn:hover {
  background-color: #23c175;
  color: #ffffff;
}

/* コピー完了時のスタイル */
.header-copy-btn.copied {
  background-color: #1eab67;
  border-color: #1eab67;
  color: #ffffff;
}

.header-copy-btn svg {
  display: inline-block;
  flex-shrink: 0;
}

[id] {
  scroll-margin-top: 80px;
  }

/* ==========================================
   スマートフォン・タブレット用の最適化（レスポンシブ）
   ========================================== */
@media screen and (max-width: 768px) {

[id] {
  scroll-margin-top: 100px;
  }

  /* 1. 全体の余白調整（スマホに合わせてタイトに） */
  .note-container {
    padding: 32px 16px; /* 上下の余白を狭め、左右の余白を16pxに固定 */
  }

  /* 2. ヘッダーの調整（はみ出し・重なり防止） */
  .note-header {
    height: auto; /* 高さを固定せず中身に合わせる */
    padding: 10px 0;
  }

  .header-container {
    padding: 0 16px;
    flex-wrap: wrap; /* 要素が増えた場合に折り返せるように */
    gap: 12px;       /* ロゴと各ボタンの間に程よい隙間を作る */
  }

  .logo {
    font-size: 16px; /* ロゴを少しコンパクトに */
  }

  .nav-links a {
    font-size: 13px;
    margin-left: 12px; /* メニュー同士の間隔を詰める */
  }

  .header-copy-btn {
    margin-left: 10px;
    padding: 4px 8px; /* 全文コピーボタンを少し小ぶりに */
    font-size: 11px;
  }

/* 3. タイトル・見出しのフォントサイズ調整 */
  .article-title {
    font-size: 24px;
    margin-bottom: 32px;
    line-height: 1.5;
  }

  .note-article h2 {
    font-size: 19px;
    margin-top: 40px;
    margin-bottom: 20px;
  }

  /* 4. 本文の調整 */
  .note-article p {
    font-size: 15px; /* スマホの画面に合わせて微調整 */
    margin-bottom: 24px;
    line-height: 1.75; /* 行間が空きすぎないよう微調整 */
  }

  /* 5. 画像とキャプション */
  .note-image {
    margin: 28px 0;
  }

  .note-image img {
    border-radius: 4px; /* 小さな画面に合わせて角丸を少し控えめに */
  }

  .note-image figcaption {
    font-size: 13px;
    padding: 0 8px; /* 長いキャプションが画面端にくっつかないように */
  }

  /* 6. 目次の調整 */
  .note-toc {
    padding: 18px; /* 内側の余白を削ってコンテンツ幅を確保 */
    margin-top: 32px;
    margin-bottom: 32px;
  }

  /* 7. 仕切り線の調整 */
  .note-divider {
    margin: 40px 0; /* 上下の広い余白をスマホ用に圧縮 */
  }
}
