/* 階段の計算だけの見た目（共通の style.css には足さない）。
   色の意味はアプリ（かんたん階段計算）と同じ3つ＋墨: 朱＝法に入らない／茶＝等級に入らない・境目（共通の --warn）／
   緑＝入る・等級の例外に当たる回り（共通の --ok）。★色だけで言わない（記号と語を必ず添える）。 */

:root {
  --k-alarm: #b3361f;
  --k-alarm-soft: #f8e3de;
  --k-exempt-soft: #e1efe5;
  --k-caution-soft: #f6e9da;
  --k-faint: #8d97a1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --k-alarm: #f08d78;
    --k-alarm-soft: #3b231d;
    --k-exempt-soft: #1c2e23;
    --k-caution-soft: #33271b;
    --k-faint: #6f7a85;
  }
}

/* ── 入力 ── */
/* 欄のまとまり＝fieldset.group（★div で包むと、まとまり全体が1つの文に数えられる＝test/site の40字の決まり） */
.tool fieldset.group { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 12px 0 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tool fieldset.group:first-of-type { border-top: 0; padding-top: 0; }
/* legend は枠の線の上に乗るので、ふつうの塊として置き直す */
.tool fieldset.group > legend { float: left; width: 100%; font-size: 15px; font-weight: 700; padding: 0; margin: 0 0 2px; }
.tool fieldset.group > legend + * { clear: both; }
.tool .computed { font-size: 14px; color: var(--muted); }
.tool .check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; font-size: 15px; }
.tool .missing { font-size: 14px; color: var(--muted); }
.tool .low-height { font-size: 13px; color: var(--warn); }

/* ── 結果 ── */
.kaidan-out { display: flex; flex-direction: column; gap: 14px; }
.kaidan-out h3 { font-size: 15px; }
.kaidan-out .headline { display: flex; flex-direction: column; gap: 2px; }
.kaidan-out .headline .shape { font-weight: 700; }
.kaidan-out .headline .numbers { font-size: 14px; color: var(--muted); font-family: var(--font); }

