/* ============================================================
   E-計算！ Math — データの平均・ばらつき・分位点（data-summary.html）だけで使う見た目
   共通（../assets/css/ek.css の v2 層・css/math.css）の上に重ねる。色は共通の変数だけを使う。
   ============================================================ */

/* ---- 要点（リードの直下） ---- */
.ds-quick { margin: 4px 0 22px; }
.ds-quick ul { margin: 2px 0 0; padding-left: 1.2em; }
.ds-quick li { margin: 2px 0; }

/* ---- データの入力欄 ---- */
.ds-data {
  display: block; width: 100%; min-width: 0; min-height: 190px; resize: vertical;
  padding: 10px 12px; font: inherit; font-size: 15px; line-height: 1.6; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
}
.ds-data:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.ds-data[aria-invalid="true"] { border-color: var(--s2); border-width: 2px; }
.ds-unit input[aria-invalid="true"], #bwVal[aria-invalid="true"], #lv[aria-invalid="true"], #lp[aria-invalid="true"] { border-color: var(--s2); border-width: 2px; }
/* 入力の案内。空でも1行分の高さを取っておく（読み込み後に下の欄がずれないように） */
.ds-msg { margin: 8px 0 0; min-height: 1.7em; font-size: 13px; line-height: 1.7; color: var(--muted); }
.ds-msg.warn { color: var(--tint-warn-ink); }
.ds-rules { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.ds-tools { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 4px 0 16px; font-size: 13px; color: var(--ink-2); }
.ds-clear { border: 1px solid var(--grid); border-radius: 999px; padding: 5px 12px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.ds-clear:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 結果 ---- */
/* 最初の計算が終わるまでの場所を取っておく（読み込み後のずれを小さくする） */
#resultPanel:not(.ds-off) #result { min-height: 232px; }
#resultPanel:not(.ds-off) .ds-fig-hist { min-height: 300px; }
#resultPanel:not(.ds-off) .ds-fig-box { min-height: 190px; }
#resultPanel.ds-off details.why { display: none; }
.ds-unit input[type="text"] { text-align: left; }
table.data th[scope="row"] { text-align: left; font-weight: 600; color: var(--ink); }
table.data.ds-stats th .sub { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); }
table.data.ds-stats thead th { text-align: left; }
table.data.ds-stats thead th.n { text-align: right; }
table.data.ds-stats tr.ds-sep > * { border-top: 2px solid var(--grid); }
/* 共通CSSは最後の行の td だけ下線を消すので、行見出し（th）もそろえる */
table.data tbody tr:last-child > th[scope="row"] { border-bottom: 0; }
table.data td.ds-note, table.data th.ds-note { white-space: normal; font-size: 12px; color: var(--muted); }
.ds-fig { margin: 22px 0 0; padding: 16px 16px 12px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); min-width: 0; }
.ds-fig figcaption { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; line-height: 1.6; }
.ds-fig .ds-cap-sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.ds-fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.ds-fig svg text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ds-fig .ax { stroke: var(--baseline); stroke-width: 1; }
.ds-fig .gl { stroke: var(--grid); stroke-width: 1; }
.ds-fig .bar { fill: color-mix(in srgb, var(--accent) 72%, var(--surface)); }
.ds-fig .mean { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 3; }
.ds-fig .med { stroke: var(--ink); stroke-width: 2; }
.ds-fig .box { fill: color-mix(in srgb, var(--accent) 18%, var(--surface)); stroke: var(--accent); stroke-width: 1.5; }
.ds-fig .wh { stroke: var(--ink-2); stroke-width: 1.5; }
.ds-fig .out { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.ds-fig .mk { fill: var(--ink); }
.ds-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 0; margin: 8px 0 0; font-size: 12px; color: var(--ink-2); }
.ds-legend li { display: flex; align-items: center; gap: 6px; }
.ds-legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--ink); }
.ds-legend i.dash { border-top: 2px dashed var(--ink); }
.ds-legend i.sw { width: 12px; height: 10px; border: 0; border-radius: 2px; background: color-mix(in srgb, var(--accent) 72%, var(--surface)); }
.ds-legend i.ring { width: 9px; height: 9px; border: 1.5px solid var(--ink); border-radius: 50%; }
.ds-five { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.ds-five b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ds-fig-msg { margin: 0; font-size: 13px; color: var(--tint-warn-ink); }
/* 入力の読み方の注意（3桁区切り・表の貼り付けなど）。結果カードの上に出す */
#result .ds-inwarn { margin: 0 0 14px; }
/* 桁の多い数（1,000,000,000,001.5 や 1.5×10¹⁵）が狭い画面ではみ出さないように */
#result .res-hero .big b, #result .res-hero .sub, #result .res-mini .v, #result .res-mini .s, .ds-five, .ds-look li { overflow-wrap: anywhere; }
html[data-ui="v2"] #result.ds-long .res-hero .big b { font-size: 30px; }
@media (max-width: 560px) {
  /* 桁の多い数のときは、小さな3つを縦に並べる（1/3 の幅では数の途中で折り返してしまう） */
  html[data-ui="v2"] #result.ds-long .res-mini { grid-template-columns: 1fr; }
  html[data-ui="v2"] #result.ds-long .res-mini > div { padding: 8px 0 0; }
  html[data-ui="v2"] #result.ds-long .res-mini > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--grid); margin-top: 8px; }
}
/* 一覧の表：項目名は折り返して、値の列を狭い画面でも見えるようにする */
table.data.ds-stats th[scope="row"], table.data.ds-stats thead th { white-space: normal; }
table.data.ds-stats th[scope="row"] { min-width: 7em; }
/* 本文の比較表：見出しは「第1」「四分位数」の間で折り返してよい（共通CSSの th.n は折り返さない） */
table.data.ds-cmp th.n { white-space: normal; }
@media (max-width: 480px) {
  html[data-ui="v2"] table.data.ds-stats th, html[data-ui="v2"] table.data.ds-stats td,
  html[data-ui="v2"] table.data.ds-cmp th, html[data-ui="v2"] table.data.ds-cmp td,
  html[data-ui="v2"] table.data.ds-freq th, html[data-ui="v2"] table.data.ds-freq td { padding-left: 6px; padding-right: 6px; }
}
/* 折り返してよい位置を決める（「第1」「四分位数」の間など） */
.ds-nb { display: inline-block; white-space: nowrap; }
/* 度数分布表：階級の欄は折り返して、度数の列が狭い画面でも見えるように */
table.data.ds-freq th { white-space: normal; }
table.data.ds-freq td.ds-bin { white-space: normal; text-align: left; min-width: 7.5em; }

/* ---- 上位何%・パーセンタイル ---- */
.ds-look { margin: 4px 0 0; padding: 0; list-style: none; }
.ds-look li { padding: 10px 0; border-top: 1px solid var(--grid); font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.ds-look li:first-child { border-top: 0; padding-top: 4px; }
.ds-look .k { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.ds-look .v { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 4px; }
.ds-look small { font-size: 12px; color: var(--muted); }

@media (max-width: 560px) {
  .ds-fig { padding: 12px 10px 10px; }
  .ds-fig svg text { font-size: 10.5px; }
}

/* ---- 本文の表（求め方の比較）。データ名は表の幅いっぱいの行にして、数の列を狭い画面でも見えるようにする ---- */
table.data.ds-cmp th.ds-m { text-align: left; font-weight: 600; color: var(--ink); }
table.data.ds-cmp tr.ds-grp th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2); background: var(--page); }
table.data.ds-cmp tbody tr.ds-grp:hover { background: transparent; }
