/* うちの器で量る: 粉引きの灰白の地・鉄の黒の文字・土の赤茶1色(答えと選択の印だけ)。器は木の台に置く。
   gamebook(生成り・墨・朱)と色を重ねない(CHECKLIST 3章) */
:root {
  --main-w: 1200px;
  --ground: #ebeae5; --ink: #2b2a27; --ink2: #57554f; --rule: #c4c1b8;
  --accent: #9c4a26; --water: #c9dde3; --glaze: #e6e3dc; --paper: #f6f5f1;
  --focus: #9c4a26; --ad-line: #c4c1b8; --ad-text: #57554f;
  --mincho: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --gothic: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}
html { background: var(--ground); color: var(--ink); }
body { margin: 0; font: 16px/1.6 var(--gothic); }
.num, .std, .vcap, table, .tick { font-variant-numeric: tabular-nums; }
a { color: var(--ink); }

.head { padding-top: 28px; padding-bottom: 14px; border-bottom: 1px solid var(--ink); }
.head h1 { font: 600 40px/1.2 var(--mincho); margin: 0; letter-spacing: .04em; }
.lead { margin: 8px 0 0; color: var(--ink2); font-size: 17px; }

.tool {
  display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 4fr); column-gap: 48px;
  grid-template-areas: "stage input" "stage sub" "stage more";
  grid-template-rows: auto auto 1fr;
  padding-top: 24px;
}
.tool > * { min-width: 0; }
/* 左の列(器の台+棚)ごと追従。列の中では重ならない */
.col-l { grid-area: stage; align-self: start; position: sticky; top: 12px; min-width: 0; }
/* 左の列は 答え+器の台(〜400)+案内+棚 で約 860px。それより低い画面では追従しない */
@media (max-height: 900px) { .col-l { position: static; } }
.stage { min-width: 0; }
.input { grid-area: input; }
.result { grid-area: result; }
.sub { grid-area: sub; }
.more { grid-area: more; }
.add { grid-area: input; }
.tool.adding .input, .tool.adding .result, .tool.adding .sub, .tool.adding .more { display: none; }

