/* ============================================================
   比較のページの共通の部品（assets/css/cmp.css）
   画面の組み立ては assets/js/cmp/ui.js。見た目の案は docs/hikaku/mock/cmp-layout.html。
   色・角丸・影は ek.css の変数（--accent・--surface など）だけを使う（ダークモードは ek.css が切り替える）。
   ek.css の部品と名前がぶつからないよう、全部 cmp- を付けて .cmp の中に閉じる。
   ============================================================ */
.cmp { margin: 0 0 8px; }
.cmp-sec { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; margin: 0 0 16px; }
.cmp-sec[hidden] { display: none; }
.cmp-sec > h2 { font-size: 17px; margin: 0 0 12px; line-height: 1.4; }
.cmp-sec h3 { font-size: 15px; margin: 18px 0 8px; }
.cmp-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; line-height: 1.7; }
.cmp-msg { font-size: 14px; color: var(--ink-2); margin: 8px 0; }

/* ---------- 入力：PC は3列、スマホは1列 ---------- */
.cmp-form { margin: 0 0 16px; }
.cmp-q { display: grid; grid-template-columns: 1fr; gap: 16px 20px; align-items: start; }
.cmp-q.cols-2 { grid-template-columns: 1fr 1fr; }
.cmp-q.cols-3 { grid-template-columns: 1.2fr 1.4fr 1fr; }
.cmp-q-more { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.cmp .qh { display: block; font-weight: 700; font-size: 14px; margin: 0 0 6px; color: var(--ink); }
.cmp .cmp-fl { display: block; font-weight: 600; font-size: 13px; margin: 0 0 4px; color: var(--ink-2); }
.cmp-num { display: flex; align-items: center; gap: 6px; }
.cmp-num .u { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.cmp .cmp-num input {
  width: 100%; min-width: 0; font: inherit; font-size: 20px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums;
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); margin: 0;
}
.cmp .compact .cmp-num input { font-size: 16px; padding: 6px 8px; }
.cmp .cmp-num input:focus-visible, .cmp select:focus-visible, .cmp button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmp select {
  font: inherit; font-size: 14px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); max-width: 100%;
}
.cmp-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }
.cmp-err { font-size: 13px; color: var(--tint-warn-ink); background: var(--tint-warn); border-radius: 6px; padding: 4px 8px; margin: 6px 0 0; }
.cmp-err[hidden] { display: none; }
.cmp-err-all { margin-top: 12px; }

.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cmp-chip {
  font: inherit; font-size: 13px; line-height: 1.4; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--baseline); background: var(--surface); color: var(--ink-2);
}
.cmp-chip:hover { border-color: var(--accent); }
.cmp-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cmp-seg { display: flex; border: 1px solid var(--baseline); border-radius: 8px; overflow: hidden; }
.cmp-seg button {
  flex: 1; font: inherit; font-size: 13px; padding: 9px 4px; color: var(--ink-2); background: var(--surface);
  border: 0; border-radius: 0; cursor: pointer; margin: 0; min-width: 0;
}
.cmp-seg button + button { border-left: 1px solid var(--baseline); }
.cmp-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cmp-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; color: var(--ink); }
.cmp-check input { accent-color: var(--accent); margin: 3px 0 0; }

