/*
 * 買うまえ計算室
 * 見た目の考え方: 図面と巻尺。結果の数字を主役にして、寸法線と目盛りは
 * 「数量を示す場所」にだけ使う。黄色は巻尺、赤は注意だけ。
 */
:root {
  --paper: #ffffff;
  --tint: #f1f5fb;
  --grid: #dde6f3;
  --line: #c3cfe2;
  --ink: #14264a;
  --ink-2: #4a5878;
  --blue: #2b4fb5;
  --tape: #ffd21f;
  --red: #c8281e;
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
  --font-num: "DIN Alternate", Bahnschrift, "DIN Condensed", "Roboto Condensed", "Arial Narrow", var(--font-jp);
  --wrap: 1040px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-jp);
  font-size: 1rem;
  line-height: 1.8;
}

a { color: var(--blue); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 10; background: var(--paper); padding: 8px 12px; }
.skip:focus { left: 12px; }

/* ---------- 枠まわり ---------- */

.site-head {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 14px 20px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
}

.brand {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.site-head nav { display: flex; gap: 20px; font-size: 0.9rem; }
.site-head nav a { color: var(--ink); }

/* 巻尺の帯。目盛りは上端から下がる */
.tape {
  height: 22px;
  border-block: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 1.5px, transparent 1.5px 80px) 0 0 / 100% 72% no-repeat,
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 40px) 0 0 / 100% 52% no-repeat,
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 8px) 0 0 / 100% 30% no-repeat,
    var(--tape);
}

.pr-notice {
  margin: 0;
  padding: 6px 20px;
  background: var(--tint);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  text-align: center;
}

main { max-width: var(--wrap); margin: 0 auto; padding: 32px 20px 72px; }

