/* 1. 全体設定 */
:root {
  --primary-color: #1e6091;
  --primary-hover: #1a4971;       /* ホバー色 */
  --text-main: #222222;           /* 基本テキスト色 */
  --text-muted: #555555;          /* 補足テキスト色 */
  --border-color: #d1d5db;         /* テーブル・区切り線 */
  --badge-red-bg: #fde8e8;         /* 締め切り等の赤強調背景 */
  --badge-red-text: #c81e1e;       /* 締め切り等の赤テキスト */
  --table-header-bg: #e5e7eb;      /* テーブルヘッダー背景色 */
  --table-stripe-bg: #f9fafb;      /* テーブル交互背景色 (偶数行) */
  --table-hover-bg: #e0f2fe;       /* ホバー選択時の背景色 (ライトブルー) */
  --table-hover-text: #0369a1;     /* ホバー選択時のテキスト色 */
  --code-bg: #f8fafc;              /* ソースコード背景色 */
  --code-border: #cbd5e1;          /* ソースコード枠線 */
}

* {
  box-sizing: border-box;
}

body {
  margin: 24px auto;
  padding: 0 24px;
  max-width: 1000px;
  background-color: #ffffff;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

/* インライン属性(align)のテキスト位置調整 */
h1[align], h2[align], h3[align], p[align], div[align] {
  text-align: left !important;
}

/* 2. 見出し装飾 */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  border-left: 5px solid var(--primary-color);
  padding-left: 12px;
  margin-top: 10px;
  margin-bottom: 20px;
  line-height: 1.4;
}

h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 40px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border-color);
}

h2 a {
  color: inherit;
  text-decoration: none;
}

h2.practice {
  background-color: #eff6ff;          /* 背景 */
  color: #1e3a8a;                     /* テキスト */
  padding: 12px 18px;                 /* 内側の余白 */
  margin-top: 48px;                   /* 前の文章との間の余白 */
  margin-bottom: 20px;
  border: 1px solid #bfdbfe;          /* 全体の薄い枠線 */
  border-left: 6px solid #1e6091;     /* 左側の太いアクセントライン */
  border-bottom: 1px solid #bfdbfe !important; /* 通常h2の下線を打ち消し */
  border-radius: 0 8px 8px 0;         /* 右側の角丸 */
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
}

h2.practice::before {
  content: "PRACTICE";
  background-color: #1e6091;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* 小見出し (h3) */
h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 24px;
  margin-bottom: 10px;
  padding-left: 8px;
  border-left: 3px solid var(--primary-color);
}