/* 札を押すと出る額の欄 */
.cmp-pairs { display: grid; gap: 8px; margin-top: 10px; }
.cmp-pair { background: var(--page); border-radius: 8px; padding: 10px 12px; }
.cmp-pair[hidden] { display: none; }
.cmp-pair-h { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.cmp-pair-fs { display: grid; gap: 8px; }
.cmp-pair .cmp-seg button { padding: 6px 4px; }

.cmp-more { margin-top: 14px; }
.cmp-more > summary { cursor: pointer; font-size: 14px; color: var(--accent); font-weight: 600; list-style: none; user-select: none; }
.cmp-more > summary::-webkit-details-marker { display: none; }
.cmp-more > summary::before { content: "▸ "; }
.cmp-more[open] > summary::before { content: "▾ "; }

/* 広告の断り：ほかの文と同じ大きさ */
.cmp-adnote { font-size: 14px; color: var(--ink-2); margin: 0 0 16px; padding: 10px 12px; border-left: 3px solid var(--baseline); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; line-height: 1.7; }

/* ---------- 答え ---------- */
.cmp-answer .lbl { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.cmp-answer .who { font-size: 28px; font-weight: 800; margin: 4px 0 2px; line-height: 1.3; color: var(--ink); }
.cmp-answer .val { font-size: 34px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.3; }
.cmp-answer .val small { font-size: 15px; font-weight: 700; color: var(--ink-2); margin-left: 4px; }
.cmp-answer .sub { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.cmp-answer .sub:empty { display: none; }
.cmp-answer.is-empty .lbl { color: var(--ink); }
.cmp-errlist { margin: 8px 0 0; padding-left: 1.2em; font-size: 14px; color: var(--tint-warn-ink); }
.cmp-stale { font-size: 15px; margin: 8px 0 0; padding: 10px 12px; background: var(--tint-warn); color: var(--tint-warn-ink); border-radius: 8px; }
.cmp-cond { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.cmp-cond span { font-size: 12px; background: var(--page); border: 1px solid var(--grid); border-radius: 6px; padding: 3px 8px; color: var(--ink-2); }
.cmp-minis { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; border-top: 1px solid var(--grid); }
.cmp-minis > div { padding: 12px 12px 0 0; min-width: 0; }
.cmp-minis > div + div { padding-left: 12px; border-left: 1px solid var(--grid); }
.cmp-minis b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--ink); }
.cmp-minis span { font-size: 12px; color: var(--muted); line-height: 1.5; display: block; }

/* ---------- 一覧：行カード。PC は列がそろって表のように読める ---------- */
.cmp-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 14px; }
.cmp-tools .cmp-chips { margin: 0; }
.cmp-sortl { display: inline-flex; align-items: center; gap: 6px; }
.cmp-head, .cmp-row { display: grid; grid-template-columns: 40px minmax(180px, 1.5fr) minmax(200px, 1.6fr) minmax(150px, 1fr) 96px; gap: 12px; align-items: center; }
.cmp-head { font-size: 12px; color: var(--muted); padding: 0 14px 6px; border-bottom: 1px solid var(--grid); }
.cmp-list { list-style: none; margin: 0; padding: 0; }
.cmp-item { border-bottom: 1px solid var(--grid); padding: 14px; }
.cmp-item.top { background: var(--tint-good); border-radius: var(--r); border-bottom-color: transparent; }
.cmp-rk { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.cmp-rk.ref { background: var(--muted); }
.cmp-nm { min-width: 0; }
.cmp-nm b { display: block; font-size: 15px; line-height: 1.35; color: var(--ink); }
.cmp-nm small { display: block; color: var(--muted); font-size: 12px; }
.cmp-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.cmp-tag { font-size: 11px; line-height: 1.5; padding: 1px 6px; border-radius: 4px; background: var(--page); border: 1px solid var(--grid); color: var(--ink-2); }
.cmp-tag.chg { background: var(--tint-warn); color: var(--tint-warn-ink); border-color: transparent; font-weight: 700; }
.cmp-tag.note { border-style: dashed; }
.cmp-v { min-width: 0; }
.cmp-v .big { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.cmp-v .big.neg { color: var(--muted); }
.cmp-bar { height: 8px; background: var(--grid); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cmp-reason { display: inline-block; font-size: 12px; line-height: 1.5; color: var(--tint-warn-ink); background: var(--tint-warn); border-radius: 4px; padding: 1px 6px; }
.cmp-refv { font-size: 13px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.cmp-bd { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; line-height: 1.6; }
.cmp-bd span { display: block; }
.cmp-bd .minus { color: var(--muted); }
.cmp-act { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.cmp-pick {
  font: inherit; font-size: 13px; display: flex; gap: 6px; align-items: center; justify-content: center; cursor: pointer;
  border: 1px solid var(--baseline); border-radius: 8px; padding: 5px 6px; background: var(--surface); color: var(--ink);
}
.cmp-pick[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.cmp-pick:disabled { opacity: .45; cursor: not-allowed; }
.cmp-open { font: inherit; font-size: 13px; color: var(--accent); text-align: center; background: none; border: 0; padding: 2px; cursor: pointer; }
.cmp-open:hover { text-decoration: underline; }

/* 行の下の段：確認日・公式サイト・広告（広告は右端、線で区切る） */
.cmp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 10px 0 0 52px; font-size: 12px; color: var(--muted); }
.cmp-foot a { color: var(--accent); }
.cmp-foot .old { color: var(--tint-warn-ink); font-weight: 700; }
.cmp-ad { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--grid); }
.cmp-ad em { font-style: normal; font-size: 11px; border: 1px solid var(--line-strong); color: var(--ink-2); border-radius: 3px; padding: 0 4px; }
.cmp-foot .cmp-ad a { color: var(--ink-2); text-decoration: underline; }
.cmp-px { position: absolute; width: 1px; height: 1px; border: 0; opacity: 0; }

/* 内訳と根拠（res.steps） */
.cmp-why { margin: 12px 0 0 52px; background: var(--page); border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--ink); }
.cmp-why[hidden] { display: none; }
.cmp-item.top .cmp-why { background: var(--surface); }
.cmp-why table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cmp-why td { padding: 5px 0; border-bottom: 1px dashed var(--grid); vertical-align: top; }
.cmp-why td small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.cmp-why td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.cmp-why p { margin: 8px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.cmp-why .cmp-miss { color: var(--tint-warn-ink); }
.cmp-notes { margin: 8px 0 0; padding-left: 1.2em; color: var(--ink-2); }
.cmp-url { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* 参考・対象外 */
.cmp-refsec .cmp-item { opacity: .92; }
.cmp-exc { margin: 0; padding-left: 1.2em; font-size: 13px; color: var(--ink-2); line-height: 1.8; }
.cmp-exc b { color: var(--ink); }

/* ---------- 図（たたまない） ---------- */
.cmp-chart-box svg { width: 100%; height: auto; display: block; overflow: visible; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; margin-top: 8px; color: var(--ink-2); }
.cmp-legend i { display: inline-block; width: 16px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.cmp-be { font-size: 14px; margin: 10px 0 0; line-height: 1.7; }
.cmp-be[hidden] { display: none; }
.cmp-be b { color: var(--ink); }

/* 前提と範囲 */
.cmp-scope dl { display: grid; grid-template-columns: 9em 1fr; gap: 8px 16px; margin: 0; font-size: 14px; line-height: 1.7; }
.cmp-scope dt { color: var(--muted); font-weight: 700; }
.cmp-scope dd { margin: 0; }

/* 選んで比べる：並べた表 */
.cmp-vs-scroll { overflow-x: auto; }
.cmp-vs table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.cmp-vs th, .cmp-vs td { padding: 8px 6px; border-bottom: 1px solid var(--grid); text-align: right; vertical-align: top; overflow-wrap: anywhere; }
.cmp-vs th:first-child, .cmp-vs td:first-child { text-align: left; color: var(--muted); font-weight: 700; width: 28%; }
.cmp-vs thead th { font-size: 13px; color: var(--ink); }
.cmp-vs .win { color: var(--good-text); font-weight: 800; }

/* 画面の下の帯（選んでいるときだけ） */
.cmp-tray {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 50; width: min(1040px, calc(100% - 16px));
  background: var(--ink); color: var(--surface); border-radius: var(--r) var(--r) 0 0; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: var(--shadow);
}
.cmp-tray[hidden] { display: none; }
.cmp-tray b { font-size: 14px; }
.cmp-tray .btns { display: flex; gap: 8px; flex: none; }
.cmp-tray button { font: inherit; font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 8px; cursor: pointer; border: 1px solid var(--surface); }
.cmp-tray .go { background: var(--surface); color: var(--ink); }
.cmp-tray .go:disabled { opacity: .5; cursor: not-allowed; }
.cmp-tray .off { background: transparent; color: var(--surface); font-weight: 500; }
body.cmp-has-tray { padding-bottom: 64px; }

@media (max-width: 760px) {
  .cmp-sec { padding: 16px; }
  .cmp-q.cols-2, .cmp-q.cols-3, .cmp-q-more { grid-template-columns: 1fr; gap: 14px; }
  .cmp-answer .who { font-size: 22px; }
  .cmp-answer .val { font-size: 28px; }
  .cmp-minis { grid-template-columns: 1fr; }
  .cmp-minis > div, .cmp-minis > div + div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-left: 0; border-bottom: 1px solid var(--grid); }
  .cmp-minis b { order: 2; font-size: 16px; white-space: nowrap; }
  .cmp-minis span { font-size: 13px; }
  .cmp-head { display: none; }
  .cmp-row { grid-template-columns: 32px minmax(0, 1fr) 88px; grid-template-areas: "rk nm act" "v v v" "bd bd bd"; gap: 8px 10px; }
  .cmp-row .cmp-rk { grid-area: rk; } .cmp-row .cmp-nm { grid-area: nm; } .cmp-row .cmp-act { grid-area: act; }
  .cmp-row .cmp-v { grid-area: v; } .cmp-row .cmp-bd { grid-area: bd; }
  .cmp-item { padding: 14px 4px; }
  .cmp-item.top { padding: 14px 10px; }
  .cmp-bd { display: flex; gap: 4px 12px; flex-wrap: wrap; }
  .cmp-bd span { display: inline; }
  .cmp-foot { margin-left: 0; }
  .cmp-ad { margin-left: 0; width: 100%; padding: 8px 0 0; border-left: 0; border-top: 1px solid var(--grid); justify-content: space-between; }
  .cmp-why { margin-left: 0; padding: 10px; }
  .cmp-scope dl { grid-template-columns: 1fr; gap: 2px; }
  .cmp-scope dd { margin-bottom: 8px; }
  .cmp-vs th:first-child, .cmp-vs td:first-child { width: 30%; }
  .cmp-vs table { font-size: 13px; }
  .cmp-tray { width: 100%; border-radius: 0; padding: 8px 12px; }
  .cmp-tray b { font-size: 13px; }
  .cmp-tray button { font-size: 13px; padding: 6px 10px; }
}

/* 解説の中の式（比較のページの本文） */
.article .formula-line { background: var(--page); border-radius: 8px; padding: 10px 12px; line-height: 1.8; }
.cmp-tray b small { font-size: 12px; font-weight: 500; margin-left: 4px; opacity: .85; }
@media (max-width: 640px) { .cmp-tray b small { display: none; } }
/* 長い注記の札：スマホでは2行で切り、押すと開く */
.cmp-tag.clamp { cursor: pointer; }
@media (max-width: 760px) {
  .cmp-tag.clamp:not(.open) { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
/* 一覧の残りを開くボタン（40枚のとき上位10枚だけを出す） */
.cmp-more-btn { display: block; width: 100%; margin: 12px 0 0; padding: 10px; font: inherit; font-size: 14px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 8px; cursor: pointer; }
.cmp-more-btn:hover { text-decoration: underline; }