/* 器の台 */
.stage-cap { display: flex; align-items: baseline; gap: 12px; }
.vname { font: 600 24px/1.3 var(--mincho); }
.vcap { color: var(--ink2); font-size: 14px; }
.stage-figs { position: relative; }
.stage-figs.two { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.fig { display: block; width: 100%; max-width: 540px; height: auto; max-height: 400px; margin: 0 auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
/* 指で動かす所だけページを送らない(器の他の所をなぞればページが動く) */
.fig .knob, .fig .pt { touch-action: none; }
.fig .pt { cursor: grab; }
.fig .pt:focus { outline: none; }
.fig .pt:focus-visible circle:nth-child(2) { stroke: var(--ink); }
.tool.adding .fig { max-height: 520px; }
.fig2 { display: block; width: 100%; max-width: 200px; height: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; }
.fig2[hidden] { display: none; }
.stage-note { font-size: 13px; color: var(--ink2); margin: 4px 0 0; min-height: 1em; }
.mine-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 4px; }
.mine-cta p { margin: 0; flex: 1 1 16em; font-size: 14px; }
.mine-cta[hidden] { display: none; }
.mine-cta button { font-weight: 600; }
.nw { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.fig .knob { cursor: ns-resize; }
.fig .knob:focus { outline: none; }
.fig .knob:focus-visible circle.k { stroke: var(--ink); stroke-width: 3; }
.fig text { font-family: var(--gothic); }

/* 入力 */
.tabs { display: flex; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; font: 600 16px var(--gothic); color: var(--ink2); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 8px 0; }
.w { color: var(--ink2); }
select, input.num, input.name { font: 16px var(--gothic); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 0 8px; }
input.num { width: 6.5em; text-align: right; }
input.num.s { width: 4.5em; }
input.name { width: 100%; max-width: 20em; }
input[aria-invalid="true"] { border-color: #b3261e; }
select { max-width: 100%; }
button, .btn { font: 15px var(--gothic); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 0 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.swap, .q { width: 44px; padding: 0; border-radius: 50%; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.seg button[aria-pressed="true"], .chips button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.chips { display: flex; gap: 8px; margin: 8px 0; }
.chips.scroll { flex-wrap: wrap; }
.chips.wrap { flex-wrap: wrap; }
.tabs button { min-height: 44px; }
.chips button { white-space: nowrap; border-radius: 22px; }
.err { color: #b3261e; font-size: 14px; margin: 0; min-height: 0; }
.err:empty { display: none; }
.hint { font-size: 13px; color: var(--ink2); margin: 6px 0; }

/* 答え */
.result { margin: 0 0 8px; }
.rh, .sh, .ah { font: 600 14px var(--gothic); color: var(--ink2); margin: 0 0 4px; letter-spacing: .08em; }
.answer { font: 600 34px/1.35 var(--mincho); margin: 0; text-wrap: balance; word-break: auto-phrase; }
.answer.stale { opacity: .45; }
.answer em { font-style: normal; color: var(--accent); }
.sub { border-top: 1px solid var(--ink); margin-top: 16px; padding-top: 10px; }
.std { margin: 0 0 2px; color: var(--ink2); }
.std-note { margin: 0 0 8px; font-size: 13px; color: var(--ink2); }
.guide { border-left: 3px solid var(--accent); padding: 4px 12px; margin: 8px 0; font-size: 14px; }
.guide .chips { flex-wrap: wrap; margin: 6px 0 0; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.copied { font-size: 13px; color: var(--ink2); }
.answer .ph { display: inline-block; }
.dtable table { width: auto; font-size: 14px; }
.dtable caption { text-align: left; font-size: 13px; color: var(--ink2); padding-bottom: 2px; }

/* 棚 */
.shelf-wrap { border-top: 1px solid var(--rule); margin-top: 16px; padding-top: 10px; }
.shelf { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 2px 8px; }
.shelf .item { position: relative; flex: 0 0 auto; }
.shelf .pick { flex-direction: column; width: 92px; height: 104px; padding: 6px 4px; gap: 2px; font-size: 12px; line-height: 1.3; }
.shelf .pick svg, .shelf .pick .thumb { width: 48px; height: 52px; }
.shelf .pick .thumb { object-fit: cover; border-radius: 3px; }
.shelf .pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.shelf .menu { position: absolute; top: -6px; right: -6px; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: none; font-size: 18px; color: var(--ink2); }
.shelf .menu::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--paper); border: 1px solid var(--rule); z-index: -1; }
.shelf .item { isolation: isolate; }
.shelf .addv { width: 92px; height: 104px; flex: 0 0 auto; border: 1px dashed var(--accent); color: var(--accent); font-size: 13px; flex-direction: column; line-height: 1.3; }
.shelf .addv .plus { font-size: 24px; line-height: 1; }

/* 器を足す */
.add { border-top: 1px solid var(--ink); padding-top: 10px; }
.steps { padding-left: 1.4em; margin: 0; }
.steps li { margin: 0 0 14px; }
.stp { font-weight: 600; display: block; margin-bottom: 4px; }
.stp.sub { font-weight: 400; color: var(--ink2); font-size: 14px; margin-top: 10px; }
.aresult { font: 600 20px/1.4 var(--mincho); margin: 10px 0 4px; color: var(--ink2); }
.aresult.ok { color: var(--accent); }
.aover summary { min-height: 44px; font-weight: 400; font-size: 14px; color: var(--ink2); }
.file { position: relative; }

/* 詳しい設定・早見表 */
.more { margin-top: 16px; }
details { border-top: 1px solid var(--rule); }
details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
details summary::after { content: "+"; margin-left: auto; font-weight: 400; }
details[open] summary::after { content: "−"; }
.adv-body h3 { font-size: 15px; margin: 14px 0 4px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { min-height: auto; width: 20px; height: 20px; }
.tscroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--rule); padding: 6px 8px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr:focus { background: var(--paper); outline: none; }
tbody tr:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
td.pickq:hover, td.pickq:focus { color: var(--accent); text-decoration: underline; outline: none; }
td.pickq:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* ツールの後 */
.after { margin-top: 24px; }
.basis ul { font-size: 14px; color: var(--ink2); padding-left: 1.2em; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0; }
.card { display: block; border: 1px solid var(--rule); background: var(--paper); padding: 14px 16px; text-decoration: none; border-radius: 4px; }
.card b { font-family: var(--mincho); font-size: 18px; display: block; }
.card span { font-size: 14px; color: var(--ink2); }
.foot { padding-top: 16px; padding-bottom: 40px; border-top: 1px solid var(--rule); font-size: 14px; }

/* 記事 */
.article { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.article h1 { font: 600 32px/1.3 var(--mincho); margin: 28px 0 8px; }
.article h2 { font: 600 22px/1.4 var(--mincho); margin: 32px 0 8px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.article figure { margin: 16px 0; }
.article figure svg { width: 100%; max-width: 480px; height: auto; }
.article figcaption { font-size: 13px; color: var(--ink2); }

/* 左右の縦長は本文 1200px + 2*(160+32)px 以上のときだけ */
@media (min-width: 1584px) {
  .ad-slot.rail { display: flex; }
  .ad-slot.inline { display: none; }
}

@media (max-width: 860px) {
  .head { padding-top: 14px; padding-bottom: 8px; }
  .head h1 { font-size: 28px; }
  .lead { font-size: 13px; margin-top: 2px; }
  .tool { grid-template-columns: minmax(0, 1fr); grid-template-areas: "input" "result" "stage" "sub" "shelf" "more"; grid-template-rows: none; padding-top: 6px; }
  .result { grid-area: result; margin: 4px 0 0; }
  .answer { min-height: 0; }
  .sub { border-top: 0; margin-top: 4px; padding-top: 0; }
  .lead { font-size: 14px; }
  #unit { width: 6.2em; }
  #vsel { max-width: 9.5em; }
  .col-l { display: contents; }
  .stage { grid-area: stage; }
  .shelf-wrap { grid-area: shelf; }
  .shelf { flex-wrap: nowrap; overflow-x: auto; }
  .tool.adding { grid-template-areas: "stage" "add" "shelf"; }
  .tool.adding .add { grid-area: add; }
  .tabs { margin-bottom: 4px; }
  .sentence { margin: 4px 0; gap: 4px 6px; }
  .chips { margin: 4px 0; }
  .chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .chips.scroll::-webkit-scrollbar { display: none; }
  .chips.scroll.at-end { -webkit-mask-image: none; mask-image: none; }
  .rh { display: none; }
  .answer { font-size: 24px; }
  .stage-cap { display: none; }
  .stage { position: static; }
  .fig { max-width: 320px; max-height: 230px; margin: 0 auto; }
  .tool.adding .fig { max-width: 100%; max-height: 62vh; }
  .stage-note { text-align: center; }
  .cards { grid-template-columns: 1fr; }
}