/* 3. 本文・リンク・強調表示 */
p {
  margin-top: 0;
  margin-bottom: 16px;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* 日付等の強調テキスト (<font color="#ff3300">) */
font[color], font[color="#ff3300"] {
  color: var(--badge-red-text) !important;
  background-color: var(--badge-red-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
}

/* 下線 (<u>)装飾 */
u {
  text-decoration: none;
  background: linear-gradient(transparent 80%, #fef08a 80%);
  font-weight: 600;
}

/* 4. C++ソースコード・実行結果表示 (<pre>, <code>) */
pre, code {
  font-family: Consolas, "Courier New", Courier, Monaco, "Fira Code", monospace;
  font-size: 14px;
}

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 16px 0;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

/* 5. 画像表示 (<img>) */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border: 0px solid var(--border-color);
  border-radius: 4px;
  padding: 4px;
  background-color: #ffffff;
}

/* 6. テーブル */
table {
  width: 100% !important;
  border-collapse: collapse !important;
  border: 1px solid var(--border-color) !important;
  margin: 20px 0 !important;
  font-size: 14px;
}

table[border], table td, table tr {
  border: 1px solid var(--border-color) !important;
}

table td {
  padding: 10px 12px !important;
  vertical-align: middle;
  white-space: nowrap;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
              color 0.2s ease,
              border-left-color 0.2s ease;
}


table td[align="left"] {
  white-space: normal !important;
  min-width: 280px;
}

/* ヘッダー行 */
table tbody tr:first-child {
  background-color: var(--table-header-bg) !important;
  font-weight: 600;
}

table tbody tr:first-child td {
  text-align: center !important;
  white-space: nowrap;
}

/* 偶数行・奇数行の背景色（ゼブラ表示） */
table tbody tr:nth-child(even) td {
  background-color: var(--table-stripe-bg);
}

table tbody tr:nth-child(odd) td {
  background-color: #ffffff;
}

/* マージされたセル (rowspan) の背景色固定 */
table tbody td[rowspan] {
  background-color: #ffffff !important;
  text-align: center;
  font-weight: 500;
}


table tbody tr:not(:first-child):hover td {
  background-color: var(--table-hover-bg) !important;
  color: var(--table-hover-text);
  cursor: pointer;
}


table tbody tr:not(:first-child):hover td:first-child {
  border-left: 4px solid var(--primary-color) !important;
  font-weight: bold;
}

/* 7. リスト・補足・フッター */
ul, ol {
  padding-left: 20px;
  margin-bottom: 20px;
}

li {
  margin-bottom: 6px;
}

div[align="left"] {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -10px;
  margin-bottom: 16px;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 30px 0 20px 0;
}

/* モバイル対応 */
@media (max-width: 768px) {
  body {
    padding: 0 12px;
  }
  table {
    display: block;
    overflow-x: auto;
  }
}

/* ==========================================================================
   参考情報ブロック (.info-box)
   ========================================================================== */
.info-box {
  background-color: #f8fafc;          
  border: 1px solid #cbd5e1;          
  border-left: 5px solid #0284c7;     
  border-radius: 6px;                
  padding: 16px 20px;
  margin: 24px 0;
}

/* 枠内の h3 見出しの調整 */
.info-box h3 {
  margin-top: 0;                     
  margin-bottom: 10px;
  padding-left: 0;                   
  border-left: none !important;    
  color: #0369a1;                 
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.info-box h3::before {
  content: "💡";                      
  margin-right: 8px;
  font-size: 1.1rem;
}

.info-box > *:last-child {
  margin-bottom: 0;
}



/* ==========================================================================
   C++ ソースコード表示 (VS Code Dark風)
   ========================================================================== */
/* 1. コードブロック全体コンテナ */
.code-block {
  margin: 24px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #334155;
  background-color: #0f172a;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* 2. コードブロック上部ヘッダー */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #1e293b;
  padding: 8px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: #94a3b8;
  border-bottom: 1px solid #334155;
  font-weight: 600;
}

.code-title {
  color: #e2e8f0;
}

/* C++ バッジ表示 */
.code-lang {
  background-color: #2563eb;
  color: #ffffff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* 3. コード領域 (<pre><code>) */
pre, code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Fira Code", monospace;
}

/* 単体 <pre> タグ */
pre {
  background-color: #0f172a !important;
  color: #f1f5f9;
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 8px;
  border: 1px solid #334155;
  line-height: 1.6;
  font-size: 14px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
  -moz-tab-size: 4;
}

.code-block pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background-color: transparent !important;
}

pre code {
  background: none !important;
  padding: 0 !important;
  color: inherit;
  font-size: inheri;
}

/* 4. コンソール出力 */
code.console-output {
  color: #38bdf8 !important;
}

.code-block:has(code.console-output) {
  background-color: #090d16;
  border-color: #1e293b;
}

.code-block:has(code.console-output) .code-header {
  background-color: #0f172a;
}


/* 1. コードブロック背景と標準テキスト */
pre[class*="language-"],
code[class*="language-"] {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
  font-family: Consolas, "Cascadia Code", "Courier New", monospace !important;
  font-size: 14px;
  line-height: 1.5;
  text-shadow: none !important;
}

/* 2. トークン別カラー設定 */

/* コメント (緑色) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #57a64a !important;
  font-style: normal;
}

/* キーワード: class, public, void, return, using, namespace 等 (青色) */
.token.keyword,
.token.boolean,
.token.selector {
  color: #569cd6 !important;
  font-weight: normal;
}

/* プリプロセッサ: #include, #define 等 (グレー/紫色) */
.token.macro,
.token.directive-hash,
.token.directive {
  color: #9b9b9b !important;
}

/* クラス名・構造体名 (エメラルドグリーン) */
.token.class-name,
.token.type-definition {
  color: #4ec9b0 !important;
}

/* 関数名・メソッド名 (薄黄色) */
.token.function {
  color: #dcdcaa !important;
}

/* 文字列リテラル (赤茶色/オレンジ) */
.token.string,
.token.char {
  color: #ce9178 !important;
}

/* 数値 (薄緑色) */
.token.number {
  color: #b5cea8 !important;
}

/* 演算子・区切り記号: +, =, ::, {}, () 等 (明るいグレー) */
.token.operator,
.token.punctuation {
  color: #d4d4d4 !important;
}

/* 変数名・メンバ変数 (水色) */
.token.property,
.token.variable {
  color: #9cdcfe !important;
}