:root {
  color-scheme: light;
  --ink: #1b3128;
  --muted: #52655a;
  --pine: #164532;
  --pine-dark: #10392a;
  --lime: #d7e99f;
  --paper: #f4f7f1;
  --line: #dce5da;
  --white: #fff;
  --radius: 1rem;
  font-family: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.5; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #276c4c; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { line-height: 1.22; }
h2 { font-size: 1.35rem; letter-spacing: -.025em; }
.shell { width: min(74rem, calc(100% - 3rem)); margin-inline: auto; }
.visually-hidden, .field-name {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner { min-height: 3.85rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-size: 1.18rem; font-weight: 750; text-decoration: none; letter-spacing: -.035em; }
.brand-mark { position: relative; display: block; width: 1.8rem; height: 1.8rem; border-radius: .5rem; background: var(--pine); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: .59rem; height: .38rem; background: var(--lime); border-radius: 75% 0 75% 0; top: .63rem; }
.brand-mark::before { left: .38rem; transform: rotate(65deg); }
.brand-mark::after { left: .86rem; transform: rotate(-15deg); }
.header-link { color: var(--pine); font-size: .95rem; font-weight: 650; text-decoration: none; }
.header-link:hover { text-decoration: underline; text-underline-offset: .2em; }

.hero { overflow: hidden; background: var(--pine-dark); color: var(--white); }
.hero-inner { position: relative; padding-block: 2.65rem 2.9rem; }
.hero h1 { position: relative; z-index: 1; font: 500 clamp(2.35rem, 5.1vw, 4rem)/1.06 Georgia, serif; letter-spacing: -.045em; }
.hero p { position: relative; z-index: 1; max-width: 34rem; margin-top: .9rem; color: #deecdf; font-size: 1.08rem; }
.bed-sketch { position: absolute; inset: 0 -1.5rem 0 auto; width: 21rem; color: #a9cd9c; overflow: hidden; opacity: .47; }
.sketch-outline {
  position: absolute;
  border: 2px solid currentColor;
  border-radius: .5rem;
  transform: rotate(-24deg) skewX(18deg);
}
.sketch-large {
  inset: 2rem 3.25rem auto auto;
  width: 14rem;
  height: 7.5rem;
  background: repeating-linear-gradient(0deg, transparent 0 1.35rem, #a9cd9c55 1.35rem 1.43rem);
  box-shadow: 0 .65rem 0 -.1rem var(--pine-dark), 0 .79rem 0 -.08rem currentColor;
}
.sketch-small {
  inset: 7.15rem -.9rem auto auto;
  width: 8rem;
  height: 3.85rem;
  background: repeating-linear-gradient(0deg, var(--pine-dark) 0 .85rem, #5b826a .85rem .93rem);
  box-shadow: 0 .45rem 0 -.08rem var(--pine-dark), 0 .6rem 0 -.08rem currentColor;
}
.sketch-leaves {
  inset: 3.75rem 8.9rem auto auto;
  width: 1.25rem;
  height: .64rem;
  border: 0;
  border-radius: 75% 0 75% 0;
  background: currentColor;
  box-shadow: 2.5rem 1.5rem 0 currentColor, 5.25rem -1.2rem 0 currentColor, -3.25rem -1rem 0 currentColor;
}

.workbench { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; padding-block: 1.65rem 2.4rem; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: 0 5px 18px #213b2610; padding: 1.5rem; min-width: 0; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; }
.section-head p { margin-top: .35rem; color: var(--muted); font-size: .94rem; }
.mix-head { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.3rem; }
.bed-labels, .material-labels, .bed-row, .material-row { display: grid; align-items: center; gap: .55rem; }
.bed-labels, .bed-row { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(4.2rem, .65fr) 2rem; }
.material-labels, .material-row { grid-template-columns: minmax(0, 1.48fr) minmax(3.6rem, .55fr) minmax(5.25rem, .95fr) 2rem; }
.bed-labels, .material-labels { margin-bottom: .35rem; color: var(--muted); font-size: .89rem; font-weight: 640; }
fieldset { min-width: 0; padding: 0; border: 0; margin: 0 0 .55rem; }
.with-unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.with-unit > * { grid-row: 1; }
.with-unit input { grid-column: 1 / -1; padding-right: 2.1rem; }
.material-row .with-unit input { padding-right: 2.7rem; }
.with-unit > span { grid-column: 2; margin-right: .65rem; font-size: .84rem; color: var(--muted); pointer-events: none; }
input, textarea { width: 100%; color: var(--ink); background: #fbfcfa; border: 1px solid #becdc0; border-radius: .53rem; min-height: 2.7rem; padding: .45rem .65rem; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
input[aria-invalid="true"] { border-color: #ac382b; }
.remove-button, .secondary, .primary, .text-button { font-weight: 680; border-radius: .53rem; line-height: 1.25; }
.remove-button { padding: 0; min-height: 2.7rem; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 1.3rem; }
.remove-button:disabled { visibility: hidden; }
.remove-button:hover { background: #f8ece9; color: #943b31; }
.secondary { min-height: 2.55rem; padding: .48rem .75rem; border: 1px solid #c7d7c9; background: var(--white); color: var(--pine); font-size: .9rem; }
.secondary:not(:disabled):hover { background: #eef5eb; }
.secondary:disabled { opacity: .5; }
.add-button span { margin-right: .2rem; }
.text-button { padding: .15rem 0; min-height: 2rem; background: transparent; border: 0; color: var(--pine); text-decoration: underline; text-underline-offset: .2em; font-size: .89rem; flex: 0 0 auto; }
.text-button:hover { color: #38764f; }
.primary { margin-top: 1.2rem; width: 100%; min-height: 2.85rem; border: 1px solid var(--pine); color: var(--white); background: var(--pine); }
.primary:hover { background: var(--pine-dark); }
.form-error { color: #913629; margin-top: .8rem; font-size: .95rem; }

.result-head { align-items: start; }
#result-title { scroll-margin-top: 1rem; }
.copy-button { flex: 0 0 auto; }
.total { background: #eaf2da; border-radius: .75rem; padding: 1rem 1.15rem; color: var(--pine-dark); }
.total > span { font-size: .94rem; font-weight: 680; }
.total div { font-size: 1.1rem; line-height: 1.12; margin: .16rem 0 .2rem; }
.total strong { font-size: clamp(2.1rem, 5vw, 2.85rem); font-weight: 730; letter-spacing: -.06em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.total p { color: #405741; font-size: .94rem; }
.material-results, .breakdown ul { list-style: none; padding: 0; margin: 0; }
.material-results li, .breakdown li { display: flex; justify-content: space-between; gap: 1rem; padding: .82rem 0; border-bottom: 1px solid var(--line); }
.material-results li > div, .breakdown li > div { min-width: 0; }
.material-results h3, .breakdown h3 { font-size: .98rem; overflow-wrap: anywhere; }
.material-results p, .breakdown p { margin-top: .18rem; font-size: .88rem; color: var(--muted); }
.material-results strong, .breakdown strong { align-self: start; text-align: right; color: var(--pine); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.material-results strong span { display: block; color: var(--muted); font-size: .85rem; font-weight: 500; }
.rounding-note { color: var(--muted); font-size: .9rem; padding-top: .8rem; }
.breakdown { margin-top: .85rem; border-top: 1px solid var(--line); }
.breakdown summary { cursor: pointer; padding: .7rem 0 .2rem; font-weight: 680; font-size: .94rem; }
.breakdown li:last-child { border-bottom: 0; padding-bottom: 0; }
.breakdown strong { font-size: .9rem; }
#result-empty, .copy-status, #copy-fallback label { font-size: .93rem; color: var(--muted); }
.copy-status, #copy-fallback { margin-top: .85rem; }
#copy-text { margin-top: .3rem; resize: vertical; }

.guide { padding-block: 1.55rem 2.5rem; border-top: 1px solid var(--line); }
.guide-grid { margin-top: 1rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6rem; }
.guide-grid h3 { font-size: 1.03rem; }
.guide-grid p { margin-top: .4rem; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); padding-block: 1.1rem; color: var(--pine); font-weight: 680; }
.site-footer .shell { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1rem; }
.site-footer span { color: var(--muted); font-size: .9rem; font-weight: 400; }

@media (max-width: 61rem) {
  .workbench { gap: 1rem; }
  .card { padding: 1.2rem; }
  .config > .section-head { flex-wrap: wrap; }
  .bed-sketch { width: 16rem; opacity: .29; }
}

@media (max-width: 49rem) {
  .shell { width: min(36rem, calc(100% - 2rem)); }
  .hero-inner { padding-block: 1.9rem 2rem; }
  .bed-sketch { display: none; }
  .workbench { grid-template-columns: minmax(0, 1fr); padding-top: 1rem; }
  .guide-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
}

@media (max-width: 28rem) {
  .shell { width: calc(100% - 1.35rem); }
  .card { padding: 1rem; }
  .bed-labels, .material-labels { display: none; }
  .bed-row, .material-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.5rem; align-items: end; gap: .6rem; margin-bottom: .75rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
  .material-row label:first-of-type { grid-column: 1 / 3; }
  .bed-row label:nth-of-type(3), .material-row label:nth-of-type(2) { grid-column: 1; }
  .remove-button { grid-column: 3; grid-row: 1; }
  .field-name { position: static; display: block; width: auto; height: auto; margin: 0 0 .2rem; overflow: visible; clip-path: none; font-size: .89rem; font-weight: 640; color: var(--muted); }
}
