/* 収納づくり設計：やさしく、わかりやすい見た目（文字は16px以上） */
:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #6e675d;
  --line: #e6dfd2;
  --soft: #faf7f1;
  --accent: #3d7a5c;
  --accent-dark: #2e6148;
  --accent-soft: #e7f2ec;
  --ok: #2e7d4f;
  --ok-bg: #e8f4ec;
  --ng: #b83a2c;
  --ng-bg: #fdecea;
  --warn-bg: #fff6e0;
  --warn-line: #e7c46a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.06), 0 4px 14px rgba(60, 45, 20, 0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

.site-header, main, .site-footer { max-width: 780px; margin: 0 auto; padding: 0 16px; }

/* ---- ヘッダー ---- */
.site-header { padding-top: 28px; padding-bottom: 8px; }
.brand { display: flex; gap: 14px; align-items: flex-start; }
.brand-mark {
  flex: none; width: 44px; height: 44px; margin-top: 2px; border-radius: 12px;
  background:
    linear-gradient(var(--card), var(--card)) 9px 9px / 26px 7px no-repeat,
    linear-gradient(var(--card), var(--card)) 9px 19px / 26px 7px no-repeat,
    linear-gradient(var(--card), var(--card)) 9px 29px / 26px 7px no-repeat,
    var(--accent);
}
h1 { font-size: 26px; line-height: 1.3; margin: 0; letter-spacing: 0.02em; }
.lead { color: var(--muted); margin: 6px 0 12px; }

h2 { font-size: 20px; line-height: 1.4; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 .num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 16px;
}
h3 { font-size: 17px; margin: 0 0 6px; }

