/* --- MARブランドカラー --- */
/* ボルドー（ワインレッド）をベースに、サイト全体のナビゲーション・見出し・
   アクセント装飾に使う。的中率/回収率ゲージや優位/不利バッジ等の「意味を持つ色」
   （青=中立、緑=有利、赤=不利）とは別軸の色として、ブランド色は混同しないよう
   ボルドー系でまとめる。 */
:root {
  --mar-primary: #7a2438;
  --mar-primary-dark: #5c1b2a;
  --mar-accent: #b04a5a;
  --mar-bg-accent: #fbeef0;
  --mar-bg-accent-strong: #f3d9de;

  /* セクション識別色（レースカレンダー/コース詳細データ/AI成績）。
     ボルドーの雰囲気は崩さず、サイドバーで「今どのページにいるか」を
     色とアイコンで区別するためだけに使う差し色。コース詳細データ・AI成績は
     芝（緑）・ダート（茶）の色分けと混同しないよう、ボルドーと同系（赤紫〜赤）の
     色味でまとめつつ、互いに見分けられるよう色相をずらしている。 */
  --mar-section-calendar: #2f6690;
  --mar-section-courses: #7a3d6e;
  --mar-section-performance: #9c4a2f;
  --mar-section-trend: #2d7a4a;
}

body {
  font-family: sans-serif;
  color: #2a2a2a;
}

h1 {
  color: var(--mar-primary);
  border-bottom: 3px solid var(--mar-accent);
  padding-bottom: 8px;
}

h2 {
  color: var(--mar-primary);
}

/* --- セクション別のサブカラー（レースカレンダー/コース詳細データ/AI成績） --- */
/* ボルドーをベースに保ちつつ、見出し・カードの上線・表ヘッダーの背景に差し色を
   使うことで、サイドバーの文字色だけでなくページ全体としてどの種類のページに
   いるかひと目で分かるようにする（差し色はサイドバーと同じ変数を使う）。 */

body.section-calendar h1,
body.section-calendar h2 {
  color: var(--mar-section-calendar);
}

body.section-calendar h1 {
  border-bottom-color: var(--mar-section-calendar);
}

body.section-calendar .card {
  border-top-color: var(--mar-section-calendar);
}

body.section-calendar th {
  background: #e8f0f7;
}

body.section-courses h1,
body.section-courses h2 {
  color: var(--mar-section-courses);
}

body.section-courses h1 {
  border-bottom-color: var(--mar-section-courses);
}

body.section-courses .card {
  border-top-color: var(--mar-section-courses);
}

body.section-courses th {
  background: #f3e8f0;
}

body.section-performance h1,
body.section-performance h2 {
  color: var(--mar-section-performance);
}

body.section-performance h1 {
  border-bottom-color: var(--mar-section-performance);
}

body.section-performance .card {
  border-top-color: var(--mar-section-performance);
}

body.section-performance th {
  background: #f7e8e0;
}

/* --- 芝/ダートの色分け（コース一覧・右側タブの階層表示等） --- */

.race-type-turf {
  color: #2e7d32;
  font-weight: 600;
}

.race-type-dirt {
  color: #8d6e3a;
  font-weight: 600;
}

.nav {
  margin-bottom: 20px;
}

.nav a {
  text-decoration: none;
  color: var(--mar-accent);
}

table {
  border-collapse: collapse;
  margin-bottom: 30px;
  width: 100%;
}

th, td {
  border: 1px solid #aaa;
  padding: 6px 10px;
  text-align: center;
}

th {
  background: var(--mar-bg-accent);
  color: var(--mar-primary);
}

td a {
  text-decoration: none;
  color: #000;
}

td a:hover {
  text-decoration: underline;
  color: var(--mar-accent);
}

/* --- Home コンセプトヒーロー --- */

.home-concept {
  background: var(--mar-bg-accent);
  border-left: 5px solid var(--mar-accent);
  border-radius: 0 8px 8px 0;
  padding: 22px 24px 18px;
  margin: 8px 0 26px;
}

.home-concept-tagline {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--mar-primary);
  line-height: 1.35;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.home-concept-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.concept-chip {
  display: inline-block;
  background: var(--mar-primary);
  color: #fff;
  font-size: 0.76em;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.home-concept-desc {
  font-size: 0.88em;
  color: #555;
  margin: 0;
}

.home-concept-desc a {
  color: var(--mar-primary);
  font-weight: 600;
}

/* カード説明文 */
.card-desc {
  font-size: 0.87em;
  color: #555;
  line-height: 1.6;
  margin: 4px 0 10px;
}

.card-desc-sm {
  font-size: 0.82em;
  color: #888;
  margin: 0 0 6px;
}

/* --- カード型レイアウト --- */

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  flex: 1 1 280px;
  /* flexアイテムの既定値min-width:autoのままだと、中の表（.table-wrap、
     white-space:nowrapで内容に応じた幅を取る）の最小幅がそのままカードの
     最小幅になり、スマホ幅でカードだけページよりはみ出して見えてしまう。
     0にして、表側のoverflow-x:auto（横スクロール）にきちんと委ねる。 */
  min-width: 0;
  border: 1px solid #ddd;
  border-top: 3px solid var(--mar-accent);
  border-radius: 8px;
  padding: 16px 20px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2, .card h3 {
  margin-top: 0;
}

.card .card-link {
  display: inline-block;
  margin-top: 8px;
  font-weight: bold;
  color: var(--mar-primary);
}

/* カード内セカンダリセクション（補助情報） */
.card-secondary {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

.card-secondary h4 {
  font-size: 0.8em;
  font-weight: 700;
  color: #999;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

/* カード内折りたたみセクション（週別推移など） */
details.card-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

details.card-detail > summary {
  font-size: 0.8em;
  font-weight: 700;
  color: #999;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

details.card-detail > summary::-webkit-details-marker { display: none; }

details.card-detail > summary::after { content: " ▼"; font-size: 0.75em; }

details.card-detail[open] > summary::after { content: " ▲"; }

details.card-detail > summary:hover { color: var(--mar-primary); }

/* --- 的中率・回収率の大きい数字表示 --- */

.summary-stats {
  display: flex;
  gap: 24px;
  margin: 12px 0;
}

.summary-stat {
  text-align: center;
}

.summary-stat .value {
  display: block;
  font-size: 2em;
  font-weight: bold;
  color: var(--mar-primary);
}

.summary-stat .label {
  display: block;
  font-size: 0.85em;
  color: #666;
}

/* 馬場×クラス×年度パネルの概要カードで、最重要指標（平均勝ち時計）だけを大きく
   表示し、それ以外（人気・配当・体重・枠番馬番）はサブとして一回り小さくする */

.summary-stat-primary .value {
  font-size: 2.6em;
}

.summary-stat-secondary .value {
  font-size: 1.3em;
}

.summary-stat-secondary .label {
  font-size: 0.8em;
}

/* 概要カードの平均人気・配当・体重・枠番/馬番が、このコース全体（全×all×全期間）の
   値からはっきり離れている場合に色を付ける（advantage-badgeと同じ配色。閾値は
   全コースの実データから「ノイズではない差」のラインを集計して決めている）。
   高い方向（荒れ傾向・配当高め等）は緑、低い方向（堅め・配当低め等）は赤で示す。
   どちらが「得」かは指標ごとに異なるため、色は単に「平均からはっきり離れている」
   ことを示すだけで、優劣の意味は持たせない。 */
.value-trend-high {
  color: #1e7d34;
  font-weight: bold;
}

.value-trend-low {
  color: #c62828;
  font-weight: bold;
}

/* --- 週別推移の簡易バーチャート（CSSのみ、JSライブラリ不使用） --- */

.bar-chart {
  margin: 12px 0;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.9em;
}

.bar-row .bar-label {
  width: 90px;
  flex-shrink: 0;
  color: #555;
}

.bar-week-group {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #ddd;
}

.bar-week-group:last-child {
  border-bottom: none;
}

.bar-week-label {
  font-weight: bold;
  margin-bottom: 4px;
}

/* 単勝・複勝を横並びにし、週をまたいだ比較・推移を見やすくする */
.bar-week-cols {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.bar-week-col {
  flex: 1;
  min-width: 220px;
}

/* 的中率の行は回収率より控えめに見せる（回収率が主役、的中率は参考） */
.bar-row--secondary {
  font-size: 0.8em;
  opacity: 0.8;
}

/* 開催別成績「レース詳細」の、開催日1日分の的中率・回収率（小さく1行） */
.day-mini-stats {
  font-size: 0.85em;
  color: #555;
  margin: 2px 0 8px;
}

/* --- 的中率・回収率の色付きゲージバー --- */

.rate-gauge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 120px;
}

.rate-gauge .gauge-track {
  position: relative;
  flex: 1;
  min-width: 60px;
  background: #eee;
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}

.rate-gauge .gauge-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
}

.rate-gauge .gauge-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #333;
}

.rate-gauge .gauge-value {
  width: 56px;
  flex-shrink: 0;
  text-align: right;
  color: #333;
  font-size: 0.9em;
}

/* --- 式別ごとの回収率(主)・的中率(副)カード（AI成績ページ） --- */
/* 回収率を主役にして大きく、的中率は脇役として小さく添える。 */

.bet-stat-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
}

.bet-stat-card {
  flex: 1 1 160px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  text-align: center;
}

.bet-stat-label {
  font-weight: bold;
  margin-bottom: 8px;
}

.bet-stat-primary {
  margin-bottom: 8px;
}

.rate-big {
  font-size: 1.9em;
  font-weight: bold;
  line-height: 1.1;
}

.bet-stat-primary-label {
  display: block;
  font-size: 0.75em;
  color: #888;
}

.bet-stat-primary-gauge {
  margin-top: 6px;
  display: flex;
  justify-content: center;
}

.bet-stat-primary-gauge .rate-gauge {
  width: 100%;
  max-width: 160px;
}

.bet-stat-primary-gauge .gauge-track {
  height: 18px;
}

.bet-stat-primary-gauge .gauge-value {
  /* 数値は上の大きな数字（.rate-big）で既に表示しているため、ここでは重複させない */
  display: none;
}

.bet-stat-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85em;
  color: #666;
}

