/* craft-calc — 「B-Light」：白地の作業台＋原価の層プレビュー。数字は等幅、文字はサンセリフ。 */
:root {
  --bg: #f6f6f3; --grid: #e9ebee; --surface: #fff; --panel: #fbfbfa;
  --text: #1b1f24; --muted: #5b6670; --faint: #8b94a0; --line: #e1e4e8; --line-strong: #c3c9d0;
  --brand: #f2a33c; --brand-ink: #1a1204; --brand-soft: #fdf1de; --brand-line: #f0cf9a;
  --c-mat: #f2a33c; --c-elec: #ef6f6c; --c-dep: #3fb8a5; --c-fail: #5b9bd5; --c-post: #7fb069; --c-pack: #b48ad6; --c-labor: #e47bb0;
  --ok: #2f7d4a; --warn-bg: #fff6d9; --warn-line: #ecd58a; --footer: #1b1f24; --footer-text: #b9c0c8;
  --font: "IBM Plex Sans JP", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 6px; --r-lg: 10px;
  --shadow: 0 1px 2px rgba(27,31,36,.05), 0 6px 20px rgba(27,31,36,.05);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}
a { color: var(--text); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0 0 .8em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 780px; }
.note { color: var(--muted); font-size: .82rem; line-height: 1.6; }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 3px; }