/* ---- カード ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.hint { color: var(--muted); margin: 4px 0 10px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border-radius: 10px;
  border: 1.5px solid var(--accent); background: var(--accent); color: #fff;
  font: inherit; font-weight: bold; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { background: var(--card); color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { min-height: 40px; padding: 6px 14px; }
.btn.armed { background: var(--ng-bg); border-color: var(--ng); color: var(--ng); }
.btn:focus-visible, .btn:focus-within, .pick:focus-visible, .jump a:focus-visible, .linkish:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(61, 122, 92, 0.4); outline-offset: 2px;
}
.linkish { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 8px 0; min-height: 44px; }

/* ---- 家具を選ぶ ---- */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pick {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  font: inherit; color: inherit; cursor: pointer; min-height: 84px;
}
.pick:hover:not(:disabled) { border-color: var(--accent); }
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
.pick-check {
  flex: none; width: 28px; height: 28px; margin-top: 2px; border-radius: 8px;
  border: 2px solid #b9b0a2; background: var(--card); position: relative;
}
.pick.on .pick-check { background: var(--accent); border-color: var(--accent); }
.pick.on .pick-check::after {
  content: ""; position: absolute; left: 8px; top: 3px; width: 7px; height: 13px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.pick-body { display: flex; flex-direction: column; gap: 2px; }
.pick-name { font-weight: bold; font-size: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-desc { color: var(--muted); }
.pick.soon { cursor: not-allowed; background: var(--soft); }
.pick.soon .pick-name, .pick.soon .pick-desc { color: #8f877b; }
.pick.soon .pick-check { border-style: dashed; }
.soon-badge { font-size: 16px; font-weight: bold; color: #7a5b16; background: #f5e7c3; border-radius: 999px; padding: 0 10px; }
.chosen { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin: 4px 0 0; }
.chosen .linkish { padding: 4px 0; min-height: 44px; }

/* ---- 移動ボタン（上にくっつく） ---- */
.jump {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 2px; margin: 0 -2px 10px;
  background: var(--bg);
  scrollbar-width: none;
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: none; padding: 6px 14px; min-height: 40px; display: inline-flex; align-items: center;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.jump a:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 入力 ---- */
fieldset { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
legend { font-weight: bold; font-size: 17px; padding: 0; margin-bottom: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; justify-content: flex-end; }
.iw { position: relative; display: block; margin-top: 4px; }
.iw input {
  font: inherit; font-size: 19px; font-variant-numeric: tabular-nums;
  width: 100%; padding: 10px 12px; border: 1.5px solid #d6cdbd; border-radius: 10px; background: #fff; color: var(--text);
}
.iw[data-unit] input { padding-right: 46px; }
.iw[data-unit]::after {
  content: attr(data-unit); position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.iw select {
  font: inherit; font-size: 18px; width: 100%; padding: 10px 36px 10px 12px; border: 1.5px solid #d6cdbd; border-radius: 10px;
  background: #fff; color: var(--text); -webkit-appearance: none; appearance: none; min-height: 50px;
}
.iw.sel::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none;
}
.iw select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61, 122, 92, 0.18); }
.field.bad .iw select { border-color: var(--ng); background: var(--ng-bg); }
.iw input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61, 122, 92, 0.18); }
.field.bad .iw input { border-color: var(--ng); background: var(--ng-bg); }
.field .err { color: var(--ng); }
.field .auto-note { color: var(--muted); }
.field .auto-note:empty { display: none; }
.field .err:empty { display: none; }

.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.iw input:disabled { background: #f1efea; color: #aaa; }
/* 入力欄の説明の図（丸数字で入力欄と対応） */
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 8px 0 14px; }
.guides.one { grid-template-columns: minmax(0, 520px); }
.guide { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.guide figcaption { font-weight: bold; margin-bottom: 4px; }
.cap-note { font-weight: normal; color: var(--muted); }
.guide-svg { display: block; width: 100%; height: auto; }
.g-side { fill: #f8f2e6; stroke: #cdbd9f; }
.g-wood { fill: #e2cfae; stroke: #6b5232; stroke-width: 1; }
.g-back { fill: #d9d0bf; }
.g-front { fill: #c9b48c; stroke: #6b5232; stroke-width: 1; }
.g-box { fill: #d7ecdf; stroke: #2e6b4c; stroke-width: 1.2; }
.g-boxbot { fill: #6fae8a; }
.g-boxwall { fill: #8fc4a6; stroke: #2e6b4c; stroke-width: 1; }
.g-mae { fill: #e2cfae; stroke: #6b5232; stroke-width: 1; }
.g-rail { fill: #2f2f2f; }
.g-railbar { fill: #555; }
.g-floor { stroke: #8a8378; stroke-width: 1.5; }
.g-dim { stroke: #b8452f; stroke-width: 2; }
.g-guide { stroke: #b8452f; stroke-width: 1; stroke-dasharray: 3 3; }
.g-label { font-size: 17px; fill: #4a443b; }
.g-small { font-size: 15px; fill: #fff; }
.pin circle { fill: #b8452f; stroke: #fff; stroke-width: 2; }
.pin text { fill: #fff; font-size: 16px; font-weight: bold; text-anchor: middle; dominant-baseline: central; }
.pin-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 24px; height: 24px; padding: 0 5px; margin-right: 6px; border-radius: 12px;
  background: #b8452f; color: #fff; font-weight: bold; font-size: 16px; line-height: 1; vertical-align: 1px;
}
.flabel { display: block; }
.guide-notes { list-style: none; margin: 12px 0 0; padding: 0; }
.guide-notes li { margin-bottom: 6px; color: var(--muted); }
.guide-notes .pin-badge { margin-right: 4px; }
details.more { border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; margin: 0 0 18px; background: var(--soft); }
details.more > summary {
  cursor: pointer; list-style: none; padding: 12px 0; font-weight: bold; color: var(--accent);
  display: flex; align-items: center; gap: 10px; min-height: 48px;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: ""; flex: none; width: 10px; height: 10px; border: solid var(--accent); border-width: 0 2.5px 2.5px 0;
  transform: rotate(-45deg); transition: transform 0.15s;
}
details.more[open] > summary::before { transform: rotate(45deg); }
details.more[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }

/* ---- お知らせ ---- */
.alert { border-color: var(--ng); background: var(--ng-bg); }
.alert h2 { color: var(--ng); }
.notice { border-color: var(--warn-line); background: var(--warn-bg); }
.alert ul, .notice ul { margin: 0; padding-left: 22px; }
.status-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 18px; flex-wrap: wrap; }
.status-row .status { flex: 1 1 260px; margin-bottom: 0; }
.status-row .btn { flex: 0 0 auto; }
.pdf-help { border-color: var(--accent); }
.pdf-steps { margin: 0 0 14px; padding-left: 22px; }
.pdf-steps li { margin-bottom: 8px; }
.status {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; border: 1.5px solid;
}
.status.ok { background: var(--ok-bg); border-color: #b8dcc6; }
.status.ng { background: var(--ng-bg); border-color: #efb8b0; color: var(--ng); }
.status-mark { font-weight: bold; font-size: 20px; line-height: 1.4; }
.status.ok .status-mark, .status.ok strong { color: var(--ok); }

/* ---- 計算のもと ---- */
.basis { margin: 0; padding-left: 26px; }
.basis li { margin-bottom: 10px; }
.b-label { display: block; font-weight: bold; }
.b-expr strong { color: var(--accent); font-size: 18px; }
.b-note { display: block; color: var(--muted); }
.group-title { font-size: 17px; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.group-title:first-child { margin-top: 4px; }

/* ---- 板の寸法一覧（表） ---- */
.table-wrap { margin: 0 -4px; }
.parts-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 16px; }
.parts-table .c-num { width: 54px; }
.parts-table .c-qty { width: 58px; }
.parts-table th, .parts-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.parts-table thead th { color: var(--muted); font-weight: normal; border-bottom: 2px solid var(--line); }
.parts-table thead th:not(:first-child) { text-align: right; }
.parts-table .num { text-align: right; font-weight: bold; font-variant-numeric: tabular-nums; }
.parts-table .qty { color: var(--accent); white-space: nowrap; }
.parts-table th.p-name { font-weight: bold; }
.parts-table .p-row th, .parts-table .p-row td { border-bottom: 0; padding-bottom: 0; }
.parts-table .p-why { color: var(--muted); line-height: 1.5; padding-top: 2px; word-break: break-word; }
.group-row th { background: var(--soft); font-weight: bold; padding: 6px 8px; }
.parts-table tfoot th { font-weight: bold; text-align: right; }
.parts-table tfoot th, .parts-table tfoot td { border-bottom: 0; border-top: 2px solid var(--line); }
.parts-table tfoot tr + tr th, .parts-table tfoot tr + tr td { border-top: 0; }
/* スマホの縦画面：名前を1行目、数字を2行目にして、名前が細切れにならないようにする */
@media (max-width: 560px) {
  .parts-table, .parts-table thead, .parts-table tbody, .parts-table tfoot { display: block; }
  .parts-table tr { display: grid; grid-template-columns: 1fr 50px 50px 44px 52px; }
  .parts-table colgroup { display: none; }
  .parts-table thead th:first-child { visibility: hidden; }
  .parts-table .p-row th.p-name { grid-column: 1 / -1; padding-bottom: 0; }
  .parts-table .p-row td:nth-child(2) { grid-column: 2; }
  .parts-table .group-row th, .parts-table .why-row td { grid-column: 1 / -1; }
  .parts-table tfoot th { grid-column: 1 / 5; }
}

/* ---- 検算 ---- */
.badge { font-size: 16px; font-weight: bold; padding: 2px 12px; border-radius: 999px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.ng { background: var(--ng-bg); color: var(--ng); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; }
.mark { font-weight: bold; font-size: 20px; width: 24px; flex: none; line-height: 1.5; }
.checks .ok .mark { color: var(--ok); }
.checks .ng { background: var(--ng-bg); }
.checks .ng .mark, .checks .ng .c-title { color: var(--ng); }
.c-title { font-weight: bold; }
.c-detail { color: var(--muted); word-break: break-word; }

/* ---- 展開図と切る順番 ---- */
.kerf { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px; padding: 12px 14px; margin: 8px 0 16px; }
.kerf p { margin: 0 0 6px; }
.kerf ol { margin: 0; padding-left: 22px; }
.kerf li { margin-bottom: 6px; }
.cut-list, .steps { list-style: none; margin: 0; padding: 0; }
.cut-item, .step { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--card); }
.cut-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cut-no { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 10px; font-weight: bold; white-space: nowrap; }
.cut-title { font-weight: bold; font-size: 18px; flex: 1; min-width: 0; }
.part-qty { font-weight: bold; color: var(--accent); font-size: 18px; white-space: nowrap; }
.cut-size { margin: 4px 0 0; color: var(--muted); }
.cut-tip { margin: 0; color: var(--muted); }
.cut-fig { margin: 4px 0; }
.board-svg { display: block; max-width: 520px; height: auto; }
.board { fill: #f3e6cf; stroke: #8a6a3b; stroke-width: 1.5; }
.board.thin { fill: #ece7dc; stroke-dasharray: 4 3; }
.dim-line { stroke: #555; stroke-width: 1; }
.dim-text { font-size: 19px; font-weight: bold; fill: #2b2b2b; }
.edge-text { font-size: 17px; fill: #8a8378; }

/* ---- 完成図・組み立て方の図 ---- */
.complete svg { display: block; max-width: 560px; height: auto; margin: 0 auto; }
.complete polygon, .step-fig polygon { stroke: #6b5232; stroke-width: 0.8; stroke-linejoin: round; }
.wood .f-front { fill: #f3e6cf; }
.wood .f-top { fill: #faf2e3; }
.wood .f-side { fill: #e2cfae; }
.backp .f-front { fill: #e9e2d4; }
.backp .f-top { fill: #f1ebdf; }
.backp .f-side { fill: #d9d0bf; }
.plinth .f-front { fill: #2f2f2f; }
.plinth .f-top { fill: #555; }
.plinth .f-side { fill: #1f1f1f; }
.plinth polygon { stroke: #111; }
.frontp .f-front { fill: #ead7b3; }
.frontp .f-top { fill: #f4e7cd; }
.frontp .f-side { fill: #d6bf96; }
.boxp .f-front { fill: #f6eddc; }
.boxp .f-top { fill: #fbf5ea; }
.boxp .f-side { fill: #e8dcc4; }
.complete .handle, .step-fig .handle { fill: #5f5e5a; stroke: #3d3d3a; }
.new .f-front { fill: #8fc4a6 !important; }
.new .f-top { fill: #b7dcc6 !important; }
.new .f-side { fill: #6fae8a !important; }
.new polygon { stroke: #2e6b4c !important; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 14px; border: 1px solid #6b5232; border-radius: 3px; flex: none; }
.sw.wood { background: #f3e6cf; }
.sw.backp { background: #e9e2d4; }
.sw.plinth { background: #2f2f2f; }
.sw.frontp { background: #ead7b3; }
.step-fig svg { display: block; max-width: 440px; height: auto; margin: 8px auto; }
.step-texts { margin: 0; padding-left: 20px; }
.step-texts li { margin-bottom: 4px; }
.step-texts .check-tx { font-weight: bold; color: var(--accent); }

/* ---- 板の記号（A・B・C…） ---- */
.letter {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 26px; height: 26px; padding: 0 6px; margin-right: 6px; border-radius: 999px;
  background: #3d3a35; color: #fff; font-weight: bold; font-size: 16px; line-height: 1; vertical-align: 2px;
}
.letter.big { min-width: 30px; height: 30px; font-size: 17px; }
.letter.inline { min-width: 24px; height: 24px; font-size: 16px; margin: 0 2px; vertical-align: 1px; padding: 0 5px; }
.tag circle { fill: #3d3a35; stroke: #fff; stroke-width: 2; }
.tag text { fill: #fff; font-size: 15px; font-weight: bold; }
.tag rect { fill: #3d3a35; stroke: #fff; stroke-width: 2; }
.hw-title { margin-top: 18px; }
.hardware { list-style: none; margin: 0; padding: 0; }
.hardware li { padding: 8px 0; border-top: 1px solid var(--line); }
.hardware li:first-child { border-top: 0; }
.hw-head { display: flex; justify-content: space-between; gap: 10px; }
.hw-name { font-weight: bold; }
.hw-note { color: var(--muted); }

/* ---- 完成イメージの画像 ---- */
.image-row { display: flex; gap: 10px; flex-wrap: wrap; }
.image-preview { display: block; max-width: 100%; max-height: 420px; margin-top: 12px; border-radius: 12px; border: 1px solid var(--line); }
.image-preview[hidden] { display: none; }
.err-text { color: var(--ng); margin: 8px 0 0; }

.site-footer { padding-bottom: 40px; }

/* ---- 印刷・PDF ---- */
.print-only { display: none; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: bold; }
@media print {
  @page { size: A4; margin: 12mm; }
  html { scroll-behavior: auto; }
  body { background: #fff; font-size: 11pt; }
  .no-print, #stop, #warn[hidden], #picker { display: none !important; }
  .print-only { display: block; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: auto; padding: 10px 12px; margin-bottom: 10px; }
  .site-header, main { max-width: none; padding: 0; }
  .cut-item, .step, .parts-table tr, .checks li, .basis li, .summary { break-inside: avoid; }
  h2 { break-after: avoid; }
  .image-preview { max-height: 70mm; }
  .complete svg { max-width: 120mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* 紙を節約：展開図と組み立て方は2つずつ横に並べる */
  .cut-list, .steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .cut-item, .step { margin-bottom: 0; }
  .board-svg, .step-fig svg { max-width: 100%; }
  /* 合計の行は、ページごとにくり返さず最後に1回だけ */
  .parts-table tfoot { display: table-row-group; }
}