.bet-stat-secondary .rate-gauge {
  min-width: 0;
}

.bet-stat-n {
  margin-top: 8px;
  font-size: 0.8em;
  color: #888;
}

/* --- AI成績ページ: モデルタグ・3モデル比較レイアウト --- */
.model-tag {
  display: inline-block;
  font-size: 0.75em;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}
.model-tag-main { background: #6a1b9a; color: #fff; }
.model-tag-hit  { background: #9c27b0; color: #fff; }
.model-tag-val  { background: #ce93d8; color: #4a148c; }

.model-primary-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.model-primary-desc {
  font-size: 0.85em;
  color: #666;
  margin-bottom: 12px;
}

.sub-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.sub-model-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.sub-model-card-header {
  padding: 8px 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-bottom: 1px solid #ddd;
}
.sub-model-card-header-hit { background: #f3e5f5; border-left: 4px solid #9c27b0; }
.sub-model-card-header-val { background: #f3e5f5; border-left: 4px solid #6a1b9a; }

.sub-model-card-name {
  font-weight: bold;
  font-size: 1.05em;
}
.sub-model-card-desc {
  font-size: 0.82em;
  color: #666;
}

.sub-model-card-body {
  padding: 12px;
}
.sub-model-card-body .bet-stat-cards {
  gap: 8px;
}
.sub-model-card-body .bet-stat-card {
  flex: 1 1 130px;
  padding: 10px;
}

@media (prefers-color-scheme: dark) {
  .site-nav { background: #1a1a1a; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
  .home-concept { background: transparent; }
  .home-concept-desc { color: #aaa; }
  .card { background: transparent; border-color: #444; }
  .card-desc { color: #aaa; }
  .card-desc-sm { color: #777; }
  .card-secondary { border-top-color: #444; }
  .card-secondary h4 { color: #666; }
  details.card-detail { border-top-color: #444; }
  details.card-detail > summary { color: #666; }
  .model-primary-desc { color: #aaa; }
  .model-tag-val { background: #7b1fa2; color: #f3e5f5; }
  .sub-model-card { border-color: #444; }
  .sub-model-card-header { border-bottom-color: #444; }
  .sub-model-card-header-hit,
  .sub-model-card-header-val { background: #2a1535; }
  .sub-model-card-desc { color: #aaa; }
}
:root[data-theme="dark"] .site-nav { background: #1a1a1a; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
:root[data-theme="light"] .site-nav { background: #fff; }
:root[data-theme="dark"] .home-concept { background: transparent; }
:root[data-theme="dark"] .home-concept-desc { color: #aaa; }
:root[data-theme="dark"] .card { background: transparent; border-color: #444; }
:root[data-theme="dark"] .card-desc { color: #aaa; }
:root[data-theme="dark"] .card-desc-sm { color: #777; }
:root[data-theme="dark"] .card-secondary { border-top-color: #444; }
:root[data-theme="dark"] .card-secondary h4 { color: #666; }
:root[data-theme="dark"] details.card-detail { border-top-color: #444; }
:root[data-theme="dark"] details.card-detail > summary { color: #666; }
:root[data-theme="dark"] .model-primary-desc { color: #aaa; }
:root[data-theme="dark"] .model-tag-val { background: #7b1fa2; color: #f3e5f5; }
:root[data-theme="dark"] .sub-model-card { border-color: #444; }
:root[data-theme="dark"] .sub-model-card-header { border-bottom-color: #444; }
:root[data-theme="dark"] .sub-model-card-header-hit,
:root[data-theme="dark"] .sub-model-card-header-val { background: #2a1535; }
:root[data-theme="dark"] .sub-model-card-desc { color: #aaa; }
:root[data-theme="light"] .model-primary-desc { color: #666; }
:root[data-theme="light"] .model-tag-val { background: #ce93d8; color: #4a148c; }

/* --- 内訳テーブルの式別セル（_breakdown_table_html／_bet_stat_cell_html） --- */
/* 概要カード（.bet-stat-card）と同じ「上に回収率(大)・下に的中率(小)」の縦並びを
   1セルの中で再現し、内訳テーブルでもカードと同じ主従関係を一目で分かるようにする。 */

.cell-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cell-stat-primary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.cell-stat-primary .rate-big {
  font-size: 1.15em;
}

.cell-stat-primary-label {
  font-size: 0.7em;
  color: #888;
}

.cell-stat-primary-gauge .rate-gauge {
  width: 100%;
  max-width: 90px;
}

.cell-stat-primary-gauge .gauge-track {
  height: 10px;
}

.cell-stat-primary-gauge .gauge-value {
  /* 数値は.rate-bigで既に表示しているため、ここでは重複させない */
  display: none;
}

.cell-stat-secondary {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8em;
  color: #888;
  border-top: 1px dashed #ddd;
  padding-top: 4px;
  width: 100%;
  justify-content: center;
}

.cell-stat-secondary .rate-gauge {
  min-width: 0;
}

.cell-stat-secondary .gauge-value {
  font-size: 0.85em;
  color: #888;
}

/* --- セル内メイン/サブ2行表示（レース名+開催場、開催場名+開催回数） --- */

.cell-main-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-main-sub .main {
  font-weight: 600;
}

.cell-main-sub .sub {
  font-size: 0.8em;
  color: #888;
}

/* --- 日付の曜日表示（土曜=青、日曜・祝日=赤） --- */

.weekday-sat {
  color: #1565c0;
}

.weekday-sun {
  color: #d32f2f;
}

/* --- 今週の開催（競馬場・第○回、土曜/日曜それぞれの○日目） --- */
/* Homeの一番上、メインコンテンツより目立たせるため、カード形式で大きめに表示する */

.weekly-meeting-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  margin: 12px 0 24px;
}

.weekly-meeting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 22px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  min-width: 200px;
}

.weekly-meeting-item .main {
  font-size: 1.3em;
  font-weight: 700;
}

.weekly-meeting-item .sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 1em;
  color: #555;
}

/* --- 的中/不的中バッジ --- */

.hit-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: bold;
  color: white;
}

.hit-badge.win {
  background: #2e8b57;
}

.hit-badge.miss {
  background: #aaa;
}

/* 除外・取消（払い戻し）。的中/不的中ではないことを示す控えめな表示 */
.hit-badge.void {
  background: transparent;
  color: #999;
  font-weight: normal;
}

/* 高配当の的中は、バッジ・配当額ともに大きく強調する */
.hit-badge.hit-badge-big {
  background: #cc2222;
  font-size: 1em;
  padding: 3px 12px;
}

.hit-payout-big {
  font-weight: bold;
  font-size: 1.15em;
  color: #cc2222;
}

/* --- 優位/不利/ねらい目バッジ（着度数・内訳表の「傾向」列） --- */

.advantage-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.85em;
  font-weight: bold;
  white-space: nowrap;
}

.advantage-badge.high {
  background: #e6f4ea;
  color: #1e7d34;
  border: 1px solid #1e7d34;
}

.advantage-badge.low {
  background: #fdeaea;
  color: #c62828;
  border: 1px solid #c62828;
}

/* --- データセクション内インサイト文（チャート/テーブルの直後） --- */

p.data-insight {
  margin: 6px 0 14px;
  padding: 8px 14px;
  background: var(--mar-bg-accent);
  border-left: 3px solid var(--mar-accent);
  border-radius: 0 4px 4px 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--mar-text);
}

/* about.html AI通算成績テーブル */

.about-ai-stats {
  margin: 16px 0 20px;
  padding: 16px 20px;
  background: var(--mar-bg-accent);
  border-left: 4px solid var(--mar-accent);
  border-radius: 0 6px 6px 0;
}

.about-ai-stats h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.about-ai-stats table {
  width: auto;
  margin-bottom: 8px;
}

.about-ai-stats-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--mar-text-sub);
}

/* ========================================
   about.html ページ専用レイアウト
   ======================================== */

/* コンテンツ3分割カード（出馬表/AI成績/コース別データ） */
.about-content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 20px 0 32px;
}

.about-content-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  border-top: 3px solid var(--mar-accent);
  padding: 18px 14px 14px;
  text-align: center;
  transition: box-shadow 0.15s;
}

.about-content-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.about-content-icon {
  font-size: 1.8em;
  line-height: 1;
  margin-bottom: 8px;
}

.about-content-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95em;
}

.about-content-card p {
  margin: 0 0 10px;
  font-size: 0.82em;
  color: #444;
  line-height: 1.5;
}

.about-content-card a {
  display: inline-block;
  font-size: 0.82em;
  color: var(--mar-accent);
  text-decoration: none;
  font-weight: bold;
}

.about-content-card a:hover {
  text-decoration: underline;
}

/* 運営者ボックス */
.about-author-box {
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 18px 22px;
  line-height: 1.8;
}

/* MARコンセプトタグライン */
.about-mar-concept {
  font-size: 1.08em;
  font-weight: 600;
  color: var(--mar-primary);
  border-left: 4px solid var(--mar-accent);
  padding: 6px 14px;
  margin: 0 0 14px;
  background: var(--mar-bg-accent);
  border-radius: 0 6px 6px 0;
}

/* 特徴量グループ（メイン/サブ） */
.about-feature-section {
  margin: 14px 0 18px;
}

.about-feature-group-label {
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mar-accent);
  margin: 14px 0 6px;
  padding: 0;
  border: none;
}

.about-feature-badges--sub li {
  opacity: 0.85;
}

/* AI特徴量バッジリスト */
.about-feature-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
  padding: 0;
  list-style: none;
}

.about-feature-badges li {
  background: var(--mar-bg-accent);
  border: 1px solid var(--mar-bg-accent-strong);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.88em;
}

.about-feature-badges li strong {
  color: var(--mar-primary);
}

/* MARモデル3枚カード */
.about-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}

.about-model-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.6;
}

.about-model-card-main {
  border-left: 4px solid #6a1b9a;
  background: #fbf7fe;
}

.about-model-card-hit {
  border-left: 4px solid #9c27b0;
}

.about-model-card-val {
  border-left: 4px solid #ce93d8;
}

.about-model-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.about-model-card p {
  margin: 0 0 8px;
  font-size: 0.88em;
  color: #555;
}
.about-model-detail {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 0.82em;
  color: #666;
  line-height: 1.7;
}
.about-model-detail li { margin: 0; }

/* 運営方針ボックス */
.about-policy-box {
  background: #fafafa;
  border-left: 4px solid var(--mar-accent);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 12px 0;
  line-height: 1.85;
}

/* お問い合わせカード */
.about-contact-box {
  background: var(--mar-bg-accent);
  border-radius: 8px;
  padding: 20px 24px;
  margin: 8px 0;
}

.about-contact-box a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 18px;
  background: var(--mar-primary);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95em;
}

.about-contact-box a:hover {
  background: var(--mar-primary-dark);
}

@media (prefers-color-scheme: dark) {
  .about-mar-concept { background: transparent; }
  .about-content-card { border-color: #555; background: transparent; }
  .about-content-card p { color: inherit; }
  .about-author-box { background: transparent; border-color: #555; }
  .about-feature-badges li { background: transparent; border-color: #666; }
  .about-model-card { border-color: #555; background: transparent; }
  .about-model-card-main { background: transparent; }
  .about-model-card p { color: inherit; }
  .about-model-detail { color: inherit; }
  .about-policy-box { background: transparent; }
  .about-contact-box { background: transparent; }
}
:root[data-theme="dark"] .about-mar-concept { background: transparent; }
:root[data-theme="dark"] .about-content-card { border-color: #555; background: transparent; }
:root[data-theme="dark"] .about-content-card p { color: inherit; }
:root[data-theme="dark"] .about-author-box { background: transparent; border-color: #555; }
:root[data-theme="dark"] .about-feature-badges li { background: transparent; border-color: #666; }
:root[data-theme="dark"] .about-model-card { border-color: #555; background: transparent; }
:root[data-theme="dark"] .about-model-card-main { background: transparent; }
:root[data-theme="dark"] .about-model-card p { color: inherit; }
:root[data-theme="dark"] .about-model-detail { color: inherit; }
:root[data-theme="dark"] .about-policy-box { background: transparent; }
:root[data-theme="dark"] .about-contact-box { background: transparent; }
:root[data-theme="light"] .about-content-card { border-color: #ddd; background: #fff; }
:root[data-theme="light"] .about-model-card-main { background: #fbf7fe; }

/* --- 馬個別総評（horse-comment） --- */

.horse-comment-wrap {
  margin: 0 0 12px;
  padding: 10px 14px;
  background: #fff8e1;
  border-left: 4px solid #f9a825;
  border-radius: 0 5px 5px 0;
}

ul.horse-comment {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
}

ul.horse-comment li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #333;
  margin-bottom: 2px;
}

ul.horse-comment li:last-child {
  margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  .horse-comment-wrap {
    background: #2a2000;
    border-color: #c68400;
  }
  ul.horse-comment li {
    color: #e8e8e8;
  }
}

/* --- 馬場×クラス×年度パネルの「特徴」コールアウト（外枠優位等） --- */
/* はっきりした傾向がある場合だけ表示する（無理に特徴を出さない） */

.feature-callout {
  margin: 0 0 12px;
  padding: 8px 14px;
  border-left: 4px solid var(--mar-accent);
  background: var(--mar-bg-accent);
  font-weight: bold;
  color: var(--mar-primary-dark);
}

/* --- 着度数の積み上げ横バーチャート（人気/枠番/馬番） --- */
/* 行数の多い数表の代わりに、1着/2着/3着/着外の内訳を色分けした帯（合計100%）で
   視覚化する。出走自体が無いランクは行を出さない。有利/不利のバッジは固定幅の枠
   （.chakudo-badge-slot）に表示し、バッジの有無でバーの開始位置がズレないようにする。 */

.chakudo-legend {
  margin: 0 0 4px;
  font-size: 0.85em;
  color: #888;
}

.chakudo-chart {
  margin: 12px 0;
}

.chakudo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.95em;
}

.chakudo-row .chakudo-label {
  width: 28px;
  flex-shrink: 0;
  text-align: right;
  color: #555;
  font-weight: bold;
}

/* 血統別成績（種牡馬名）は人気/枠番/馬番の番号ラベルより長いため、幅を広げ
   左揃えにする（番号ラベルと同じ.chakudo-rowの構造を流用するため） */
.chakudo-row .peds-label {
  width: 160px;
  text-align: left;
}

/* 枠番別着度数チャートのラベルに、出馬表ページと同じ枠色を付ける */
.chakudo-row .waku-1 { background-color: white; color: #000; border: 1px solid #ccc; }
.chakudo-row .waku-2 { background-color: black; color: #fff; }
.chakudo-row .waku-3 { background-color: red; color: #fff; }
.chakudo-row .waku-4 { background-color: blue; color: #fff; }
.chakudo-row .waku-5 { background-color: yellow; color: #000; }
.chakudo-row .waku-6 { background-color: green; color: #fff; }
.chakudo-row .waku-7 { background-color: orange; color: #000; }
.chakudo-row .waku-8 { background-color: pink; color: #000; }
.chakudo-row [class*="waku-"] {
  border-radius: 4px;
  text-align: center;
}

.chakudo-row .chakudo-badge-slot {
  width: 100px;
  flex-shrink: 0;
}

.chakudo-row .chakudo-bar-track {
  display: flex;
  flex: 1;
  min-width: 160px;
  height: 28px;
  border-radius: 4px;
  background: #eee;
  /* overflow:hiddenにすると子要素のカスタムツールチップまで切り取られてしまうため、
     角丸は各セグメントの最初/最後の要素側だけに付ける */
}

.chakudo-segment:first-child {
  border-radius: 4px 0 0 4px;
}

.chakudo-segment:last-child {
  border-radius: 0 4px 4px 0;
}

.chakudo-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
  font-size: 0.9em;
  font-weight: bold;
  white-space: nowrap;
  overflow: visible;
}

/* ネイティブのtitle属性のツールチップは小さく見づらいため、
   大きく読みやすいカスタムツールチップをCSSのみで表示する */
.chakudo-segment .chakudo-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 1.05em;
  font-weight: normal;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.1s ease-in-out;
}

.chakudo-segment:hover .chakudo-tooltip {
  visibility: visible;
  opacity: 1;
}

.chakudo-segment.seg-1st {
  background: #1565c0;
}

.chakudo-segment.seg-2nd {
  background: #42a5f5;
}

.chakudo-segment.seg-3rd {
  background: #90caf9;
  color: #2a2a2a;
}

.chakudo-segment.seg-out {
  background: #e0e0e0;
  color: #555;
}

.chakudo-row .chakudo-value {
  width: 72px;
  flex-shrink: 0;
  text-align: right;
  color: #333;
  font-size: 0.9em;
}

/* --- 的中率重視・回収率重視モデルのTOP5（補助情報） ---
   メインの出走表（Score/Rank列）はバランス型のスコアのため、それが主役。
   ここは「参考までに」という位置づけが伝わるよう、小さめ・控えめな見た目にする。 */

.ai-sub-model-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0 16px;
  font-size: 0.82em;
  color: #666;
}

.ai-sub-model-picks-col {
  flex: 1 1 220px;
  padding: 8px 12px;
  border: 1px dashed #ddd;
  border-radius: 6px;
  background: #fcfcfc;
}

.ai-sub-model-picks-label {
  margin: 0 0 4px;
  font-weight: bold;
  color: #888;
}

.ai-sub-model-picks-list {
  margin: 0;
  padding-left: 1.4em;
}

.ai-sub-model-picks-list li {
  margin: 1px 0;
}

.ai-sub-model-picks-empty {
  margin: 0;
  color: #aaa;
}

/* --- オッズ更新ラベル --- */

.odds-update-label {
  font-size: 0.75rem;
  color: #888;
  margin: 0.25rem 0 0.25rem;
  text-align: right;
}
.odds-update-label--confirmed {
  color: #2e7d32;
  font-weight: bold;
}

/* --- AI指数帯グラフ --- */

.band-chart-wrap {
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
}

/* --- 表の視認性向上（横スクロール対応・ヘッダー固定・縞模様） --- */

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
  margin-bottom: 16px;
  /* iOSで横スクロールをなめらかに（モバイルで表の列が画面幅に収まらない場合の
     横スクロール操作のため）。 */
  -webkit-overflow-scrolling: touch;
}

/* table自体がwidth:100%（親要素=table-wrapの幅に強制的に収まる）のままだと、
   スマホ等の狭い画面で列が圧縮され、馬名等の日本語が1文字ずつ縦に折り返されて
   読みにくくなる（table-wrapのoverflow-x:autoが効かない）。table-wrap内のtable
   だけは内容に応じた幅を取れるようにし、セルの折り返しも止めて、収まらない分は
   table-wrap側の横スクロールに委ねる。 */
.table-wrap table {
  width: auto;
  min-width: 100%;
}

.table-wrap th,
.table-wrap td {
  white-space: nowrap;
}

/* 出馬表・レース結果表など「1行=1頭」で全頭を一度に見たい主要テーブルには
   縦スクロールをかけない（横スクロールのみ残す。馬体重等が長い列で
   幅が収まらない場合の対応のため）。 */
.table-wrap--full {
  max-height: none;
  overflow-y: visible;
}

.table-wrap table {
  margin-bottom: 0;
}

.table-wrap thead th {
  /* overflow-yをtable-wrap自身に持たせることで、ヘッダーの固定（sticky）が
     ページ全体ではなくこの表の内側だけで効くようにする（overflow-yが無いと
     sticky配置がビューポート基準になり、短い表が並ぶページ（Home等）で
     ヘッダーが他の要素に重なって表示されてしまう）。 */
  position: sticky;
  top: 0;
  z-index: 1;
}

table tbody tr:nth-child(even) {
  background: #f7f9fb;
}

table tbody tr:hover {
  background: #eef3f8;
}

/* スマートフォン幅では、表セルの余白・文字サイズを少し詰めて、横スクロールが
   必要になるまでに見える列数を増やす（横スクロール自体はtable-wrapで維持する）。 */
@media (max-width: 480px) {
  th, td {
    padding: 4px 6px;
    font-size: 0.85em;
  }

  /* 血統別着度数グラフ: 種牡馬名ラベル(160px)+ バー(160px)+ 値(72px)= 472px以上が
     スマホ幅(約390px)を超えて横スクロールが発生するため、各要素を縮小する */
  .chakudo-row .peds-label {
    width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chakudo-row .chakudo-bar-track {
    min-width: 60px;
  }
  .chakudo-row .chakudo-value {
    width: 40px;
  }
}

/* --- 列ソート可能な表（sortable-table.js） --- */

table.sortable thead th {
  cursor: pointer;
  user-select: none;
}

table.sortable thead th:hover {
  background: #e2e6ea;
}

table.sortable thead th.sort-asc::after {
  content: " \25B2";
}

table.sortable thead th.sort-desc::after {
  content: " \25BC";
}

/* --- 折りたたみセクション（年度別など行数の多い内訳） --- */

details.breakdown {
  margin: 8px 0 16px;
}

details.breakdown summary {
  cursor: pointer;
  font-weight: bold;
  padding: 6px 0;
}

details.breakdown summary:hover {
  color: var(--mar-accent);
}

/* --- サイト共通ナビゲーション --- */

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 20px;
  padding: 10px 0 12px;
  border-bottom: 2px solid var(--mar-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.site-nav a {
  text-decoration: none;
  color: var(--mar-primary);
  font-weight: bold;
}

.site-nav a:hover {
  text-decoration: underline;
  color: var(--mar-accent);
}

/* サイト名（MAR）をどのページのヘッダーからも常に伝えられるようにするブランド表示 */
.site-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-right: 8px;
}

.site-brand-name {
  font-size: 1.4em;
  letter-spacing: 0.05em;
}

.site-brand-sub {
  font-size: 0.75em;
  font-weight: normal;
  color: #666;
}

/* --- ページの先頭へ戻るリンク（長いページの末尾用） --- */

.back-to-top {
  margin-top: 24px;
  text-align: center;
}

.back-to-top a {
  text-decoration: none;
  color: var(--mar-primary);
  font-weight: bold;
}

.back-to-top a:hover {
  color: var(--mar-accent);
  text-decoration: underline;
}

/* --- サイト共通フッター --- */

footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  text-align: center;
  color: #666;
  font-size: 0.85em;
}

footer p {
  margin: 4px 0;
}

.site-footer-brand {
  font-weight: bold;
  color: #444;
}

.site-footer-disclaimer {
  font-size: 0.9em;
}

.site-footer-updated {
  font-size: 0.85em;
  color: #888;
}

.site-footer-links a {
  margin: 0 8px;
  color: #888;
  text-decoration: underline;
}

.site-footer-links a:hover {
  color: var(--mar-accent);
}

.site-brand:hover .site-brand-sub {
  color: var(--mar-accent);
}

/* --- 競馬場・コースの検索ボックス（page-search.js） --- */

.page-search {
  position: relative;
  margin-left: auto;
  /* 狭い画面では.site-brandと並んだ際に画面幅を超えないよう縮小できるようにする
     （flex-basis 260pxを上限に、必要なら0まで縮む）。 */
  flex: 0 1 260px;
  min-width: 140px;
}

.page-search-input {
  /* 固定幅ではなく可変にし、狭い画面でも.site-nav（display:flex）の幅に収まるように
     する（固定幅だとモバイルでサイトロゴと並んだ際に画面からはみ出すことがあった）。 */
  width: 100%;
  max-width: 260px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9em;
  box-sizing: border-box;
}

.page-search-input:focus {
  outline: none;
  border-color: var(--mar-accent);
}

.page-search-results {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 5;
  width: 280px;
  max-width: 90vw;
  max-height: 320px;
  overflow-y: auto;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-search-results li {
  border-bottom: 1px solid #f0f0f0;
}

.page-search-results li:last-child {
  border-bottom: none;
}

.page-search-results a {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: #2a2a2a;
  font-size: 0.9em;
}

.page-search-results a:hover {
  background: var(--mar-bg-accent);
  color: var(--mar-primary);
}

/* --- ブレッドクラム（現在地の階層パス） --- */

.breadcrumb {
  margin: 0 0 16px;
  font-size: 0.9em;
  color: #666;
}

.breadcrumb a {
  text-decoration: none;
  color: var(--mar-accent);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-current {
  font-weight: bold;
  color: var(--mar-primary);
}

.venue-compare-current {
  color: var(--mar-primary);
}

/* --- 本文+右サイドバーの2カラムレイアウト（page-sidebar） --- */
/* 階層が深いページ（コース詳細・AI成績のコース別ページ等）で、兄弟ページ
   （他のコース・他の競馬場・他の年度等）へすぐ移動できるようにする。 */

.page-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.page-content {
  flex: 1;
  min-width: 0;
}

.page-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: 12px;
  background: var(--mar-bg-accent);
  border: 1px solid var(--mar-bg-accent-strong);
  border-top: 3px solid var(--mar-primary);
  border-radius: 8px;
  padding: 16px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

/* 「ひとつ上の階層へ」リンク：各セクション一覧より上に固定表示し、
   見た目でも下のセクション群と区別する */
.page-sidebar-up {
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--mar-bg-accent-strong);
  font-size: 0.9em;
}

.page-sidebar-up a {
  text-decoration: none;
  color: var(--mar-primary);
  font-weight: bold;
}

.page-sidebar-up a:hover {
  text-decoration: underline;
}

.page-sidebar h3 {
  margin: 16px 0 4px;
  font-size: 0.95em;
  color: var(--mar-primary);
}

.page-sidebar h3:first-of-type {
  margin-top: 0;
}

.page-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-sidebar li {
  margin-bottom: 6px;
  font-size: 0.9em;
}

.page-sidebar a {
  text-decoration: none;
  color: var(--mar-accent);
}

.page-sidebar a:hover {
  text-decoration: underline;
}

.page-sidebar-current {
  font-weight: bold;
  color: var(--mar-primary);
}

@media (max-width: 800px) {
  .page-layout {
    flex-direction: column;
  }

  .page-sidebar {
    flex-basis: auto;
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* --- セクション分けカード型UI + セクション間タブナビゲーション（section-tabs.js） --- */
/* 縦に長い「見出し→表→見出し→表」の羅列を避け、関連セクションをタブで切り替えて
   見せる。タブの中身（.section-panel）はカード調の見た目にして視覚的にグループ化する。 */

.tabbed-section {
  margin: 16px 0 24px;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  padding: 4px 0;
}

.section-tabs button {
  border: 1px solid #ccd6e0;
  background: #f4f6f8;
  color: #444;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 0.95em;
  font-weight: bold;
  cursor: pointer;
}

.section-tabs button:hover {
  background: #e9eef4;
}

.section-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--mar-primary);
  border-color: var(--mar-primary);
  border-bottom: 2px solid #fff;
}

/* メインタブ（馬場×クラス×年度）は他の参考データタブより大きくし、
   このページの主役であることを示す。参考データの方は小さなラベルで
   グループ分けする（辞書的に参照するサブデータという位置づけ）。 */
.section-tabs button.tab-main {
  font-size: 1.1em;
  padding: 10px 22px;
}

.section-tabs-sub-label {
  align-self: center;
  margin: 0 2px 0 10px;
  font-size: 0.85em;
  color: #888;
}

.section-panel-intro {
  margin: 0 0 14px;
  color: #555;
  font-size: 0.92em;
}

.section-panel {
  border: 1px solid #ccd6e0;
  border-radius: 0 8px 8px 8px;
  padding: 16px 20px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.section-panel > h3:first-child {
  margin-top: 0;
}

/* --- 年度別/週別トレンドの折れ線グラフ（sparkline_html.py） --- */
/* 的中率（左軸・青）と回収率（右軸・損益分岐点100%で色分け）を1つのグラフに重ねて
   表示し、何を表しているグラフかキャプション付きのカードで明示する。横軸の日付/年度は
   グラフの脇に置かず、対応する点の真下にSVG内テキストとして配置する。 */

.trend-section {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 16px;
}

.trend-item {
  flex: 1 1 320px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
}

.trend-item-label {
  font-weight: bold;
  font-size: 0.9em;
  margin-bottom: 4px;
  color: #444;
}

.trend-chart-wrap {
  display: flex;
}

.trend-chart {
  width: 100%;
  height: auto;
}

.trend-chart-breakeven {
  stroke: #999;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.trend-chart-breakeven-label {
  font-size: 8px;
  fill: #999;
}

.trend-chart-axis-label {
  font-size: 8px;
  fill: #888;
}

.trend-chart-axis-hit {
  fill: #aaa;
}

.trend-chart-axis-return {
  fill: #888;
}

.trend-chart-legend-label {
  font-size: 8px;
  fill: #555;
}

.trend-chart-hit-line {
  opacity: 0.8;
}

.trend-chart circle {
  cursor: pointer;
}

/* --- 馬場×クラスのインタラクティブ絞り込み（cross-filter.js） --- */

.cross-filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.cross-filter-controls select {
  margin-left: 6px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.cross-filter-empty {
  color: #777;
}

/* --- カード型のセクション見出し階層調整（.card内のh3/h4が詰まって見えないように） --- */

.card h4 {
  margin-bottom: 6px;
}

/* --- コース一覧（開催中/非開催で大小表示） --- */

.course-tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.course-tile.active {
  flex: 1 1 220px;
  border: 2px solid var(--mar-primary);
  border-radius: 8px;
  padding: 16px;
  background: var(--mar-bg-accent);
}

.course-tile.active .place-name {
  font-size: 1.3em;
  font-weight: bold;
}

.course-tile.active .meeting-info {
  color: #555;
  font-size: 0.85em;
}

.course-tile.inactive {
  flex: 0 0 auto;
  padding: 4px 8px;
  font-size: 0.85em;
  color: #777;
}

/* --- カレンダーwidget --- */

.calendar-widget {
  text-align: center;
}

/* PC幅でサイドバー（page-calendar-tab）がfloat:rightになるとき、カレンダーwidgetが
   floatの下に落ちないようBFCを作る。iPad横向き（801px以上）でも正しく横並びになる。 */
body.section-calendar .calendar-widget {
  display: flow-root;
  max-width: 100%;
  overflow-x: auto;
}

.calendar-widget #calendar {
  border-collapse: collapse;
  margin: 20px auto;
  width: 80%;
}

.calendar-widget #calendar td, .calendar-widget #calendar th {
  border: 1px solid #ccc;
  padding: 10px;
  width: 14%;
  height: 80px;
  vertical-align: top;
}

.calendar-widget #calendar a {
  text-decoration: none;
  color: var(--mar-accent);
  font-weight: bold;
}

/* races/index.htmlの大きなカレンダーのみ表示する、日付ごとの開催場・メインレース一覧
   （calendar.js dayMeetingsHtml、window.raceMeetings由来）。複数開催がある日は
   セルの高さが自動的に伸びる（tdのheightは最小値として扱われるため）。 */
.calendar-day-meetings {
  margin-top: 4px;
  text-align: left;
}

.calendar-day-meeting {
  margin-top: 4px;
  line-height: 1.3;
}

.calendar-day-meeting-main {
  display: block;
  font-size: 0.78em;
  font-weight: bold;
  color: var(--mar-primary);
}

.calendar-day-meeting-main a {
  color: var(--mar-primary);
  text-decoration: underline;
}

.calendar-day-meeting-sub {
  display: block;
  font-size: 0.68em;
  color: #777;
}

/* 重賞（G1/G2/G3）バッジ。カレンダー・開催一覧・HOME等、レース名を表示する
   複数の場所で共通して使う小さな色付きラベル。G1=青、G2=赤、G3=緑の配色。 */
.grade-badge {
  display: inline-block;
  font-size: 0.85em;
  font-weight: bold;
  color: white;
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1.4;
}

.grade-badge-G1 {
  background-color: #1f4fd6;
}

.grade-badge-G2 {
  background-color: #c62828;
}

.grade-badge-G3 {
  background-color: #2e7d32;
}

.calendar-widget #calendar th.sat {
  color: #1f4fd6;
}

.calendar-widget #calendar th.sun {
  color: #c62828;
}

.calendar-widget #monthYear {
  font-size: 1.5em;
  margin: 0 10px;
}

.calendar-widget #todayRace {
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 1.2em;
}

.calendar-widget #todayRace a {
  /* デフォルトのdisplay:inlineのままpaddingを付けると、ボタンの背景が
     行の高さ分の領域を確保せず、直後の要素（カード等）に重なって表示されて
     しまうため、inline-blockにして確実に高さ分のスペースを確保する */
  display: inline-block;
  text-decoration: none;
  color: white;
  background-color: var(--mar-primary);
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: bold;
}

.calendar-widget #todayRace a:hover {
  background-color: var(--mar-primary-dark);
}

.calendar-widget #todayRace p {
  color: #555;
}

/* --- ページ右側に常時表示する、小さなカレンダー＋現在地タブ（page_calendar_tab_html） --- */
/* レースカレンダーページ（大きな月表示カレンダーを持つ）以外のどのページでも
   site_nav_html経由で必ず表示される。矢印での前後月移動の仕組み（calendar.js）は
   そのまま流用し、このタブの中だけで縮小表示する。 */

.page-calendar-tab {
  float: right;
  width: 230px;
  margin: 0 0 16px 16px;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  font-size: 0.8em;
  /* floatの高さがカレンダー＋階層表示自体の高さしかないと、本文がそこで
     右側いっぱいに広がってしまい、グラフ等の終端位置が途中でズレて見える。
     画面の高さ分だけは必ず確保し、本文の折り返し幅を画面下まで揃える。 */
  min-height: 100vh;
}

/* PC幅では常時表示の本文埋め込みのため、開閉ボタン・背景・閉じるボタンは不要 */
.page-calendar-tab-toggle,
.page-calendar-tab-backdrop,
.page-calendar-tab-close {
  display: none;
}

.page-calendar-tab .calendar-widget #calendar {
  width: 100%;
  margin: 6px auto;
}

.page-calendar-tab .calendar-widget #calendar td,
.page-calendar-tab .calendar-widget #calendar th {
  padding: 3px;
  height: 26px;
  width: auto;
}

.page-calendar-tab .calendar-widget #monthYear {
  font-size: 1em;
  margin: 0 6px;
}

.page-calendar-tab .calendar-widget #todayRace {
  margin: 8px 0;
  font-size: 1em;
}

.page-calendar-tab .calendar-widget #todayRace a {
  padding: 5px 10px;
  font-size: 0.9em;
}

.page-calendar-tab-location {
  list-style: none;
  padding: 8px 0 0;
  margin: 8px 0 0;
  border-top: 1px dashed #ccc;
}

.page-calendar-tab-location li {
  list-style: none;
}

/* 右側タブ下部のSNSリンク（X・Instagram） */
.page-calendar-tab-sns {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 0;
  margin: 8px 0 0;
  border-top: 1px dashed #ccc;
}

.page-calendar-tab-sns li {
  list-style: none;
}

.page-calendar-tab-sns a {
  text-decoration: none;
  color: var(--mar-accent);
}

.page-calendar-tab-sns a:hover {
  text-decoration: underline;
}

/* --- 広告ユニット（本文中・サイドバー共通） --- */
/* ユーザーに広告が多いと感じさせないよう、本文中は意味のある区切りにのみ置き、
   間隔を空ける。サイドバーの広告はPCのみ表示し、モバイルでは下の@mediaで隠す
   （モバイルではサイドバー自体が本文の下に縦に流れるため、本文の合間に広告が
   増えすぎないようにするため）。 */
.ad-unit {
  margin: 20px 0;
  text-align: center;
}

.ad-unit--sidebar {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px dashed #ccc;
}

/* --- 書籍アフィリエイト（Amazon/楽天）の紹介ウィジェット --- */

.book-recommendation {
  margin: 16px 0;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
}

.book-recommendation-title {
  margin: 0 0 4px;
  font-weight: bold;
}

.book-recommendation-note {
  margin: 0 0 6px;
  font-size: 0.9em;
  color: #666;
}

.book-recommendation-links {
  margin: 0;
}

.affiliate-link {
  text-decoration: none;
  color: var(--mar-primary);
  font-weight: bold;
}

.affiliate-link:hover {
  color: var(--mar-accent);
  text-decoration: underline;
}

/* --- A8.net提携プログラムの紹介ウィジェット（お名前.com等、競馬関連に限らない） --- */

.a8-program-recommendation {
  margin: 16px 0;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
}

.a8-program-title {
  margin: 0 0 6px;
  font-weight: bold;
}

.a8-program-item {
  margin: 0 0 4px;
}

.a8-program-note {
  font-size: 0.9em;
  color: #666;
}

/* HOMEの1段下にレースカレンダー/AI成績/コース詳細データ、さらにその下に
   ページ固有の階層（競馬場・コース等）と、ネストするごとに字下げ+左線を入れて
   階層が深くなっていることを視覚的に示す */
.page-calendar-tab-sublevel {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 0;
  padding: 0 0 0 14px;
  border-left: 1px dashed #ccc;
}

.page-calendar-tab-location a {
  text-decoration: none;
  color: var(--mar-accent);
}

.page-calendar-tab-location a:hover {
  text-decoration: underline;
}

.page-calendar-tab-current {
  font-weight: bold;
  color: var(--mar-primary);
}

.nav-icon {
  display: inline-block;
}

/* レースカレンダー/コース詳細データ/AI成績のうち、今いる大分類の枝だけを
   差し色にする（ボルドーはベースのまま、識別のためだけの差し色として使う）。
   入れ子の下の階層（page-calendar-tab-sublevel）の左線にも同じ色を継承させ、
   どれだけ深い階層にいても「同じ系列にいる」ことが分かるようにする。 */
.page-calendar-tab-location li.nav-color-calendar > a,
.page-calendar-tab-location li.nav-color-calendar > span.page-calendar-tab-current {
  color: var(--mar-section-calendar);
}

.page-calendar-tab-location li.nav-color-calendar .page-calendar-tab-sublevel {
  border-left-color: var(--mar-section-calendar);
}

.page-calendar-tab-location li.nav-color-courses > a,
.page-calendar-tab-location li.nav-color-courses > span.page-calendar-tab-current {
  color: var(--mar-section-courses);
}

.page-calendar-tab-location li.nav-color-courses .page-calendar-tab-sublevel {
  border-left-color: var(--mar-section-courses);
}

.page-calendar-tab-location li.nav-color-performance > a,
.page-calendar-tab-location li.nav-color-performance > span.page-calendar-tab-current {
  color: var(--mar-section-performance);
}

.page-calendar-tab-location li.nav-color-performance .page-calendar-tab-sublevel {
  border-left-color: var(--mar-section-performance);
}

.page-calendar-tab-location li.nav-color-trend > a,
.page-calendar-tab-location li.nav-color-trend > span.page-calendar-tab-current {
  color: var(--mar-section-trend);
}

.page-calendar-tab-location li.nav-color-trend .page-calendar-tab-sublevel {
  border-left-color: var(--mar-section-trend);
}

@media (max-width: 800px) {
  /* スマホ幅では常時の本文埋め込み（float）ではなく、ボタンで開く
     ポップアップ（ドロワー）にする。階層リストが長いページ（兄弟レース・
     兄弟競馬場が多い出馬表ページ等）だと、常時埋め込みのままでは縦に
     長い文字の塊になってしまい、本文がその下に押し下げられて見にくいため。 */
  .page-calendar-tab {
    float: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 82%;
    max-width: 320px;
    height: 100%;
    min-height: 0;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1001;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.25);
  }

  .page-calendar-tab.open {
    transform: translateX(0);
  }

  .page-calendar-tab-toggle {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 6px 10px;
    border: 1px solid var(--mar-primary);
    border-radius: 6px;
    background: #fff;
    color: var(--mar-primary);
    font-weight: bold;
    font-size: 0.9em;
    cursor: pointer;
  }

  .page-calendar-tab-close {
    display: block;
    margin-left: auto;
    border: none;
    background: none;
    font-size: 1.6em;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 0 8px;
  }

  .page-calendar-tab-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
  }

  .page-calendar-tab-backdrop.open {
    display: block;
  }

  /* サイドバー広告はPCのみ（モバイルで本文中の広告と合わせて多くなりすぎないため） */
  .ad-unit--sidebar {
    display: none;
  }
}

/* --- レースカレンダーページの「本日の開催」（出馬表・コース詳細データへのリンク） --- */

.today-meeting-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0;
  margin: 12px 0 20px;
}

.today-meeting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  min-width: 200px;
}

.today-meeting-item .main {
  font-weight: 600;
}

.today-meeting-item .sub {
  font-size: 0.85em;
  color: #888;
}

/* ===== 傾向分析日記 ===== */
.trend-article { max-width: 860px; }
.trend-header { margin-bottom: 1.5rem; }
.trend-date-badge {
  display: inline-block; background: #1565c0; color: #fff;
  font-size: 0.82em; font-weight: 700; padding: 3px 10px;
  border-radius: 3px; margin-bottom: 6px; letter-spacing: 0.05em;
}
.weekly-badge { background: #6a1b9a; }
.trend-title { font-size: 1.4rem; margin: 4px 0 2px; }
.trend-generated-at { font-size: 0.78em; color: #888; margin: 0; }

/* 統計ブロック */
.trend-stats-block { margin: 1.2rem 0 1.6rem; }
.trend-venues2 { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 1rem; }
.trend-venue-card2 {
  border: 1px solid #ddd; border-radius: 6px; padding: 10px 14px;
  min-width: 180px; flex: 1 1 180px;
}
.trend-venue-header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.trend-venue-name { font-weight: 700; font-size: 1.05em; }
.trend-venue-meta { font-size: 0.78em; color: #444; }
.trend-ground-badge {
  display: inline-block; font-size: 0.78em; font-weight: 700;
  padding: 1px 7px; border-radius: 3px; color: #fff;
}
.ground-good  { background: #2e7d32; }
.ground-soft  { background: #f57f17; }
.ground-heavy { background: #6d4c41; }
.ground-bad   { background: #b71c1c; }

/* コース別テーブル（各競馬場カード内）— グローバルth/trスタイルをリセット */
.trend-course-table { width: 100%; border-collapse: collapse; font-size: 0.85em; margin-bottom: 0; }
.trend-course-table th,
.trend-course-table td { border: none; text-align: left; }
.trend-course-table th { background: transparent; color: #888; font-weight: 600; padding: 2px 6px; border-bottom: 1px solid #ddd; }
.trend-course-table td { background: transparent; padding: 3px 6px; color: inherit; }
.trend-course-table tbody tr:nth-child(even) { background: transparent; }
.trend-course-table tbody tr:hover { background: transparent; }
.trend-course-table td.cs-type { font-weight: 700; width: 3em; }
.trend-course-table td.cs-upset { color: #444; }
.cs-baseline { font-size: 0.78em; color: #555; margin-left: 3px; }

/* 全体指標バー */
.trend-indicators { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 1rem; align-items: center; }
.trend-indicator { display: flex; align-items: center; gap: 6px; }
.trend-indicator-label { font-size: 0.85em; color: #333; }
.trend-indicator-sub { font-size: 0.8em; color: #444; }
.trend-upset-badge {
  display: inline-block; font-size: 0.85em; font-weight: 700;
  padding: 2px 10px; border-radius: 3px; color: #fff;
}
.upset-high { background: #b71c1c; }
.upset-mid  { background: #e65100; }
.upset-low  { background: #1565c0; }

/* AI成績テーブル — グローバルth/trスタイルをリセット */
.trend-stats-table { border-collapse: collapse; font-size: 0.88em; margin-top: 0.5rem; margin-bottom: 0; }
.trend-stats-table th { background: #f0f0f0; color: #333; padding: 5px 14px; text-align: center; border: 1px solid #ccc; font-weight: 600; }
.trend-stats-table td { background: transparent; color: #222; padding: 5px 14px; text-align: center; border: 1px solid #ccc; }
.trend-stats-table tbody tr:nth-child(even) { background: #f8f8f8; }
.trend-stats-table tbody tr:hover { background: #f0f0f0; }
.roi-plus { color: #1b5e20; font-weight: 700; }
.roi-minus { color: #b71c1c; font-weight: 700; }

/* HOME傾向日記カードのリスト */
.trend-recent-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.trend-recent-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.trend-recent-list li:last-child { border-bottom: none; }
.trend-recent-list a { color: var(--mar-section-trend); text-decoration: none; }
.trend-recent-list a:hover { text-decoration: underline; }

/* 本文 */
.trend-text-body { line-height: 1.85; }
.trend-text-body h2.trend-section-title {
  font-size: 1.1rem; margin: 1.8rem 0 0.5rem;
  padding-left: 8px; border-left: 4px solid #1565c0;
}
.trend-text-body h3.trend-section-title {
  font-size: 1rem; margin: 1.2rem 0 0.4rem;
  color: var(--mar-section-trend);
  padding-left: 8px; border-left: 3px solid var(--mar-section-trend);
}
.trend-text-body h4.trend-section-title {
  font-size: 0.95rem; margin: 1rem 0 0.3rem; color: var(--mar-section-trend);
}
.trend-text-body h5.trend-section-title {
  font-size: 0.9rem; margin: 0.8rem 0 0.2rem; color: #2a6640;
}
.trend-text-body p { margin: 0.5rem 0; }
.trend-md-list { margin: 0.5rem 0 0.5rem 1.2rem; padding: 0; }
.trend-md-list li { margin: 0.2rem 0; }
.trend-md-table-wrap { overflow-x: auto; margin: 0.8rem 0; }
.trend-md-table { border-collapse: collapse; font-size: 0.9em; min-width: 300px; margin-bottom: 0; }
.trend-md-table th { background: #f0f0f0; color: #333; padding: 5px 12px; text-align: left; border: 1px solid #ccc; font-weight: 600; }
.trend-md-table td { background: transparent; color: #222; padding: 4px 12px; border: 1px solid #ccc; }
.trend-md-table tbody tr:nth-child(even) { background: #f8f8f8; }
.trend-md-table tbody tr:hover { background: #f0f0f0; }

/* ナビ */
.trend-nav-bottom { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border, #eee); }

/* 一覧ページ */
.trend-index-list { list-style: none; padding: 0; margin: 0; }
.trend-index-entry { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border, #eee); }
.entry-badge {
  display: inline-block; font-size: 0.75em; font-weight: 700; padding: 2px 7px;
  border-radius: 3px; color: #fff; white-space: nowrap;
}
.entry-badge.daily  { background: #1565c0; }
.entry-badge.weekly { background: #6a1b9a; }

/* 週次ページ — セクション背景は常に白、内部テキストは常に暗色 */
.trend-day-section {
  margin: 1.5rem 0; padding: 1rem;
  background: #fff !important;
  border: 1px solid #b0d8be;
  border-left: 4px solid var(--mar-section-trend);
  border-radius: 6px;
  color: #1a1a1a;
}
.trend-day-title { font-size: 1.05rem; margin: 0 0 0.8rem; color: #1a1a1a; }
/* セクション内の全要素を暗色で統一 */
.trend-day-section .trend-venue-name { color: #1a1a1a; }
.trend-day-section .trend-venue-meta { color: #444; }
.trend-day-section .trend-course-table th { color: #555; border-color: #ddd; }
.trend-day-section .trend-course-table td { color: #1a1a1a; }
.trend-day-section .trend-course-table td.cs-upset { color: #444; }
.trend-day-section .trend-indicator-label { color: #333; }
.trend-day-section .trend-indicator-sub { color: #444; }
.trend-day-section .trend-stats-table th { background: #f0f0f0; color: #222; border-color: #ccc; }
.trend-day-section .trend-stats-table td { background: transparent; color: #1a1a1a; border-color: #ccc; }
.trend-day-section .trend-stats-table tbody tr:nth-child(even) { background: #f8f8f8; }
.trend-day-section .trend-stats-table tbody tr:hover { background: #f0f0f0; }
.trend-day-section .cs-baseline { color: #555; }
.trend-pace-block { display: flex; align-items: center; gap: 8px; margin: 1rem 0; }
.trend-pace-badge {
  display: inline-block; font-size: 0.85em; font-weight: 700;
  padding: 2px 10px; border-radius: 3px; color: #fff;
}
.pace-front  { background: #1565c0; }
.pace-closer { background: #e65100; }
.pace-even   { background: #555; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .trend-venue-card2 { border-color: #444; }
  :root:not([data-theme="light"]) .trend-index-entry { border-color: #444; }
  /* trend-day-section は白背景固定 — 内部はすべて暗色で上書き */
  :root:not([data-theme="light"]) .trend-day-section .trend-venue-meta { color: #444; }
  :root:not([data-theme="light"]) .trend-day-section .trend-venue-name { color: #1a1a1a; }
  :root:not([data-theme="light"]) .trend-day-section .trend-course-table th { background: transparent; color: #555; border-color: #ddd; }
  :root:not([data-theme="light"]) .trend-day-section .trend-course-table td { background: transparent; color: #1a1a1a; }
  :root:not([data-theme="light"]) .trend-day-section .trend-course-table td.cs-upset { color: #444; }
  :root:not([data-theme="light"]) .trend-day-section .trend-course-table tbody tr:nth-child(even) { background: transparent; }
  :root:not([data-theme="light"]) .trend-day-section .trend-indicator-label { color: #333; }
  :root:not([data-theme="light"]) .trend-day-section .trend-indicator-sub { color: #444; }
  :root:not([data-theme="light"]) .trend-day-section .trend-stats-table th { background: #f0f0f0; color: #222; border-color: #ccc; }
  :root:not([data-theme="light"]) .trend-day-section .trend-stats-table td { background: transparent; color: #1a1a1a; border-color: #ccc; }
  :root:not([data-theme="light"]) .trend-day-section .trend-stats-table tbody tr:nth-child(even) { background: #f8f8f8; }
  :root:not([data-theme="light"]) .trend-day-section .trend-stats-table tbody tr:hover { background: #f0f0f0; }
  :root:not([data-theme="light"]) .trend-day-section .cs-baseline { color: #555; }
  :root:not([data-theme="light"]) .trend-text-body h3.trend-section-title { color: #5ec98a; border-left-color: #5ec98a; }
  :root:not([data-theme="light"]) .trend-text-body h4.trend-section-title { color: #5ec98a; }
  :root:not([data-theme="light"]) .trend-text-body h5.trend-section-title { color: #4aaa70; }
  :root:not([data-theme="light"]) .trend-md-table th { background: #333; color: #ddd; border-color: #555; }
  :root:not([data-theme="light"]) .trend-md-table td { background: transparent; color: #ddd; border-color: #555; }
  :root:not([data-theme="light"]) .trend-md-table tbody tr:nth-child(even) { background: #2a2a2a; }
  :root:not([data-theme="light"]) .trend-nav-bottom { border-top-color: #444; }
}

:root[data-theme="dark"] .trend-venue-card2 { border-color: #444; }
:root[data-theme="dark"] .trend-index-entry { border-color: #444; }
/* trend-day-section は白背景固定 — 内部はすべて暗色で上書き */
:root[data-theme="dark"] .trend-day-section .trend-venue-meta { color: #444; }
:root[data-theme="dark"] .trend-day-section .trend-venue-name { color: #1a1a1a; }
:root[data-theme="dark"] .trend-day-section .trend-course-table th { background: transparent; color: #555; border-color: #ddd; }
:root[data-theme="dark"] .trend-day-section .trend-course-table td { background: transparent; color: #1a1a1a; }
:root[data-theme="dark"] .trend-day-section .trend-course-table td.cs-upset { color: #444; }
:root[data-theme="dark"] .trend-day-section .trend-course-table tbody tr:nth-child(even) { background: transparent; }
:root[data-theme="dark"] .trend-day-section .trend-indicator-label { color: #333; }
:root[data-theme="dark"] .trend-day-section .trend-indicator-sub { color: #444; }
:root[data-theme="dark"] .trend-day-section .trend-stats-table th { background: #f0f0f0; color: #222; border-color: #ccc; }
:root[data-theme="dark"] .trend-day-section .trend-stats-table td { background: transparent; color: #1a1a1a; border-color: #ccc; }
:root[data-theme="dark"] .trend-day-section .trend-stats-table tbody tr:nth-child(even) { background: #f8f8f8; }
:root[data-theme="dark"] .trend-day-section .trend-stats-table tbody tr:hover { background: #f0f0f0; }
:root[data-theme="dark"] .trend-day-section .cs-baseline { color: #555; }
:root[data-theme="dark"] .trend-text-body h3.trend-section-title { color: #5ec98a; border-left-color: #5ec98a; }
:root[data-theme="dark"] .trend-text-body h4.trend-section-title { color: #5ec98a; }
:root[data-theme="dark"] .trend-text-body h5.trend-section-title { color: #4aaa70; }
:root[data-theme="dark"] .trend-md-table th { background: #333; color: #ddd; border-color: #555; }
:root[data-theme="dark"] .trend-md-table td { background: transparent; color: #ddd; border-color: #555; }
:root[data-theme="dark"] .trend-md-table tbody tr:nth-child(even) { background: #2a2a2a; }
:root[data-theme="dark"] .trend-nav-bottom { border-top-color: #444; }
:root[data-theme="dark"] .cs-baseline { color: #aaa; }