/* ---------- header / footer ---------- */
.site-header { background: rgba(255,255,255,.92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.logo svg { display: block; }
.logo small { font-weight: 500; color: var(--muted); font-size: .78rem; margin-left: 2px; }
.nav { display: flex; gap: 4px; }
.nav a { font-size: .85rem; font-weight: 500; text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a .cnt { font-family: var(--mono); font-size: .78rem; background: var(--text); color: #fff; border-radius: 999px; padding: 0 6px; margin-left: 4px; }
@media (max-width: 600px) { .logo small { display: none; } .nav a { padding: 6px 7px; font-size: .8rem; } .nav a.sec { display: none; } }
.site-footer { background: var(--footer); color: var(--footer-text); margin-top: 56px; padding: 26px 0 30px; font-size: .82rem; }
.site-footer a { color: #fff; margin-right: 14px; text-decoration: none; }
.site-footer nav { margin: 6px 0; }

/* ---------- hero (live thesis) ---------- */
.hero { padding: 26px 0 6px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.hero .eyebrow { font-size: .8rem; color: var(--muted); font-weight: 500; }
.hero .lead { font-size: clamp(1.35rem, 1rem + 1.6vw, 1.9rem); font-weight: 700; letter-spacing: .005em; margin: 4px 0 0; color: var(--text); line-height: 1.3; }
.hero .lead .price { font-family: var(--mono); font-weight: 700; background: linear-gradient(transparent 62%, var(--brand-soft) 62%); padding: 0 .1em; }
.hero p { color: var(--muted); font-size: .92rem; max-width: 720px; margin-top: 8px; }
.hero-art { flex: none; width: 250px; height: auto; }
@media (max-width: 820px) { .hero-art { width: 180px; } }
@media (max-width: 600px) { .hero { padding-top: 18px; flex-direction: column-reverse; align-items: flex-start; gap: 8px; } .hero-art { width: 150px; align-self: flex-end; margin-bottom: -28px; } .hero p { font-size: .86rem; line-height: 1.65; } }
.nw { white-space: nowrap; }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 18px; }
.grid > * { min-width: 0; }
@media (min-width: 960px) { .grid { grid-template-columns: 400px 1fr; align-items: start; } .stage { position: sticky; top: 66px; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 16px 0; }
.card-h h2 { font-size: .95rem; font-weight: 700; }
.card-b { padding: 12px 16px 14px; }

/* ---------- input panel ---------- */
.panel .grp { padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.panel .grp:first-child { border-top: 0; }
.grp-t { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 700; }
.grp-t .note { font-weight: 400; }
.sw { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }
.gi { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: -4px; }
.gi.big { width: 28px; height: 28px; margin-right: 8px; }
.note.empty { display: flex; align-items: center; margin: 6px 0 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; margin-top: 8px; }
.fields.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 420px) { .fields.cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field label { display: block; font-size: .76rem; color: var(--muted); margin-bottom: 3px; }
.wide { grid-column: 1 / -1; }
.in { display: flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 8px 0 0; min-height: 38px; transition: border-color .15s, box-shadow .15s; }
.in:focus-within { border-color: var(--text); box-shadow: 0 0 0 3px rgba(27,31,36,.08); }
.in input, .in select { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; font: inherit; color: var(--text); padding: 8px 6px 8px 10px; outline: none; }
.in input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-size: .95rem; }
.in input[type=text] { font-size: .92rem; }
.in select { font-size: .9rem; padding-right: 4px; cursor: pointer; }
.in .u { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.in.narrow2 input { padding-left: 6px; }
input[type=radio] { accent-color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg label { padding: 6px 12px; font-size: .85rem; font-weight: 500; cursor: pointer; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.seg label:has(input:checked) { background: var(--text); color: #fff; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: -2px; }
.helper { background: var(--bg); border-radius: var(--r); padding: 8px 10px; margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .8rem; color: var(--muted); }
.helper .in { min-height: 32px; width: 84px; }
.helper .in input { padding: 4px 4px 4px 8px; font-size: .88rem; }

/* filament list（1行＝カード：名前＋削除／価格・重量・密度・プリセット） */
.fil-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fil { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 8px 8px; }
.fil-top { display: flex; align-items: center; gap: 6px; }
.fil-top input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; font: inherit; font-size: .9rem; font-weight: 600; padding: 6px 10px; min-height: 34px; }
.fil-top input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(27,31,36,.08); }
.fil-grid { display: grid; grid-template-columns: 1.1fr .9fr .9fr 1.2fr; gap: 6px; margin-top: 6px; }
.fil-grid label > span:first-child { display: block; font-size: .7rem; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.fil-grid .in { min-height: 34px; }
.fil-grid .in input { padding: 6px 4px 6px 8px; font-size: .88rem; }
.fil-grid .in select { padding: 6px 2px 6px 6px; font-size: .82rem; }
.tbl-wrap { overflow-x: auto; }

/* buttons */
button, .btn { font: inherit; font-size: .88rem; font-weight: 600; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line-strong); background: #fff; color: var(--text); cursor: pointer; line-height: 1.3; min-height: 36px; transition: background .15s, border-color .15s; }
button:hover, .btn:hover { border-color: var(--text); background: var(--panel); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.btn-primary:hover { background: #e7952c; border-color: #e7952c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg); border-color: transparent; }
.btn-sm { padding: 4px 9px; font-size: .8rem; min-height: 28px; }
.btn-icon { padding: 4px 8px; min-height: 30px; line-height: 1; }
button:disabled { opacity: .4; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.msg { font-size: .82rem; color: var(--ok); min-height: 1.3em; margin-top: 6px; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; gap: 14px; }
.layers .bar { display: flex; height: 26px; border-radius: 4px; overflow: hidden; gap: 2px; margin-top: 10px; background: var(--bg); }
.layers .bar > span { display: block; min-width: 0; transition: flex-grow .35s ease; }
.layers .bar > span[data-zero] { display: none; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; margin-top: 12px; }
.legend .it { font-size: .82rem; }
.legend .it .k { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.legend .it .k .n { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend .it .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.legend .it .f { font-size: .72rem; color: var(--faint); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .9rem; }
.total-line .v { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.share { font-size: .75rem; color: var(--muted); font-family: var(--mono); }

.two { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .two { grid-template-columns: 1fr 1fr; } }
.price .big { font-family: var(--mono); font-size: clamp(2.2rem, 1.5rem + 2.5vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.05; margin: 4px 0 10px; }
.price .big small { font-family: var(--font); font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px dashed var(--line); font-size: .88rem; }
.row .k { color: var(--muted); }
.row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row.em .v { font-weight: 700; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--r); padding: 8px 10px; font-size: .82rem; margin-top: 10px; }

table.cmp { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.cmp th { font-size: .72rem; color: var(--muted); font-weight: 500; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.cmp td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
table.cmp th.num, table.cmp td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.cmp tr.cur td { background: var(--brand-soft); font-weight: 600; }
table.cmp tr:last-child td { border-bottom: 0; }

table.recipes { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.recipes th { font-size: .72rem; color: var(--muted); font-weight: 500; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.recipes td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.recipes td.num, table.recipes th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.recipes tr:last-child td { border-bottom: 0; }
table.recipes tr.cur td { background: var(--brand-soft); }

.pro-msg { display: none; margin-top: 8px; }
.pro-msg.show { display: block; }

/* ---------- mobile sticky result ---------- */
.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--text); color: #fff; display: none; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); font-size: .8rem; }
.sticky-bar .v { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; }
.sticky-bar a { color: #fff; font-weight: 600; text-decoration: none; border: 1px solid rgba(255,255,255,.4); border-radius: var(--r); padding: 6px 10px; white-space: nowrap; }
@media (max-width: 959px) { .sticky-bar { display: flex; } body { padding-bottom: 64px; } }

/* ---------- how it works ---------- */
.how { margin-top: 32px; }
.how h2 { font-size: 1rem; margin-bottom: 8px; }
.how ul { padding-left: 1.2em; margin: 0; }
.how li { margin: 4px 0; }

/* ---------- legal pages ---------- */
.page { padding: 28px 0; }
.page h1 { font-size: 1.5rem; margin-bottom: 4px; }
.page .meta { color: var(--muted); font-size: .85rem; margin-bottom: 20px; }
.legal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 24px 22px; box-shadow: var(--shadow); }
.legal h2 { font-size: 1.02rem; margin-top: 1.6em; padding-left: 10px; border-left: 3px solid var(--brand); }
.legal ul { padding-left: 1.3em; }