.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
/* スマホの幅では、判定の札を縦の一覧に（2列だと3枚目が1枚で残る＝2026-10-18 UI改善） */
@media (max-width: 560px) {
  .strip { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
  .strip .cell { border: 0; border-radius: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: baseline; background: transparent; }
  .strip .cell:first-child { border-top: 0; }
  .strip .cell .name { font-size: 14px; color: var(--fg); }
  .strip .cell .verdict { grid-column: 2; grid-row: 1; font-size: 16px; }
  .strip .cell .reason { grid-column: 1 / -1; color: var(--muted); }
}
.strip .cell { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.strip .cell .name { font-size: 12px; color: var(--muted); font-weight: 600; }
.strip .cell .verdict { font-size: 17px; font-weight: 700; }
.strip .cell .reason { font-size: 13px; overflow-wrap: anywhere; }

.v-within, .v-exactlyAtLimit { color: var(--ok); }
.v-boundary { color: var(--warn); }
.v-exceeds { color: var(--warn); }
.v-exceeds.v-law { color: var(--k-alarm); }
.v-none { color: var(--muted); }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.figure-box { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.figure-box .caption { font-size: 12px; color: var(--muted); }
.k-figure { width: 100%; height: auto; max-height: 460px; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }

/* 平面図 */
.k-cell { fill: none; stroke: var(--line); stroke-width: 0.75; stroke-dasharray: 3 3; }
.k-tread { stroke-width: 1; stroke: var(--fg); }
.k-tread.k-plain { fill: var(--surface); }
.k-tread.k-alarm { fill: var(--k-alarm-soft); stroke: var(--k-alarm); stroke-width: 1.5; }
.k-tread.k-exempt { fill: var(--k-exempt-soft); stroke: var(--ok); stroke-width: 1.5; }
.k-tread.k-caution { fill: var(--k-caution-soft); }
.k-arc { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 2 3.5; }
.k-arc-alarm { stroke: var(--k-alarm); }
.k-arc-caution { stroke: var(--warn); }
.k-arc-ok { stroke: var(--ok); }
.k-pivot { fill: var(--fg); }
.k-arc-label { font: 700 13px var(--mono); fill: var(--fg); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }
.k-step { font: 600 11px var(--mono); fill: var(--muted); }
.k-step.k-alarm { fill: var(--k-alarm); }
.k-step.k-exempt { fill: var(--ok); }
.k-step.k-caution { fill: var(--warn); }
.k-mark { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.k-end { font: 600 13px var(--font); fill: var(--muted); }

/* 断面図 */
.k-floor { stroke: var(--muted); stroke-width: 1; }
.k-profile { fill: none; stroke: var(--fg); stroke-width: 1.5; }
.k-profile-alarm { stroke: var(--k-alarm); }
.k-slope { stroke: var(--k-faint); stroke-width: 1; }
.k-limit { stroke-width: 1.2; fill: none; }
.k-limit-law { stroke: var(--k-alarm); stroke-dasharray: 5 3; }
.k-limit-grade { stroke: var(--warn); stroke-dasharray: 1.5 3; }
.k-limit-label { font: 600 11px var(--font); stroke: none; paint-order: stroke; }
text.k-limit-law { fill: var(--k-alarm); }
text.k-limit-grade { fill: var(--warn); }
.k-angle-arc { fill: none; stroke: var(--muted); stroke-width: 1; }
.k-angle { font: 700 15px var(--mono); fill: var(--fg); }
.k-dim { stroke: var(--muted); stroke-width: 1; fill: none; }
.k-dim-name { font: 600 11px var(--font); fill: var(--muted); }
.k-dim-value { font: 700 13px var(--mono); fill: var(--fg); }
.k-alarm-text { fill: var(--k-alarm); }

/* 判定の内訳 */
.summary { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.summary:first-child { border-top: 0; padding-top: 0; }
.summary .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.line-item { display: flex; flex-direction: column; gap: 2px; padding-left: 10px; border-left: 3px solid transparent; }
.line-item.t-alarm { border-left-color: var(--k-alarm); }
.line-item.t-caution { border-left-color: var(--warn); }
.line-item.t-exemption { border-left-color: var(--ok); }
.line-item .row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.line-item .title { font-size: 15px; }
.line-item .detail, .line-item .part { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.line-item .part { display: flex; gap: 8px; flex-wrap: wrap; }
.line-item .part .label { font-family: var(--font); color: var(--muted); }
.line-item .note { font-size: 13px; color: var(--muted); }
.passing summary { cursor: pointer; color: var(--fg); }
.passing ul { list-style: none; padding-left: 0; font-size: 13px; color: var(--muted); margin-top: 4px; }
.cites { font-size: 12px; color: var(--muted); }
.cites ul { padding-left: 1.2em; gap: 2px; }

/* 食い違い・天井高 */
.stop { border: 1px solid var(--warn); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.stop .title { font-weight: 700; }
.stop .numbers { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.choices-stop { display: flex; flex-direction: column; gap: 8px; }
.choice-button {
  font: inherit; text-align: left; cursor: pointer; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.choice-button:hover { border-color: var(--accent); }
.choice-button .choice-result { font-size: 13px; color: var(--muted); }
.stop .waiting { font-size: 13px; font-weight: 600; color: var(--muted); }
.range-risers { font-family: var(--mono); font-size: 18px; font-weight: 700; }

/* 比べる */
.variants { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.variant {
  font: inherit; text-align: left; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; cursor: pointer;
}
.variant.focus { border: 1.5px solid var(--fg); background: var(--surface); cursor: default; }
.variant .risers { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.variant .small-name { font-size: 12px; color: var(--muted); }
.variant .riser { font-family: var(--mono); font-weight: 700; }
.variant .marks { font-size: 13px; display: flex; flex-direction: column; gap: 0; }
.variant .misfit { font-size: 12px; font-family: var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.variant .warn-text { font-size: 13px; font-weight: 700; color: var(--warn); }
.variant .foot { font-size: 13px; margin-top: auto; }
.variant-actions { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; }
.link-button { font: inherit; font-size: 14px; background: none; border: 0; padding: 4px 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.counts td.n { font-size: 15px; }
.counts td.zero { color: var(--muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 480px) {
  .variants { gap: 6px; }
  .variant { padding: 8px; }
  .variant .risers { font-size: 16px; }
}

/* 話題のページ（説明のタブ）の表と式。★390 幅で字の列が2〜3字ずつに折れない（数と見出しは空白で折ってよい）・式は横にはみ出さずに折り返す */
.topic-body .formula { white-space: pre-wrap; }
.topic-body th, .topic-body td { padding: 8px; }
.topic-body th { white-space: normal; }
.topic-body td.n { white-space: normal; word-break: keep-all; }
.topic-body td.wide { min-width: 6em; }

/* 階段の欄の名前は長い（「階高（1階の床の上端〜2階の床の上端）」など）＝スマホでは組の欄も縦に1つずつ（2026-10-18 UI改善の2周目） */
@media (max-width: 560px) {
  .row > .field { flex-basis: 100%; }
}
