:root {
  color-scheme: light;
  --ink: #192a25;
  --muted: #53645d;
  --green: #214c3e;
  --green-dark: #16372d;
  --mint: #d9ebe1;
  --cream: #f8f6ef;
  --paper: #fffefa;
  --line: #d7ddd5;
  --gold: #b78335;
  --error: #9c2f25;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  line-height: 1.55;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem max(1.1rem, calc((100% - 1180px) / 2));
  color: #fff;
  background: var(--green-dark);
}

.brand { color: #fff; font-weight: 750; text-decoration: none; letter-spacing: .01em; }
.header-note { color: #d5e7dc; font-size: .9rem; }

main, footer { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }
.intro { max-width: 810px; padding: 3.1rem 0 1.6rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--green); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; }
h1 { max-width: 730px; margin: 0 0 .8rem; font-size: clamp(2.1rem, 5vw, 3.7rem); letter-spacing: -.045em; }
h2 { margin: 0 0 1rem; font-size: 1.55rem; letter-spacing: -.02em; }
h3 { margin: 0; font-size: 1.2rem; }
h4 { margin: 1.25rem 0 .35rem; font-size: .96rem; }
.intro > p:not(.eyebrow) { max-width: 760px; color: var(--muted); font-size: 1.08rem; }
.unit-note { margin-top: 1.2rem; padding: .85rem 1rem; border-left: 4px solid var(--gold); background: #fff9e9; font-size: .96rem !important; }
code { padding: .08rem .28rem; border-radius: 4px; background: #eeeade; color: var(--ink); }

.planner-grid { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); align-items: start; gap: 1.2rem; }
.input-card, .result-card, .method-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(25 42 37 / 5%);
}
.input-card { position: sticky; top: 1rem; padding: 1.35rem; }
#planner-form { display: grid; gap: .95rem; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
label { display: grid; gap: .3rem; color: var(--ink); font-size: .92rem; font-weight: 700; }
label span { color: var(--muted); font-size: .8rem; font-weight: 500; }
input {
  width: 100%;
  min-height: 46px;
  padding: .65rem .72rem;
  border: 1px solid #aebbb1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #cc9b42; outline-offset: 2px; }
label small { color: var(--muted); font-size: .78rem; font-weight: 400; line-height: 1.4; }
button { min-height: 46px; padding: .7rem 1rem; border: 0; border-radius: 9px; background: var(--green); color: white; cursor: pointer; font: inherit; font-weight: 750; }
button:hover:not(:disabled) { background: var(--green-dark); }
button:disabled { cursor: not-allowed; opacity: .48; }
.secondary-button { min-height: 40px; padding: .5rem .85rem; border: 1px solid var(--green); background: transparent; color: var(--green); }
.secondary-button:hover:not(:disabled) { background: var(--mint); color: var(--green-dark); }
.error { margin: 0; color: var(--error); font-weight: 700; }

.result-card { min-width: 0; padding: 1.5rem; }
.result-heading, .plan-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.result-heading h2 { margin: 0; }
.target-summary { margin: .8rem 0 1.1rem; color: var(--muted); font-weight: 650; }
.plans { display: grid; gap: 1rem; }
.plan { min-width: 0; padding: 1.15rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.economy-plan { border-color: #9ebda9; background: #f7fcf8; }
.plan-title { align-items: flex-start; }
.badge { flex: 0 0 auto; padding: .24rem .55rem; border-radius: 99px; background: var(--mint); color: var(--green-dark); font-size: .75rem; font-weight: 750; }
.purchase-line { margin: .85rem 0 .15rem; font-size: 1.04rem; }
.purchase-line strong { color: var(--green-dark); font-size: 1.22rem; }
.small-line, .diagram-caption { margin: .2rem 0 0; color: var(--muted); font-size: .86rem; }
.cut-list { display: grid; gap: .3rem; margin: 0; padding-left: 1.2rem; }
.cut-list li { padding-left: .1rem; }
.schematic-wrap { margin-top: 1rem; }
.cutting-comparison { margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.cutting-comparison h3 { margin: 0; }
.bolt-figure { margin: 1rem 0; }
.bolt-figure h4 { margin: 0 0 .45rem; }
.bolt-figure figcaption { margin-top: .45rem; font-size: .86rem; color: var(--muted); }
.bolt-diagram { display: block; width: 100%; height: auto; }
.cut-piece, .cut-offcut { stroke: #183b30; stroke-width: 1; vector-effect: non-scaling-stroke; }
.assembly-diagram { display: block; width: 100%; height: auto; max-height: 520px; margin: .45rem 0; }
.join-line { fill: none; stroke: #183b30; stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.outer-line { fill: none; stroke: #183b30; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.diagram-legend { display: grid; gap: .25rem; margin: .45rem 0 0; padding: 0; list-style: none; font-size: .84rem; }
.diagram-legend li { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); gap: .45rem; align-items: start; }
.diagram-legend strong { display: inline-grid; width: 1.35rem; height: 1.35rem; place-items: center; border: 1px solid #596960; border-radius: 3px; background: var(--mint); color: var(--green-dark); }
.unavailable-plan { border-style: dashed; background: #fbfaf5; }
.unavailable-plan p:last-child { margin-bottom: 0; color: var(--muted); }

.method-section { margin: 1.2rem 0 2rem; padding: 1.5rem; }
.method-section p { max-width: 850px; color: var(--muted); }
.limits-note { margin-top: 1.25rem; padding: 1rem 1.1rem; border-left: 4px solid var(--gold); background: #fff9e9; }
.limits-note h3 { font-size: 1rem; }
.limits-note p { margin-bottom: 0; }
footer { padding: 0 0 2rem; color: var(--muted); font-size: .84rem; }

@media (max-width: 850px) {
  .planner-grid { grid-template-columns: minmax(0, 1fr); }
  .input-card { position: static; }
  .intro { padding-top: 2.2rem; }
}

@media (max-width: 520px) {
  main, footer { width: min(100% - 1.1rem, 1180px); }
  .site-header { padding-inline: .65rem; }
  .header-note { font-size: .75rem; }
  .intro { padding-top: 1.7rem; }
  .input-card, .result-card, .method-section { padding: 1rem; border-radius: 12px; }
  .result-heading { align-items: flex-start; }
  .result-heading h2 { font-size: 1.3rem; }
  .result-heading .secondary-button { padding-inline: .65rem; font-size: .85rem; }
  .plan { padding: .85rem; }
}

@media print {
  .cutting-comparison { break-inside: avoid; padding: .6rem; }
  .bolt-diagram { width: 70%; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  :root { background: white; color: black; }
  body { min-width: 0; background: white; }
  .site-header, .input-card, .method-section, footer, .print-button, #print-button { display: none !important; }
  main { width: 100%; margin: 0; }
  .intro { padding: 0 0 .5rem; }
  .intro p:not(.eyebrow) { display: none; }
  h1 { margin-bottom: .5rem; font-size: 1.5rem; }
  .planner-grid { display: block; }
  .result-card { padding: 0; border: 0; box-shadow: none; }
  .result-heading { margin-bottom: .4rem; }
  .target-summary { margin: .25rem 0 .7rem; }
  .plans { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .plan { padding: .7rem; border-color: #777; box-shadow: none; break-inside: avoid; }
  .assembly-diagram { max-height: 300px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
