/* サイト全体の見た目。色や余白は、デザインのキャンバス「トップページのイメージ」に合わせている。
   CSP（style-src 'self'）のため、見た目の指定はすべてこのファイルに書く（HTML に style="…" は書かない）。 */

:root {
  --accent: #2f5b9c;        /* サイドバーや選択中のボタンの青 */
  --accent-weak: #e8eef7;
  --bg: #eef1f5;
  --card: #ffffff;
  --head: #f5f6f8;
  --line: #dde2ea;
  --grid: #e6e9ef;
  --ink: #1c1e21;
  --ink-2: #44494f;
  --muted: #5f6670;
  --side-muted: #d6e0ef;
  --side-ring: #a9d2ff;     /* サイドバーの、円を描いて流れる文字（背景が濃い青なので、明るい青にしてある） */
  --side-navy: #183258;     /* サイドバーの下の横顔の影絵と、ページ下の行の帯（v15.5） */
  --warn-bg: #fff1e6;
  --warn-ink: #a65308;
  /* グラフの色（JavaScript 側の js/chartkit.js と同じ値） */
  --c-blue: #2f5b9c;
  --c-orange: #c96a12;
  --c-green: #1baf7a;
  --c-yellow: #eda100;
  --c-pink: #e87ba4;
  --c-ramp1: #5598e7;
  --c-ramp2: #86b6ef;
  /* 上げ下げの色（v15.6 から上昇が青・下落が赤。プラス＝青・マイナス＝赤。v15.5 までは日本の株価の表示にならって逆だった） */
  --c-up: #3f73b8;
  --c-down: #c24a36;
  --c-flat: #c3c8d0;
  --c-gray: #8a919b;        /* 残存営業日・出来高などの、色を付けない系列 */
  --c-nikkei: #d1242f;      /* 個別銘柄の値動きの日経平均の線（太い赤。v15.7） */
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
/* ページ内のリンク（#…）で移動するときは、なめらかに動かす（動きを減らす設定の人には、すぐに切り替える） */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
.card[id], .card-row[id] { scroll-margin-top: 12px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.7;
}

a { color: var(--accent); }
a:hover { color: #1f4573; }

h1, h2, h3, p, ul, ol, dl, dd, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sidebar :focus-visible, .tabbar :focus-visible { outline-color: #ffffff; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 30;
  padding: 10px 14px; border-radius: 6px; background: var(--ink); color: #ffffff;
}
.skip-link:focus { top: 8px; color: #ffffff; }

.icon {
  flex: 0 0 auto; width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 全体のレイアウト（左にサイドバー、右に本文） ---------- */

/* 背景の左 240px を青くしておく（ページが長いときも、サイドバーの色が下まで続くように） */
.layout { display: flex; min-height: 100vh; background: linear-gradient(90deg, var(--accent) 0 240px, transparent 240px); }

.sidebar {
  flex: 0 0 240px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background: var(--accent); color: #ffffff;
}

/* サイト名（文字だけ。ロゴは置かない） */
.brand, .mobile-brand { display: flex; align-items: center; text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.brand { min-height: 44px; padding: 0 12px; color: #ffffff; font-size: 19px; }
.brand:hover { color: #ffffff; }
.mobile-brand { display: none; color: var(--accent); font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 18px; }
.nav ul { display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 12px 4px; font-size: 12px; font-weight: 700; color: var(--side-muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border-radius: 6px; color: #ffffff; font-weight: 500; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, 0.14); }
.nav a[aria-current="page"] { background: #ffffff; color: var(--accent); font-weight: 700; }

/* メニューの下の空いた場所（v15.5）：横顔の影絵（紺）が、下のページ下の行（同じ紺）から立ち上がる。頭のうしろにぼかした光、
   頭のまわりの円に沿って英文がゆっくり回る（左へ向かって＝反時計回り。文字は影絵のうしろを通る）。絵は templates/base.html。
   絵は幅 240px（サイドバーの端から端まで）・高さ 336px（viewBox 240×336）で、空きの下の端に置く。空きが 336px より低いときは、
   絵全体を縮める（頭も円も切らない。preserveAspectRatio の meet で、まん中・下にそろえる）。空きが 240px より低いとき（英文が 8px より
   小さくなるとき）は円の英文を外し、120px より低いときは何も出さない。
   回転の中心は円の中心（絵の座標で 122.2, 124.8）。v15.4 までの「円の左上の 1/4 の弧だけ見える英文」は、この円に変わった */
.sidebar-art { flex: 1 1 auto; min-height: 0; display: flex; align-items: flex-end; margin: 0 -14px -20px; container-type: size; }
.sidebar-scene { display: block; width: 100%; height: 100%; max-height: 336px; }
.sidebar-glow { fill: url(#sidebar-glow); }
.sidebar-glow-0 { stop-color: #e8f1ff; stop-opacity: 0.3; }
.sidebar-glow-1 { stop-color: #cfe0f8; stop-opacity: 0.1; }
.sidebar-glow-2 { stop-color: #cfe0f8; stop-opacity: 0; }
.sidebar-ring-turn { transform-origin: 122.2px 124.8px; animation: sidebar-ring-turn 50s linear infinite; }
.sidebar-ring-text { fill: var(--side-ring); font-size: 11.5px; font-weight: 500; }
.sidebar-figure { fill: var(--side-navy); fill-rule: evenodd; }
@keyframes sidebar-ring-turn { to { transform: rotate(-360deg); } }
@container (max-height: 239px) { .sidebar-ring-turn { display: none; } }
@container (max-height: 119px) { .sidebar-scene { display: none; } }
@media (prefers-reduced-motion: reduce) { .sidebar-ring-turn { animation: none; } }

/* ページ下の行：紺の帯（影絵がここから立ち上がる。サイドバーの端と下の端まで。v15.5。v15.4 までは青の上に細い線） */
.sidebar-foot { margin: 0 -14px -20px; padding: 10px 26px 16px; background: var(--side-navy); }
.sidebar-foot small { font-size: 12px; color: var(--side-muted); }

.main { flex: 1 1 0; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.main:focus { outline: none; }
#dashboard { display: flex; flex-direction: column; gap: 16px; }

.tabbar { display: none; }
.to-top { display: none; }   /* 一番上へ戻るボタンは、スマホだけ（下の「画面の幅がせまいとき」） */

/* ---------- 見出し・ボタン・お知らせ ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head h1 { font-size: 24px; font-weight: 700; line-height: 1.4; }

.btn {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; color: var(--ink-2);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: #b9c1cd; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn .icon { width: 16px; height: 16px; }

.notice { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; font-size: 13px; }
.notice-warn { border-color: #f0cba8; background: var(--warn-bg); color: #6b3602; }

.panel {
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  display: flex; flex-direction: column; gap: 10px;
}
.panel h2 { font-size: 16px; }
.notes { list-style: disc; padding-left: 1.4em; display: flex; flex-direction: column; gap: 4px; }
/* About のサイト表明（文は templates の about.html に書いてある） */
.panel-statement { padding: 22px 20px; }
.statement { font-size: 20px; font-weight: 700; line-height: 1.5; color: var(--accent); }

.link-list { display: flex; flex-direction: column; }
.link-list a {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 4px;
  border-top: 1px solid var(--grid); color: var(--ink); text-decoration: none;
}
.link-list li:first-child a { border-top: 0; }
.link-list a:hover strong { text-decoration: underline; }
.link-list .icon { color: var(--accent); width: 22px; height: 22px; }
.link-list span { display: flex; flex-direction: column; line-height: 1.5; }
.link-list small { color: var(--muted); font-size: 12px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { padding: 8px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.plain th { background: var(--head); font-size: 12px; color: var(--ink-2); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* ---------- カード ---------- */

.card-row { display: flex; flex-wrap: wrap; gap: 16px; }

.card {
  flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
.card-wide { flex: 3 1 600px; }
.card-narrow { flex: 2 1 400px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--head);
}
.card-head h2 { font-size: 14px; font-weight: 700; line-height: 1.5; }
.card-meta { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.card-body { flex: 1 1 auto; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.card-body h3 { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.card-body h3 .sub { margin-left: 6px; font-weight: 500; color: var(--muted); }

/* 切り替えのボタン類（押せる部分の高さは 44px 以上にしている） */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
/* 左に凡例、右に選択欄（米国株価指数）。凡例が長いときは、凡例のほうを折り返す */
.controls-split { flex-wrap: nowrap; justify-content: space-between; }
.controls-split .legend { flex: 1 1 auto; min-width: 0; }
.controls-split .field { flex: 0 0 auto; }

.seg, .field { display: flex; align-items: center; gap: 8px; }
.seg legend, .chips legend, .field label { float: left; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.seg-box { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; }
.seg-box button {
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.seg-box button:hover { background: var(--head); }
.seg-box button[aria-pressed="true"] { background: var(--accent); color: #ffffff; font-weight: 700; }

/* 複数を選べるボタン（比較する日など）。角丸の四角で、ほかのボタン（.btn・.seg-box）と同じ丸み */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips legend { margin-right: 2px; }
.chip {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #ffffff;
  color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #b9c1cd; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); }
.hint.is-alert { color: var(--warn-ink); font-weight: 700; }

.field select {
  min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #ffffff; color: var(--ink); font-size: 13px;
}

/* 凡例（線の色と名前の対応） */
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; color: var(--ink-2); }
.legend-tight { gap: 2px 12px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend strong { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.legend .date { color: var(--muted); }
/* 凡例の最後に添える短い注記（例：前日終値＝0%） */
.legend .legend-note { color: var(--muted); }
.swatch { flex: 0 0 auto; width: 20px; height: 2px; border-radius: 2px; background: var(--muted); }
.swatch-thick { height: 3px; }
.swatch-dash { background: repeating-linear-gradient(90deg, var(--c-ramp2) 0 5px, transparent 5px 8px); }
.c-blue { background-color: var(--c-blue); }
.c-orange { background-color: var(--c-orange); }
.c-green { background-color: var(--c-green); }
.c-yellow { background-color: var(--c-yellow); }
.c-pink { background-color: var(--c-pink); }
.c-ramp1 { background-color: var(--c-ramp1); }
.c-ramp2 { background-color: var(--c-ramp2); }
.c-ink { background-color: var(--ink); }
.c-nikkei { background-color: var(--c-nikkei); }
.c-up { background-color: var(--c-up); }
.c-down { background-color: var(--c-down); }
.c-gray { background-color: var(--c-gray); }
/* 面や棒で描く系列の見本（線の見本より太い四角） */
.swatch-box { width: 10px; height: 10px; border-radius: 2px; }
.swatch-box + .swatch-box { margin-left: -3px; }
/* 縦の線の見本（分布の図の、P25・中央値・P75・現在の線） */
.swatch-v { width: 1px; height: 12px; border-radius: 0; background: var(--ink); }
.swatch-v-dash { background: repeating-linear-gradient(180deg, var(--ink) 0 3px, transparent 3px 5px); }
.swatch-v-now { width: 3px; }

/* グラフを描く枠（高さはここで決め、Highcharts が枠に合わせて描く） */
.chart { width: 100%; height: 230px; }
/* となりのカードのほうが背が高いときは、カードの下に空きができないよう、グラフを縦に伸ばす（上限まで） */
.chart-tall { flex: 1 1 270px; height: auto; min-height: 270px; max-height: 460px; }
.empty { padding: 28px 8px; text-align: center; font-size: 13px; color: var(--muted); }

/* VIX の3つの数字 */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 8px 10px; border-radius: 6px; background: var(--head); }
.stat dt { font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.stat dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-size: 20px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-tag { font-size: 12px; font-weight: 700; color: var(--ink-2); }

/* 通貨強度：左に推移の線、右に「今の強さ」（1列） */
.split { display: flex; gap: 20px; }
.split-side { flex: 0 0 150px; display: flex; flex-direction: column; gap: 6px; }
.split-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
/* 今の強さ：強い通貨から順に並べたマス。背景の色は、強さに応じて JavaScript が付ける（js/chartkit.js の heatBlend）。
   左のグラフと下端がそろうように、マスの高さを伸ばす */
.fxstrip { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.fxstrip li {
  flex: 1 1 36px; min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 10px; border-radius: 3px; background: #f0efec; color: var(--ink); font-variant-numeric: tabular-nums;
}
.fxstrip .fx-code { font-weight: 700; }

/* 2つ並べるグラフ（原油・金、日米のイールドカーブ） */
.pair { flex: 1 1 auto; display: flex; gap: 20px; }
.pair-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pair-item .chart { flex: 1 1 200px; height: auto; min-height: 200px; max-height: 380px; }
.value-line { display: flex; align-items: baseline; gap: 8px; }
.value-line strong { font-size: 20px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.value-line span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 経済指標カレンダー */
.cal { width: 100%; border-collapse: collapse; font-size: 13px; }
.cal th { white-space: nowrap; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--head); text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.cal td { padding: 9px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.cal .cal-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal .cal-cur { font-weight: 700; }
.cal .cal-day th { background: #ffffff; padding-top: 12px; font-size: 12px; color: var(--ink); }
.cal tr.is-past td { color: var(--muted); }
.badge { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 700; line-height: 1.7; }
.badge-high { background: var(--warn-bg); color: var(--warn-ink); }
.badge-medium { background: #eef1f5; color: var(--ink-2); }

/* ページの下の「データの更新状況」 */
.status { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.status-title { margin-right: 1em; }
.status-item { margin-right: 1em; white-space: nowrap; }
.status-item.is-failed { color: var(--warn-ink); font-weight: 700; }
.status-item[title] { cursor: help; }

/* ---------- 株式ページ ---------- */

#stocks-page, #vix-page, #words-page, .page-body { display: flex; flex-direction: column; gap: 16px; }
/* カードを縦に積むところでは、高さを中身に合わせる（.card の flex は、横に並べるとき用の指定なので打ち消す。
   v15.6 で Words のページも、ほかのページと同じだけカードのあいだをあけた） */
.page-body > .card, #words-page > .card { flex: 0 0 auto; }

/* いちばん上の行：左にページ内の移動、右に日付の切り替え（前の取引日・日付・次の取引日） */
#stocks-page .page-head { align-items: center; }
.date-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  flex: 0 0 auto; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: #b9c1cd; }
.icon-btn[disabled] { opacity: 0.4; cursor: default; }
.icon-btn .icon { width: 16px; height: 16px; }
.date-field {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff;
}
.date-field label { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.date-field input { min-height: 40px; min-width: 0; border: 0; background: transparent; color: var(--ink); font-size: 13px; }

/* ページ内の移動（角丸の四角のボタン） */
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.jump a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; color: var(--ink-2);
  font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.jump a:hover { border-color: #b9c1cd; color: var(--ink); }

/* いちばん上の数字 */
.tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.tile { flex: 1 1 170px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.tile dt { font-size: 12px; color: var(--ink-2); }
.tile dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.tile-value { font-size: 20px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.seg-wrap, .seg-wrap .seg-box { flex-wrap: wrap; }

/* 個別銘柄の値動き：左にグラフ、右に抽出銘柄の表 */
.lines { display: flex; flex-wrap: wrap; gap: 20px; }
.lines-main { flex: 3 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
/* container-type：この枠の幅に合わせて、中の表の形を変えられるようにする（下の @container を参照） */
.lines-side { flex: 2 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; container-type: inline-size; }
/* 右の表のほうが背が高いとき（「自分で選ぶ」で入力欄が出ているときなど）は、グラフを下まで伸ばして、空きを作らない */
.chart-lines { flex: 1 1 340px; height: auto; min-height: 340px; max-height: 520px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th {
  padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--head);
  text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap;
}
table.mini td { height: 44px; padding: 0 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
/* 銘柄名の列は、残りの幅をすべて使い、入りきらない名前は「…」で切る（表が枠からはみ出さないように） */
table.mini-picks td:first-child { width: 100%; max-width: 0; }
table.mini-picks td.num, table.mini-picks th.num { white-space: nowrap; }
.pick-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* 銘柄名と、その後ろの銘柄コード。コードは省かない（名前が長いときは、名前のほうを「…」で切る） */
.pick-label { flex: 1 1 auto; min-width: 0; display: flex; }
.pick-label .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-label .code { flex: 0 0 auto; color: var(--ink-2); white-space: nowrap; }
.pick-remove {
  flex: 0 0 auto; width: 36px; height: 44px; margin: 0 -8px 0 auto; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.pick-remove:hover { background: var(--head); color: var(--ink); }
.pick-remove .icon { width: 14px; height: 14px; }
/* 表を置く枠の幅が 480px より狭いとき（スマホや、幅のせまいパソコン画面）は、1銘柄を2段にする。
   上の段に「銘柄名（コード）」を省かずに書き（長い名前は折り返す）、下の段に数字4つ（終値・騰落率・出来高乖離・値幅乖離）を並べる。
   数字の列の幅は、見出しの文字が入る最小の幅（左右の余白は 6px）にして、幅 320px の画面にも収まるようにしてある */
@container (max-width: 479px) {
  table.mini-picks, table.mini-picks thead, table.mini-picks tbody { display: block; }
  table.mini-picks tr { display: grid; grid-template-columns: minmax(0, 1fr) 4.6em 4.9em 5.6em 4.8em; }
  table.mini-picks tbody tr { border-bottom: 1px solid var(--grid); }
  table.mini-picks th { padding-left: 6px; padding-right: 6px; }
  table.mini-picks td { height: auto; border-bottom: 0; }
  table.mini-picks td:first-child { grid-column: 1 / -1; width: auto; max-width: none; padding: 7px 8px 0; }
  table.mini-picks td:only-child { padding-bottom: 7px; }
  table.mini-picks td:nth-child(2) { grid-column: 2; }
  table.mini-picks td.num { padding: 0 6px 7px; }
  /* 色の線と「×」のボタンは、銘柄名の1行目の高さに合わせる（名前が2行に折り返しても、1行目の横に置く） */
  .pick-name { align-items: flex-start; }
  .pick-name .swatch { margin-top: calc(0.85em - 1.5px); }
  .pick-label { display: block; }
  .pick-label .name { overflow: visible; white-space: normal; }
  /* ボタンの押せる範囲（高さ44px）は保ったまま、行の高さは文字1行ぶんにする */
  .pick-remove { margin-top: -11px; margin-bottom: -11px; }
}
.pick-add { display: flex; flex-direction: column; gap: 4px; }
.pick-add label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.pick-box { display: flex; gap: 6px; }
.pick-box input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; font-size: 13px;
}

/* 横棒の並び（業種別・規模別・寄与度）。まん中の縦線が0で、右に伸びれば上昇、左なら下落 */
.bar-columns { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 8px 28px; }
.bars { min-width: 0; display: flex; flex-direction: column; font-size: 12px; }
.bar-columns .bars { flex: 1 1 260px; }
/* となりのカードのほうが背が高いときは、下に空きができないよう、行の間隔を広げる（上限まで） */
.bar-columns .bars li { flex: 1 1 21px; max-height: 40px; }
.bar-columns .bars:only-child li { grid-template-columns: 13em 1fr 4.6em; }   /* 1列のときは、名前の欄を広く取る */
.bars li { display: grid; grid-template-columns: 10.5em 1fr 4.6em; align-items: center; column-gap: 8px; min-height: 21px; }
.bars-size li { grid-template-columns: 9.5em 1fr 4.6em; }
.bars-link { font-size: 13px; }
.bars-link li { grid-template-columns: minmax(0, 13em) 1fr 5.4em; }
.bars li.is-empty { display: block; padding: 6px 0; color: var(--muted); }   /* 「当てはまる銘柄がありません」 */
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.bar-name { display: block; line-height: 44px; }
.bar { position: relative; align-self: stretch; min-height: 21px; }
.bar::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #9aa1ab; }
.bar-fill { position: absolute; top: 50%; height: 12px; margin-top: -6px; }
.bar-fill.is-up { border-radius: 0 3px 3px 0; background: var(--c-up); }
.bar-fill.is-down { border-radius: 3px 0 0 3px; background: var(--c-down); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 市場の広がり */
.share-bar { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; }
.share-bar span { min-width: 0; }
.share-up { background: var(--c-up); }
.share-flat { background: var(--c-flat); }
.share-down { background: var(--c-down); }
.share-text { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-2); }
.share-text strong { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-mini { height: 100px; }
/* 見出しとグラフのまとまり（データが無いときは、まとまりごと隠す） */
.block { display: flex; flex-direction: column; gap: 10px; }
.block-tight { gap: 4px; }

/* ヒートマップ */
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.heat-legend > :first-child, .heat-scale { flex: 0 0 auto; }
.heat-scale { display: flex; }
.heat-scale span { width: 26px; height: 12px; }
/* 0＝大きく下落（赤）… 3＝変わらず … 6＝大きく上昇（青）。js/chartkit.js の HEAT と同じ値（v15.6 で向きを逆に） */
.heat-0 { background: #c24a36; }
.heat-1 { background: #e08572; }
.heat-2 { background: #f3c1b5; }
.heat-3 { background: #f0efec; }
.heat-4 { background: #b9cdea; }
.heat-5 { background: #7da3d8; }
.heat-6 { background: #3f73b8; }
.chart-map { height: 440px; }

/* ランキング */
.rank-grid { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.rank-grid > div { flex: 1 1 220px; min-width: 0; }
.ranklist { font-size: 13px; }
.ranklist li { display: grid; grid-template-columns: 1.6em 1fr auto; align-items: center; gap: 8px; border-bottom: 1px solid var(--grid); }
.ranklist .rank-no { color: var(--muted); font-variant-numeric: tabular-nums; }
.ranklist a { display: block; min-width: 0; line-height: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranklist .rank-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 決算発表の予定 */
.earn { display: flex; flex-direction: column; gap: 10px; }
.earn-day h3 { padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.earn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); column-gap: 28px; font-size: 13px; }
.earn-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; border-bottom: 1px solid var(--grid); }
.earn-list a { display: block; min-width: 0; line-height: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.earn-list span { flex: 0 0 auto; font-size: 12px; color: var(--muted); }

/* ---------- VIX ページ ---------- */

/* プラス・マイナスで色を変える数字（ベーシス・損益）。向きは、上昇・下落の色と同じ（プラスが赤、マイナスが青） */
.pos { color: var(--c-up); }
.neg { color: var(--c-down); }

/* データを取り込む前に出す、コマンドの表示 */
.command { margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--head); overflow-x: auto; font-size: 13px; line-height: 1.6; }
.command code { font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace; white-space: pre; }

/* カードの見出し：名前と右側の注記が1行に入らないときは、注記を下の行に送る */
.card-head-wrap { flex-wrap: wrap; row-gap: 0; }
.card-head-wrap .card-meta { flex: 0 1 auto; }

/* 表が枠より広くなったとき（とても幅のせまい画面）は、表の中だけを横に動かせるようにする */
.table-scroll { overflow-x: auto; }

/* カーソルを合わせた日の値（数値の枠）。枠の幅に合わせて、3列 → 2段 → 1段 と並べ方を変える（下の @container）。
   3列のときは、まん中の列（限月・VIX指数・建玉）を少しせまくして、日付と表示範囲の列を広く取る */
.readout-box { container-type: inline-size; }
.readout { display: grid; grid-template-columns: 1.15fr 0.95fr 1.15fr; gap: 6px; }
.readout > div { min-width: 0; padding: 5px 8px 6px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; }
.readout dt { overflow: hidden; font-size: 11px; line-height: 1.5; color: var(--ink-2); white-space: nowrap; text-overflow: ellipsis; }
.readout dd {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px;
  font-size: 14px; font-weight: 700; line-height: 1.4; font-variant-numeric: tabular-nums;
}
/* 3列のときの数字の大きさは、枠の幅に合わせる（幅 340px で約 14.6px、270px で 11.6px。cqi は「枠の幅の 1%」） */
.readout dd { font-size: clamp(11.5px, 4.3cqi, 15px); }
.readout dd > span { white-space: nowrap; }
.readout small { margin-left: 1px; font-size: 11px; font-weight: 500; color: var(--ink-2); }
.readout .ro-note { display: none; font-size: 11px; font-weight: 700; color: var(--ink-2); }
/* 3列のとき：「表示範囲」は2行になるので、いつも2行ぶんの高さを取っておく。
   交代日の「交代・ロール」は、いちばん下の横長の枠（限月交代）に出す */
.readout .ro-range dd { min-height: 2.8em; align-content: flex-start; }
.readout .ro-roll { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; }
.readout .ro-roll dd { font-size: 13px; }
@container (min-width: 640px) {
  .readout { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .readout > div { grid-column: span 2; }
  .readout .ro-volume, .readout .ro-oi { grid-column: span 3; }
  .readout .ro-dte, .readout .ro-range { grid-column: span 4; }
  .readout dd { font-size: 15px; }
  .readout .ro-range dd { min-height: 0; }
  .readout .ro-note { display: inline; }
  .readout .ro-roll { display: none; }
}
@container (min-width: 1000px) {
  .readout { grid-template-columns: 1.15fr 0.95fr 2fr 0.85fr 0.85fr 0.85fr 1.05fr 1.05fr 1.85fr; }
  .readout > div, .readout .ro-volume, .readout .ro-oi, .readout .ro-dte, .readout .ro-range { grid-column: auto; }
}

/* 限月交代のグラフ（4つの段とナビゲータを、1つのグラフの中に縦に並べる） */
.chart-roll { height: 700px; }
/* 分布の図 */
.chart-dist { height: 190px; }

/* ベーシスチェッカーの入力欄 */
.entries { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 12px; }
.entry { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.entry-wide { grid-column: span 2; }
.entry label, .sliders legend { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.entry input, .entry select {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; color: var(--ink);
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.entry input:invalid { border-color: var(--warn-ink); }
.entry-note { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 12px; color: var(--muted); }
.text-btn {
  min-height: 28px; padding: 0 2px; border: 0; background: transparent; color: var(--accent);
  font-size: 12px; text-decoration: underline; cursor: pointer;
}
.text-btn:hover { color: #1f4573; }

/* 照合の幅（スライダー） */
.sliders { display: flex; flex-direction: column; gap: 2px; }
.slider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }
.slider { display: grid; grid-template-columns: 6.6em minmax(0, 1fr) 4.6em; align-items: center; gap: 8px; min-height: 44px; }
.slider label { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.slider input { width: 100%; min-width: 0; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.slider output { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 判定（数字の枠5つ）。見た目は TOP の VIX の数字（.stat）と同じ */
.verdict { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.verdict .stat { min-width: 0; }
.verdict small { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.stat dd.stat-sub { display: block; min-height: 1.5em; font-size: 12px; font-weight: 500; line-height: 1.5; color: var(--muted); }
.judge { display: inline-block; padding: 1px 10px; border-radius: 4px; font-size: 15px; line-height: 1.7; color: var(--ink); white-space: nowrap; }
.judge-none { box-shadow: inset 0 0 0 1px var(--line); background: #ffffff; color: var(--ink-2); }
.judge-ok { background: #f0efec; box-shadow: inset 0 0 0 1px var(--line); }
/* 高い＝青、低い＝赤（プラス＝青・マイナス＝赤にそろえる。v15.6 で逆に） */
.judge-mid-high { background: #b9cdea; }
.judge-far-high { background: #5e8bc9; }
.judge-mid-low { background: #f3c1b5; }
.judge-far-low { background: #df644f; }

/* 類似局面の表と、その下の集計 */
table.mini-sim td { height: 34px; white-space: nowrap; }
table.mini-sim th:last-child { white-space: normal; }
.sim-foot { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 12px; color: var(--ink-2); }
.sim-foot > div { display: flex; align-items: baseline; gap: 6px; }
.sim-foot dd { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.sim-foot dd.pos { color: var(--c-up); }
.sim-foot dd.neg { color: var(--c-down); }

/* 参照マトリックス。マスの色は、上に文字をのせる用の7段階（js/chartkit.js の HEAT_SOFT と同じ値） */
.heat-soft-0 { background: #df644f; }
.heat-soft-1 { background: #e08572; }
.heat-soft-2 { background: #f3c1b5; }
.heat-soft-3 { background: #f0efec; }
.heat-soft-4 { background: #b9cdea; }
.heat-soft-5 { background: #7da3d8; }
.heat-soft-6 { background: #5e8bc9; }
table.matrix { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; font-size: 13px; }
table.matrix th { padding: 4px 2px; font-size: 12px; font-weight: 700; line-height: 1.4; color: var(--ink-2); text-align: center; white-space: nowrap; }
table.matrix th:first-child { width: 5.6em; text-align: left; }
table.matrix td {
  height: 46px; padding: 2px; border-radius: 3px; text-align: center; line-height: 1.35;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
table.matrix .mx-v { display: block; font-weight: 700; }
table.matrix .mx-n { display: block; font-size: 11px; }
table.matrix td.is-sparse { box-shadow: inset 0 0 0 1px var(--grid); background: #ffffff; color: var(--muted); }
table.matrix td.is-now { outline: 2px solid var(--ink); outline-offset: -1px; }
.mx-legend { flex-wrap: wrap; gap: 4px 8px; }
.mx-scale { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.mx-key { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; white-space: nowrap; }
.mx-mark { flex: 0 0 auto; width: 18px; height: 12px; border-radius: 2px; text-align: center; line-height: 12px; }
.mx-mark-sparse { box-shadow: inset 0 0 0 1px var(--grid); background: #ffffff; }
.mx-mark-now { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ワードクラウドのページ（v12） */
.field-week { gap: 6px; }
.step-btn {
  flex: 0 0 auto; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff;
  color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer;
}
.step-btn:hover { border-color: #b9c1cd; }
.step-btn[disabled] { opacity: 0.4; cursor: default; }
.words-layout { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; }
.words-cloud { flex: 3 1 480px; min-width: 0; }
.words-counts { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.chart-words { height: 460px; }
.words-table-scroll { max-height: 460px; overflow-y: auto; }
table.mini-words td { height: 32px; }
table.mini-words td:first-child { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.mini-words .num { white-space: nowrap; }
table.mini-days { table-layout: fixed; }
table.mini-days th .sub { display: block; font-weight: 500; color: var(--muted); }
table.mini-days td { height: 34px; padding: 0 6px; vertical-align: middle; }
table.mini-days td .dw-word { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.mini-days td .dw-count { display: block; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
td.empty-cell { text-align: center; color: var(--muted); }
/* 日ごとのワードクラウドと、TOP のカード（v13） */
.step-btn-text { width: auto; padding: 0 10px; font-size: 12px; font-weight: 700; }
.field-week input[type="date"] { min-height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; color: var(--ink); font: inherit; font-size: 13px; }
.words-note { font-size: 12px; color: var(--muted); }
/* 日ごとの右上の「日経平均（11/30）+1.23%」（v15.6。色は上昇・下落の色） */
.day-nikkei { margin-left: 12px; white-space: nowrap; }
.day-nikkei strong { margin-left: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-full { flex: 1 1 100%; }
.chart-words-card { height: 360px; }

/* ---------- ETF乖離のページ（v15） ---------- */

#etf-page { display: flex; flex-direction: column; gap: 16px; }
#etf-page .page-head { align-items: center; }
/* 一覧の表：銘柄名の列が残りの幅を使い、入りきらない名前は「…」で切る。幅のせまい画面では、表を横に動かして見る */
table.mini-etf { min-width: 780px; }
table.mini-etf td { height: 40px; white-space: nowrap; }
table.mini-etf .etf-code { color: var(--ink-2); }
table.mini-etf .etf-name { width: 100%; max-width: 0; }
table.mini-etf .etf-group th { padding-top: 12px; background: #ffffff; color: var(--ink); }
table.mini-etf tr.is-selected td { background: var(--accent-weak); }
table.mini-etf .etf-note { max-width: 18em; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--ink-2); }
table.mini-etf .etf-note.is-muted { color: var(--muted); }
/* 銘柄名のボタン（押すと、下のグラフがその銘柄になる）。押せる高さは行の高さいっぱい */
.row-pick {
  display: block; width: 100%; min-height: 40px; padding: 0; border: 0; background: transparent;
  color: var(--accent); font: inherit; text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-pick:hover { text-decoration: underline; }
tr.is-selected .row-pick { color: var(--ink); font-weight: 700; }
/* グラフは段が3つ（値段と推定 iNAV・乖離率・出来高。v15.3 で出来高の段を足して 440px → 520px） */
.chart-etf { height: 520px; }
/* グラフのカードの見出し：名前のすぐ右に「一覧へ戻る」ボタン、日付は右端（v15.5。v15.3 は日付とボタンを右端に並べていた）。
   名前は行の中の文字として並べ、ボタンはその最後の文字の右に続く（名前が2行になるスマホでは、2行目の右） */
.card-title { flex: 1 1 auto; min-width: 0; }
.card-title h2 { display: inline; }
.card-title .back-btn { margin-left: 12px; vertical-align: middle; }
.card-title + .card-meta { margin-left: auto; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #ffffff; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.back-btn:hover { border-color: #b9c1cd; background: var(--accent-weak); }
.back-btn .icon { width: 14px; height: 14px; }
/* 大引け（15:30）の出来高の棒の色（ほかの時刻の棒より濃い灰色）。js/etf.js の VOLUME_CLOSE_COLOR と同じ値 */
.c-gray-dark { background-color: #5f6670; }
/* グラフの上の数字の下に出す備考（例：1306 の「TOPIX先物で推定」）と、出来高の無い日の注記 */
.chart-note { font-size: 12px; color: var(--muted); }
/* グラフの下の「一覧へ戻る」は、スマホ（グラフの下まで見たあと）だけに出す */
.chart-foot { display: none; }

/* ---------- 画面の幅がせまいとき（スマホ） ---------- */

@media (max-width: 899px) {
  /* 下のメニューの高さと、その下の間（v15.7）。間は、iOS の画面の下の端を横になぞる操作（アプリの切り替え）と、メニューの横スクロールが
     重ならないように、メニューを少し持ち上げるためのもの。16px か、ホームバーの分（safe-area。分かる端末だけ）の大きいほう */
  :root { --tabbar-h: 68px; --tabbar-gap: max(16px, env(safe-area-inset-bottom, 0px)); }
  body { font-size: 15px; }
  .layout { background: none; }
  .sidebar { display: none; }
  .mobile-brand { display: flex; }
  /* 下は、メニューと、その上に浮かぶ「一番上へ戻る」ボタンにかからないだけ空ける */
  .main { padding: 16px 12px calc(var(--tabbar-h) + var(--tabbar-gap) + 64px); gap: 12px; }
  #dashboard { gap: 12px; }
  .page-head { flex-wrap: nowrap; align-items: center; }
  .page-head h1 { font-size: 22px; }
  .btn { padding: 0 12px; }

  /* 下のメニュー（v14。v15 で ETF乖離 を足して8ページ）：サイドバーと同じページを1列に並べ、横にスクロールする。1つのタブの幅は画面の 22% なので、
     4つと次の一部が見え、続きがあると分かる。スクロールバーは出さない。選択中のタブは site.js がまん中に寄せる */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: block; background: var(--accent);
    padding-bottom: var(--tabbar-gap);
  }
  .tabbar-scroll {
    display: flex; height: var(--tabbar-h); overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  }
  .tabbar-scroll::-webkit-scrollbar { display: none; }
  /* 左右に続きがあるとき、その側の端をうすくぼかす（site.js が .has-left / .has-right を付ける） */
  .tabbar::before, .tabbar::after {
    content: ""; position: absolute; top: 0; height: var(--tabbar-h); width: 34px; pointer-events: none; opacity: 0; transition: opacity 0.15s;
  }
  .tabbar::before { left: 0; background: linear-gradient(90deg, var(--accent) 30%, rgba(47, 91, 156, 0)); }
  .tabbar::after { right: 0; background: linear-gradient(270deg, var(--accent) 30%, rgba(47, 91, 156, 0)); }
  .tabbar.has-left::before, .tabbar.has-right::after { opacity: 1; }
  .tabbar a {
    flex: 0 0 auto; min-width: 22%; padding: 0 8px; scroll-snap-align: start;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border-top: 3px solid transparent; color: var(--side-muted);
    font-size: 12px; font-weight: 500; text-decoration: none; white-space: nowrap;
  }
  .tabbar a[aria-current] { border-top-color: #ffffff; color: #ffffff; font-weight: 700; }
  .tabbar .icon { width: 22px; height: 22px; }

  /* 一番上へ戻るボタン（v15.7。スマホだけ）：下のメニューの右上に浮かぶ丸いボタン。ある程度下へスクロールしたときだけ出る
     （site.js が .is-shown を付ける）。出ていないあいだは押せず、読み上げもしない（visibility: hidden） */
  .to-top {
    position: fixed; right: 14px; bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + 12px); z-index: 20;
    display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%; background: var(--accent); color: #ffffff; cursor: pointer;
    box-shadow: 0 2px 8px rgba(28, 30, 33, 0.3);
    opacity: 0; visibility: hidden; transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0s linear 0.2s;
  }
  .to-top.is-shown { opacity: 1; visibility: visible; transform: none; transition: opacity 0.2s, transform 0.2s, visibility 0s; }
  .to-top .icon { width: 22px; height: 22px; }
  @media (prefers-reduced-motion: reduce) { .to-top, .to-top.is-shown { transition: none; } }   /* 動きを減らす設定では、ふわっと出さない */

  .card-row { gap: 12px; }
  .card, .card-wide, .card-narrow { flex: 1 1 100%; }
  .card-head { padding: 10px 12px; gap: 8px; }
  .card-body { padding: 12px; }
  .controls { gap: 8px; }
  .controls-split { flex-wrap: wrap; }
  .controls-split .field { flex: 1 1 auto; }
  .seg-fill, .seg-fill .seg-box { flex: 1 1 auto; }
  .seg-fill { width: 100%; }
  .seg-fill .seg-box button { flex: 1; padding: 0 6px; }
  .seg-box button { padding: 0 10px; }
  .field { flex: 1 1 auto; }
  .field select { flex: 1; font-size: 14px; }

  .chart { height: 200px; }
  .chart-tall { flex: 0 0 auto; height: 220px; min-height: 0; }
  .stats { gap: 6px; }
  .stat { padding: 8px; }
  .stat dd { font-size: 18px; }
  .split, .pair { flex-direction: column; gap: 10px; }
  .split-side { flex: 0 0 auto; }
  .fxstrip { font-size: 14px; }
  .fxstrip li { flex: 0 0 auto; padding: 0 12px; }
  .pair-item .chart { flex: 0 0 auto; height: 170px; min-height: 0; }

  /* カレンダーは、表をやめて1件ずつの並びにする */
  .cal thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .cal, .cal tbody { display: block; }
  .cal tr { display: grid; grid-template-columns: auto auto 1fr; gap: 2px 8px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--grid); }
  .cal td { padding: 0; border: 0; }
  .cal .cal-title { grid-column: 1 / -1; grid-row: 2; font-size: 14px; font-weight: 500; }
  .cal .cal-impact { grid-column: 3; grid-row: 1; }
  .cal td.num { grid-row: 3; text-align: left !important; font-size: 12px; color: var(--muted); }
  .cal td.num::before { content: attr(data-label) " "; }
  .cal .cal-forecast { grid-column: 1 / 3; }
  .cal .cal-previous { grid-column: 3; }
  .cal .cal-day { display: block; padding: 10px 2px 4px; }
  .cal .cal-day th { display: block; padding: 0; border: 0; }
  .status-item { display: inline-block; }
}

/* 株式ページ（スマホ） */
@media (max-width: 899px) {
  #stocks-page, #vix-page, #words-page, .page-body { gap: 12px; }
  /* 上に日付の切り替え、その下にページ内の移動（横に流して1行にする） */
  #stocks-page .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .date-nav { order: -1; margin-left: 0; }
  .date-field { flex: 1 1 auto; }
  .date-field input { flex: 1; font-size: 14px; }
  .jump { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px; padding: 0 12px 4px; }
  .tiles { gap: 8px; }
  .tile { flex: 1 1 150px; padding: 10px 12px; }
  .tile-value { font-size: 18px; }
  .seg-wrap, .seg-wrap .seg-box { width: 100%; }
  .seg-wrap .seg-box button { flex: 1 1 auto; }
  .lines { gap: 12px; }
  .lines-main, .lines-side { flex: 1 1 100%; }
  .chart-lines { flex: 0 0 auto; height: 290px; min-height: 0; }
  .bars { font-size: 13px; }
  .bars li { grid-template-columns: 10.5em 1fr 4.6em; min-height: 26px; }
  .bar-columns .bars li, .bar-columns .bars:only-child li { flex: 0 0 auto; grid-template-columns: 10.5em 1fr 4.6em; }
  .bars-size li { grid-template-columns: 9.5em 1fr 4.6em; }
  .bars-link li { grid-template-columns: minmax(0, 9.5em) 1fr 5.4em; }
  .bar { min-height: 26px; }
  .heat-legend { width: 100%; }
  .chart-mini { height: 120px; }
  .chart-map { height: 520px; }
  .earn-list { grid-template-columns: 1fr; }
}

/* VIX ページ（スマホ） */
@media (max-width: 899px) {
  .chart-roll { height: 580px; }
  .chart-dist { height: 170px; }
  .entry-note { min-height: 0; }
  .entry-dte .entry-note { min-height: 44px; }
  .text-btn { min-height: 44px; font-size: 13px; }
  .slider-grid { grid-template-columns: minmax(0, 1fr); }
  .verdict { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .verdict .stat-judge { grid-column: 1 / -1; }
  table.mini-sim { font-size: 12px; }
  table.mini-sim th, table.mini-sim td { padding-left: 4px; padding-right: 4px; }
  table.matrix { border-spacing: 1px; font-size: 12px; }
  table.matrix th { font-size: 11px; }
  table.matrix th:first-child { width: 4.6em; }
  table.matrix .mx-n { font-size: 10px; }
  .mx-key { margin-left: 0; }
}

/* VIX ページ（とても幅のせまいスマホ） */
@media (max-width: 360px) {
  .entry input, .entry select { padding: 0 6px; font-size: 14px; }
  /* 類似局面の表：「期近」の列（＝ VIX ＋ ベーシス）を省いて、損益の列が画面に入るようにする */
  table.mini-sim th:nth-child(3), table.mini-sim td:nth-child(3) { display: none; }
  table.mini-sim th, table.mini-sim td { padding-left: 3px; padding-right: 3px; }
}

/* @container が使えない古いブラウザー向け：幅のせまいスマホでは、抽出銘柄の表から「終値」の列を省いて、
   銘柄名の幅を確保する（新しいブラウザーでは、上の @container で表を2段にするので、この指定は使わない） */
@supports not (container-type: inline-size) {
  @media (max-width: 479px) {
    table.mini-picks th:nth-child(2), table.mini-picks td:nth-child(2) { display: none; }
  }
}

@media (max-width: 899px) {
  .words-cloud, .words-counts { flex: 1 1 100%; }
  .chart-words { height: 320px; }
  .chart-words-card { height: 280px; }
  .words-table-scroll { max-height: 320px; }
  table.mini-days { min-width: 560px; }
}

/* ETF乖離のページ（スマホ） */
@media (max-width: 899px) {
  #etf-page { gap: 12px; }
  #etf-page .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  table.mini-etf { min-width: 620px; }
  table.mini-etf td { height: 44px; }
  .row-pick { min-height: 44px; }
  .chart-etf { height: 440px; }
  /* 「一覧へ戻る」は押しやすい大きさ（高さ 44px）にし、グラフの下にも出す */
  .back-btn { min-height: 44px; padding: 0 14px 0 12px; font-size: 13px; }
  .chart-foot { display: flex; justify-content: flex-end; margin: 0; }
}

/* ETF乖離のページ（幅 640px より狭い画面）：表をやめて、1本を3段にする。
   上の段に「コード・銘柄名（省かずに折り返す）・倍率」、中の段に数字5つ（見出しを数字の上に小さく）、下の段に備考 */
@media (max-width: 639px) {
  table.mini-etf { min-width: 0; }
  table.mini-etf, table.mini-etf tbody { display: block; }
  table.mini-etf thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.mini-etf tr.etf-group, table.mini-etf tr.etf-group th { display: block; }
  table.mini-etf tr[data-code] {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 4px;
    padding: 2px 0 8px; border-bottom: 1px solid var(--grid);
  }
  table.mini-etf tr.is-selected { background: var(--accent-weak); }
  table.mini-etf tr.is-selected td { background: transparent; }
  table.mini-etf td { height: auto; padding: 0; border-bottom: 0; white-space: normal; }
  table.mini-etf .etf-code { grid-row: 1; grid-column: 1; align-self: center; padding-left: 8px; }
  table.mini-etf .etf-name { grid-row: 1; grid-column: 2 / 5; width: auto; max-width: none; }
  table.mini-etf .etf-lev { grid-row: 1; grid-column: 5; align-self: center; padding-right: 8px; }
  table.mini-etf td.etf-num { grid-row: 2; padding-left: 8px; text-align: left !important; }
  table.mini-etf td.etf-num::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.mini-etf .etf-note { grid-row: 3; grid-column: 1 / -1; max-width: none; padding: 4px 8px 0; white-space: normal; }
  table.mini-etf .etf-note:empty { display: none; }
  .row-pick { display: flex; align-items: center; min-height: 44px; line-height: 1.4; white-space: normal; }
}
