/* --- 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;
}

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);
}

/* --- カード型レイアウト --- */

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  flex: 1 1 280px;
  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);
}

/* --- 的中率・回収率の大きい数字表示 --- */

.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;
}

/* --- 的中率・回収率の色付きゲージバー --- */

.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;
}

/* --- 内訳テーブルの式別セル（_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;
}

/* --- 優位/不利/ねらい目バッジ（着度数・内訳表の「傾向」列） --- */

.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;
}

/* --- 馬場×クラス×年度パネルの「特徴」コールアウト（外枠優位等） --- */
/* はっきりした傾向がある場合だけ表示する（無理に特徴を出さない） */

.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;
}

/* --- 表の視認性向上（横スクロール対応・ヘッダー固定・縞模様） --- */

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
  margin-bottom: 16px;
}

.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;
}

/* --- 列ソート可能な表（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-bottom: 12px;
  border-bottom: 2px solid var(--mar-primary);
}

.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;
}

.page-search-input {
  width: 260px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9em;
}

.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-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);
}

/* --- 本文+右サイドバーの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;
}

.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;
}

.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;
}

.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;
}

/* 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);
}

@media (max-width: 800px) {
  .page-calendar-tab {
    float: none;
    width: auto;
    min-height: auto;
  }
}

/* --- レースカレンダーページの「本日の開催」（出馬表・コース詳細データへのリンク） --- */

.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;
}