.site-foot { border-top: 2px solid var(--ink); background: var(--tint); }
.site-foot .in { max-width: var(--wrap); margin: 0 auto; padding: 24px 20px 40px; font-size: 0.88rem; }
.site-foot p { margin: 0 0 6px; }
.foot-name { font-weight: 800; letter-spacing: 0.06em; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.foot-links a { color: var(--ink); }
.copy { color: var(--ink-2); }

/* ---------- 文字 ---------- */

h1 {
  margin: 0 0 0.4em;
  font-size: clamp(1.65rem, 1.1rem + 2.6vw, 2.5rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.02em;
  font-feature-settings: "palt";
}

h2 {
  margin: 2.6em 0 0.7em;
  padding-top: 0.9em;
  border-top: 2px solid var(--ink);
  font-size: 1.3rem;
  line-height: 1.4;
  font-feature-settings: "palt";
}

h3 { margin: 1.6em 0 0.3em; font-size: 1.05rem; line-height: 1.5; }

p, ul, ol, table { margin: 0 0 1em; }

.lead { max-width: 36em; margin-bottom: 1.6em; color: var(--ink-2); }

.prose { max-width: 40em; }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: 0.35em; }

.formula {
  padding: 0.7em 1em;
  background: var(--tint);
  border-left: 4px solid var(--ink);
  font-weight: 700;
}

.sources { font-size: 0.93rem; }

/* ---------- 入力 ---------- */

.calc { display: grid; gap: 22px; }

@media (min-width: 880px) {
  .calc { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 32px; align-items: start; }
}

.calc-in { display: grid; gap: 20px; margin: 0; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }

legend, .f-label { display: block; margin-bottom: 6px; padding: 0; font-weight: 700; }

.hint { display: block; margin-top: 4px; color: var(--ink-2); font-size: 0.85rem; font-weight: 400; line-height: 1.5; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; flex: 1 1 auto; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: block;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  line-height: 1.5;
  text-align: center;
}
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--paper); }
.stepper button {
  width: 50px;
  min-height: 48px;
  border: 0;
  background: var(--tint);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.stepper button:first-child { border-right: 1.5px solid var(--ink); }
.stepper button:last-child { border-left: 1.5px solid var(--ink); }
.stepper button:focus-visible { outline-offset: -3px; }
.stepper input {
  width: 3.4em;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 700 1.35rem var(--font-num);
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.stepper .unit { display: flex; align-items: center; padding: 0 14px 0 4px; }

.field { display: inline-flex; align-items: center; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper); }
.field:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.field input {
  width: 5.6em;
  min-height: 46px;
  padding: 8px 4px 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 700 1.2rem var(--font-num);
  text-align: right;
}
.field input:focus-visible { outline: 0; }
.field input::placeholder { color: #9aa6bd; font-weight: 400; }
.field .unit { padding: 0 12px 0 4px; color: var(--ink-2); white-space: nowrap; }

.fields { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.fields label { display: grid; gap: 2px; font-size: 0.9rem; }

.route { display: grid; gap: 14px; }
.route-row { display: grid; gap: 4px; }
.route-row .row-name { font-size: 0.95rem; font-weight: 700; }

[hidden] { display: none !important; }

/* ---------- 結果（方眼紙） ---------- */

.calc-out { min-width: 0; }

.sheet {
  padding: 18px 18px 16px;
  border: 2px solid var(--ink);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 -1px / 100% 18px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) -1px 0 / 18px 100%,
    var(--paper);
}

.out-pre, .out-post { margin: 0; font-weight: 700; }
.out-post { margin-top: 2px; }

.out-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.12em; margin: 2px 0 0; line-height: 1.05; }
.out-main .num { font: 700 clamp(3.1rem, 1.6rem + 8.5vw, 5.4rem) / 1 var(--font-num); letter-spacing: -0.01em; }
.out-main .unit { font-size: 1.5rem; font-weight: 700; }
.out-main .words { font-size: clamp(1.9rem, 1.2rem + 3.6vw, 2.9rem); font-weight: 800; line-height: 1.3; font-feature-settings: "palt"; }

.verdict-ng .words { color: var(--red); }
.verdict-tight .words { background: linear-gradient(transparent 62%, var(--tape) 62%); }

.pair { display: flex; flex-wrap: wrap; gap: 6px 36px; }
.pair > div { min-width: 0; }
.pair .out-main .num { font-size: clamp(2.8rem, 1.5rem + 6.5vw, 4.6rem); }

.draw-wrap { margin-top: 14px; }

svg.draw { display: block; max-width: 100%; height: auto; overflow: visible; }
svg.draw .ink { fill: none; stroke: var(--ink); stroke-width: 1.5; }
svg.draw .thin { stroke-width: 1; }
svg.draw .blue { fill: none; stroke: var(--blue); stroke-width: 1.25; }
svg.draw .red { fill: none; stroke: var(--red); stroke-width: 1.5; }
svg.draw .solid { fill: var(--ink); stroke: none; }
svg.draw .body { fill: #fff; stroke: var(--ink); stroke-width: 2; }
svg.draw .body-ng { fill: rgba(200, 40, 30, 0.14); stroke: var(--red); stroke-width: 2; }
svg.draw .wall { fill: url(#hatch); stroke: var(--ink); stroke-width: 1.5; }
svg.draw .tapefill { fill: var(--tape); stroke: var(--ink); stroke-width: 1.5; }
svg.draw .band { fill: rgba(20, 38, 74, 0.16); stroke: var(--ink); stroke-width: 2.5; }
svg.draw text { fill: var(--ink); font: 13px var(--font-num); }
svg.draw text.jp { font-family: var(--font-jp); font-size: 12.5px; }
svg.draw text.dimtext { font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
svg.draw text.bluetext { fill: var(--blue); }
svg.draw text.redtext { fill: var(--red); }

.out-notes { margin: 14px 0 0; padding-left: 1.2em; font-size: 0.93rem; }
.out-notes li { margin-bottom: 0.3em; }
.out-notes .warn { color: var(--red); font-weight: 700; }

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: baseline; }
thead th { border-bottom: 2px solid var(--ink); font-size: 0.85rem; line-height: 1.5; }
td.n, th.n { font-family: var(--font-num); font-size: 1.05rem; text-align: right; white-space: nowrap; }
thead th.n { font-family: var(--font-jp); font-size: 0.85rem; white-space: normal; }

.sheet table { margin: 12px 0 0; background: rgba(255, 255, 255, 0.86); }
.sheet td.n { font-size: 1.25rem; font-weight: 700; }

/* ---------- トップページ ---------- */

.hero h1 { margin-bottom: 0.2em; font-size: clamp(2.2rem, 1.2rem + 4.8vw, 3.7rem); letter-spacing: 0.05em; }
.hero-lead { max-width: 28em; margin-bottom: 1.6em; font-size: 1.08rem; }

.quick { display: grid; gap: 18px; }
@media (min-width: 880px) {
  .quick { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 32px; align-items: start; }
}
.quick .seg label { flex: 1 1 56px; }

.quick-rows { margin: 0; }
.quick-rows > div { display: grid; grid-template-columns: 5.2em minmax(0, 1fr); align-items: baseline; gap: 0 12px; padding: 6px 0; }
.quick-rows > div + div { border-top: 1.5px dashed var(--line); }
.quick-rows dt { font-weight: 700; }
.quick-rows dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; }
.quick-rows .num { font: 700 clamp(2.1rem, 1.3rem + 4vw, 3.2rem) / 1.1 var(--font-num); }
.quick-rows .unit { font-weight: 700; }
.quick-rows a { font-size: 0.9rem; }
.quick-note { margin: 10px 0 0; color: var(--ink-2); font-size: 0.85rem; }

.tool-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.tool-list li { border-bottom: 1px solid var(--line); }
.tool-list a { display: grid; gap: 2px 28px; padding: 16px 4px; color: var(--ink); text-decoration: none; }
@media (min-width: 720px) {
  .tool-list a { grid-template-columns: 17em minmax(0, 1fr); align-items: baseline; }
}
.tool-list .t-name {
  justify-self: start;
  font-size: 1.12rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: var(--tape);
  text-decoration-thickness: 4px;
  text-underline-offset: 0.3em;
}
.tool-list a:hover .t-name, .tool-list a:focus-visible .t-name { text-decoration-color: var(--ink); }
.tool-list .t-desc { color: var(--ink-2); font-size: 0.95rem; }
.tool-list .t-in { display: block; font-size: 0.85rem; }

h2.plain { border-top: 0; padding-top: 0; }

/* ---------- ほかのツール・広告 ---------- */

.others ul { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; padding: 0; list-style: none; }

.pr-block { max-width: 40em; margin: 28px 0 0; padding: 14px 16px 6px; border: 1.5px dashed var(--ink-2); }
.pr-block p { margin: 0 0 8px; }
.pr-block ul { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 10px; padding: 0; list-style: none; }
.pr-block li a {
  display: inline-block;
  padding: 8px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.pr-block li a:hover { background: var(--tape); }
.pr-tag { display: inline-block; padding: 0 7px; border: 1.5px solid var(--ink); font: 700 0.8rem var(--font-num); letter-spacing: 0.08em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-head nav, .tape, .others, .pr-block, .pr-notice { display: none; }
  .sheet { background: none; }
}
