/* S&P 500 seasonality — dark, AA contrast, no external assets. */
:root {
  --bg: #0f172a;
  --panel: #131c31;
  --line: #24314b;
  --text: #e8eef8;
  --muted: #a9b6cc;
  --pos: #63a4ff;   /* positive: blue (not red/green dependent) */
  --neg: #ff7a7a;   /* negative: red */
  --accent: #ffd166;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.6;
}
header.top { padding: 20px 24px 8px; border-bottom: 1px solid var(--line); }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: .01em; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.formula {
  margin: 10px 0 0; padding: 8px 12px; font-size: 13px; color: #ffe9b3;
  background: rgba(255, 209, 102, .08); border-left: 3px solid var(--accent);
  border-radius: 3px;
}
.rangebar {
  padding: 12px 24px 0; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.range-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.range-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.range-label input[type="date"] {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.range-label input[type="date"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.range-btn {
  appearance: none; background: #182238; color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.range-btn:hover { border-color: var(--pos); }
.range-btn.primary { background: #1b2742; border-color: var(--pos); color: #fff; }
.range-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-presets { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
/* C37: プリセットは 13 個（1Y〜100Y・YTD・全期間）。狭い幅でも 1 行に収まりやすいよう詰める。 */
.range-presets .range-btn { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
.range-presets .range-btn[aria-pressed="true"] {
  background: #1b2742; border-color: var(--accent); color: #fff;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.range-presets .range-btn[aria-pressed="true"]:hover { border-color: var(--accent); }
.range-status { margin: 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-error { margin: 0; font-size: 12.5px; color: #ffb4b4; }
.load-error {
  margin: 10px 24px 0; padding: 10px 14px; border-radius: 8px;
  background: rgba(255, 122, 122, .12); border: 1px solid var(--neg);
  color: #ffd7d7; font-size: 13px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.load-error[hidden] { display: none; }
.load-error .range-btn { padding: 4px 10px; font-size: 12px; }
nav.tabs { display: flex; gap: 6px; padding: 12px 24px 0; flex-wrap: wrap; }
.tab {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); padding: 8px 16px; border-radius: 8px 8px 0 0;
  font-size: 14px; cursor: pointer;
}
.tab:hover { color: var(--text); border-color: #33456b; }
.tab[aria-selected="true"] {
  color: #fff; background: #1b2742; border-bottom-color: #1b2742;
  box-shadow: inset 0 2px 0 var(--pos);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main { padding: 18px 24px 40px; }
.panel[hidden] { display: none; }
.lead { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; max-width: 78ch; }
.toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.cards { display: flex; gap: 10px; flex-wrap: wrap; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; min-width: 118px;
}
.card .k { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.card .v { font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .n { font-size: 11.5px; color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.switch { display: flex; gap: 14px; align-items: center; font-size: 13px; }
.switch label { color: var(--muted); cursor: pointer; }
a.dl {
  color: var(--text); text-decoration: none; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
  background: #182238;
}
a.dl:hover { border-color: var(--pos); }
.chart { width: 100%; height: 320px; margin: 6px 0 18px; background: var(--panel);
         border: 1px solid var(--line); border-radius: 8px; }
.chart.tall { height: 420px; }
.chart.heat { height: 680px; }
/* C36: 日付（1〜31日）の 4 桁の値ラベルは 90 度に倒して出す。倒した分の高さを確保する。 */
#chart-day-mean, #chart-day-win { height: 372px; }
.table-wrap {
  overflow: auto; max-height: 480px; border: 1px solid var(--line); border-radius: 8px;
}
table { border-collapse: collapse; width: 100%; font-size: 13px;
        font-variant-numeric: tabular-nums; }
/* C36: 4 桁表示で桁が増えても、折り返して読めなくならないように 1 行で出す
   （入りきらない表は .table-wrap の横スクロールで見る）。 */
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right;
         white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: #182238; color: var(--muted); font-weight: 600; position: sticky;
           top: 0; }
tbody tr:hover { background: #182238; }
tr.partial td { opacity: .55; }
.partial-tag {
  display: inline-block; font-size: 10.5px; padding: 1px 6px; margin-left: 6px;
  border: 1px solid var(--accent); color: var(--accent); border-radius: 999px;
}
footer { padding: 16px 24px 40px; color: var(--muted); font-size: 12px;
         border-top: 1px solid var(--line); }
footer p { margin: 6px 0; max-width: 92ch; }
@media (max-width: 720px) {
  main { padding: 14px 12px 32px; }
  header.top { padding: 16px 12px 6px; }
  nav.tabs { padding: 10px 12px 0; }
  .rangebar { padding: 10px 12px 0; }
  .range-row { gap: 8px; }
  .range-label { flex: 1 1 46%; }
  .range-label input[type="date"] { width: 100%; }
  .range-presets { margin-left: 0; }
  .load-error { margin: 8px 12px 0; }
  .card { min-width: 96px; padding: 8px 10px; }
  .card .v { font-size: 16px; }
  .chart, .chart.tall { height: 280px; }
  #chart-day-mean, #chart-day-win { height: 320px; }
}

.subhead { font-size: 16px; margin: 26px 0 6px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------- PDF レポート (C33) */
.range-btn.accent { border-color: var(--accent); color: var(--accent); }
.range-btn.accent:hover { background: rgba(255, 209, 102, .12); }
.range-btn:disabled { opacity: .55; cursor: progress; }
.range-btn[aria-disabled="true"], a.range-btn:not([href]) {
  opacity: .5; pointer-events: none;
}
body.report-open { overflow: hidden; }
.report-modal {
  position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(4, 8, 16, .78); backdrop-filter: blur(3px);
}
.report-modal[hidden] { display: none; }
.report-box {
  display: flex; flex-direction: column; width: min(1180px, 100%);
  height: min(92vh, 100%); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.report-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.report-title-wrap h2 { font-size: 15px; margin: 0 0 2px; }
.report-status { margin: 0; font-size: 12px; color: var(--muted); max-width: 56ch; }
.report-status.neg { color: var(--neg); }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-actions .range-btn { text-decoration: none; display: inline-block; }
.report-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.report-body iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: #0b1222; }
.report-fallback { margin: 0; padding: 6px 16px 10px; font-size: 11.5px; color: var(--muted); }
/* C42: 単月の大きな下落（7091 の画面を埋め込む）。高さは app.js が中身に合わせる。 */
.crash-frame { display: block; width: 100%; min-height: 480px; border: 0; background: var(--bg); }
.crash-open { color: var(--accent); }
@media (max-width: 720px) {
  .report-modal { padding: 0; }
  .report-box { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
  .report-head { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .report-title-wrap h2 { font-size: 14px; }
  .report-status { font-size: 11.5px; }
  .report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .report-actions .range-btn { text-align: center; padding: 8px 6px; }
  .report-actions #report-close { grid-column: span 2; }
  .report-fallback { padding: 6px 12px 8px; }
}

.sp500-back { margin: 10px 16px 0; font-size: 13px; }
.sp500-back a { color: #9fc3ff; }
.sp500-title { margin: 6px 16px 0; font-size: 22px; color: #e8eef8; }
.range-label, #range-apply { display: none !important; }
.sp500-note { margin: 8px 16px 0; padding: 6px 10px; border: 1px solid #3a4a66; color: #ffd166; font-size: 12px; }
.sp500-link { margin: 12px 0; }
