:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #182f27;
  background: #f0f4ee;
  --muted: #4c6258;
  --border: #c5d1c8;
  --pine: #143b2f;
  --mint: #bcebc8;
  --panel: #fdfefc;
  --gap: 0.65rem;
  --radius: 1rem;
  --room-bar-offset: 4.5rem;
  scroll-padding-block-start: var(--room-bar-offset);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button,
summary {
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid #288459;
  outline-offset: 3px;
}
h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}
h1,
h2,
h3 {
  line-height: 1.16;
  overflow-wrap: anywhere;
}
h2 {
  font-size: 1.36rem;
  letter-spacing: -0.025em;
}
h3 {
  font-size: 1rem;
}

.shell {
  width: min(calc(100% - 2rem), 74rem);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar {
  container-type: inline-size;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
  padding-block: 0.45rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
  font-size: 1.3rem;
  font-weight: 780;
  letter-spacing: -0.035em;
}
.ruler {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.15rem;
  aspect-ratio: 1;
  border-radius: 0.45rem;
  background: #267450;
}
.ruler::before {
  content: "";
  width: 1.5rem;
  height: 0.5rem;
  border: 1px solid #fff;
  border-radius: 0.1rem;
  background: repeating-linear-gradient(90deg, #fff 0 1px, transparent 1px 4px)
    top / 100% 46% no-repeat;
  transform: rotate(-42deg);
}
.room-switcher {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: var(--gap);
}
.room-strip {
  flex: 1;
  display: flex;
  gap: 0.4rem;
  min-width: 0;
  overflow-x: auto;
  padding: 0.25rem;
  scrollbar-width: thin;
}
.room-tools {
  display: flex;
  flex: none;
  gap: 0.35rem;
}
.room-tools .button {
  display: inline-block;
  white-space: nowrap;
}
.room-tools .plus {
  display: inline-block;
  margin-inline-end: 0.4rem;
  vertical-align: -0.13em;
}
.room-strip .room-chip {
  display: block;
  flex: 0 0 auto;
  max-width: min(15rem, 90%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-strip .room-chip[aria-pressed="true"] {
  color: #fff;
  background: var(--pine);
  border-color: var(--pine);
}
.room-chip:focus-visible {
  outline-offset: 1px;
}
@media (max-width: 46rem) {
  .topbar .brand,
  .room-tool-detail {
    display: none;
  }
}
@container (max-width: 12rem) {
  .room-switcher {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .room-strip {
    flex-basis: 100%;
  }
  .room-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
    margin-inline-start: auto;
  }
  .room-tools .button {
    padding-inline: 0.55rem;
  }
}
.intro {
  margin-block: clamp(1.65rem, 4vw, 3.2rem) clamp(1.3rem, 3vw, 2rem);
}
.intro h1 {
  font-size: clamp(2.1rem, 5vw, 3.7rem);
  letter-spacing: -0.055em;
}
.intro p {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
  grid-template-areas:
    "measurements results"
    "openings results"
    "rates results"
    "extras results";
  gap: 1rem 1.25rem;
  align-items: start;
  padding-bottom: 3rem;
}
.measurements {
  grid-area: measurements;
}
.results {
  grid-area: results;
  display: grid;
  gap: 0.85rem;
}
.openings {
  grid-area: openings;
}
.rates {
  grid-area: rates;
}
.extras {
  grid-area: extras;
}
.workspace > *,
.field {
  min-width: 0;
}
.panel {
  padding: clamp(1rem, 2.5vw, 1.55rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.room-name-field {
  margin-block: 1.1rem 0.85rem;
}
.dimension-fields,
.rate-fields {
  display: grid;
  gap: 0.85rem;
}
.dimension-fields {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 6rem), 1fr));
}
.rate-fields {
  container-type: inline-size;
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, max(9rem, 45%)), 1fr)
  );
  margin-top: 0.8rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.35;
}
.field > span:first-child {
  overflow-wrap: anywhere;
}
.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.52rem 0.7rem;
  border: 1px solid #9dae9f;
  border-radius: 0.55rem;
  background: #fff;
  color: #182f27;
  font-size: 1rem;
  font-weight: 550;
}
.field select {
  padding-inline-end: 0.25rem;
}
.field input::placeholder {
  color: #687b71;
  opacity: 1;
}
.field input[aria-invalid] {
  border-color: #ad372c;
}
.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.15rem;
  padding-right: 0.55rem;
  border: 1px solid #9dae9f;
  border-radius: 0.55rem;
  background: #fff;
}
.input-with-unit:focus-within {
  outline: 3px solid #288459;
  outline-offset: 2px;
}
.input-with-unit:has(input[aria-invalid]) {
  border-color: #ad372c;
}
.input-with-unit input,
.input-with-unit input[aria-invalid] {
  border: 0;
  outline: 0;
  padding-inline: 0.55rem 0;
  font-size: 1.13rem;
  font-variant-numeric: tabular-nums;
}
.input-with-unit > span {
  color: var(--muted);
  font-size: 0.73rem;
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}
.section-note,
.save-state {
  font-size: 0.875rem;
  line-height: 1.45;
}
.section-note {
  margin-block: 0.5rem 0.9rem;
}
.save-state {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
}
.save-state::before {
  content: "";
  flex: 0 0 0.45rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #39825a;
}
.storage-error,
.field-error {
  color: #9c2c23;
}
.storage-error::before {
  background: currentColor;
}
.field-error {
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
p.field-error {
  margin-block: 0 0.8rem;
}

.actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  min-height: 2.85rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid #96ad9e;
  border-radius: 0.55rem;
  background: var(--panel);
  color: var(--pine);
  font-size: 0.91rem;
  font-weight: 680;
  text-align: center;
  overflow-wrap: anywhere;
}
.button:hover {
  background: #e8f2e9;
}
.button.primary {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}
.button.primary:hover {
  background: #235a44;
}
.plus {
  display: grid;
  place-items: center;
  width: 0.92rem;
  height: 0.92rem;
  flex: none;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
}
.text-button {
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0.25rem;
  min-height: 2.75rem;
  padding: 0.42rem 0.15rem;
  font-size: 0.9rem;
  font-weight: 680;
  text-align: start;
  text-underline-offset: 0.2em;
  text-decoration: underline;
}
.text-button:hover {
  text-decoration-thickness: 2px;
}

.results-panel {
  container-type: inline-size;
  --plan-line: #9cddb4;
  padding: clamp(1rem, 2.7vw, 1.6rem);
  border-radius: var(--radius);
  background: var(--pine);
  color: #f5fcf7;
}
.results-panel h2 {
  color: #fff;
}
.walls-and-plan {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-height: 10.2rem;
  margin-block: 0.65rem 0.8rem;
}
.wall-label {
  color: #d4ecdf;
  font-weight: 640;
}
.wall-number,
.quote-amount {
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.wall-number {
  margin-top: 0.22rem;
  font-size: clamp(1.9rem, 3.7vw, 3.8rem);
}
.wall-number small,
.quote-amount small {
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}
.deduction {
  margin-top: 0.4rem;
  color: #d4ecdf;
  font-size: 0.8rem;
  line-height: 1.3;
}
.plan {
  display: grid;
  grid-template: auto 1fr / auto 1fr;
  align-items: center;
  align-self: stretch;
  min-width: 0;
  gap: 0.35rem;
  padding: 0.7rem;
  border-radius: 0.4rem;
  background-image:
    linear-gradient(#a6e8bf24 1px, transparent 1px),
    linear-gradient(90deg, #a6e8bf24 1px, transparent 1px);
  background-size: 0.65rem 0.65rem;
  background-position: center;
  color: #daf8e5;
  font-size: 0.7rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.plan-length {
  grid-area: 1 / 2;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--plan-line);
  text-align: center;
}
.plan-width {
  grid-area: 2 / 1;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
}
.plan-outline {
  position: relative;
  display: grid;
  place-items: center;
  grid-area: 2 / 2;
  align-self: stretch;
  min-height: 4.4rem;
  margin-block: 0.1rem 0.35rem;
  border: 3px solid var(--plan-line);
}
.plan-height {
  text-align: center;
}
.plan-window,
.plan-door {
  display: none;
  position: absolute;
}
.plan[data-window] .plan-window {
  display: block;
}
.plan[data-door] .plan-door {
  display: block;
}
.plan-window {
  width: 37%;
  height: 0.4rem;
  top: -0.3rem;
  right: 13%;
  border: 1px solid var(--plan-line);
  background: var(--pine);
}
.plan-door {
  width: 1.9rem;
  max-width: 30%;
  aspect-ratio: 1;
  bottom: -3px;
  left: 11%;
  border: 1px solid var(--plan-line);
  border-bottom: 3px solid var(--pine);
  border-radius: 0 100% 0 0;
}
.measurements-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.9rem;
}
.measurements-list > div {
  min-width: 0;
  padding-top: 0.65rem;
  padding-bottom: 0.45rem;
  border-top: 1px solid #7cb99c7d;
}
.measurements-list dt {
  color: #d4ecdf;
  font-size: 0.87rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.measurements-list dd {
  font-size: clamp(1.08rem, 2.3vw, 1.55rem);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.measurements-list dd small {
  font-size: 0.68em;
  font-weight: 640;
  white-space: nowrap;
}
.quote-panel {
  padding: clamp(1rem, 2.55vw, 1.55rem);
  border-radius: var(--radius);
  background: var(--mint);
  color: #163a2c;
}
.quote-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.45rem var(--gap);
}
.quote-amount {
  font-size: clamp(1.7rem, 4vw, 2.85rem);
  max-width: 100%;
}
.quote-breakdown summary {
  padding-block: 0.85rem 0.3rem;
  font-weight: 660;
  cursor: pointer;
}
.quote-breakdown dl {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.quote-breakdown dl > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.2rem var(--gap);
  border-top: 1px solid #719d82;
  padding-top: 0.45rem;
  font-size: 0.87rem;
  line-height: 1.4;
}
.quote-breakdown dt,
.quote-breakdown dd {
  min-width: 0;
  overflow-wrap: anywhere;
}
.quote-breakdown dd {
  font-variant-numeric: tabular-nums;
  font-weight: 670;
}

.section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  list-style: none;
  font-size: 1.36rem;
  font-weight: 720;
  line-height: 1.16;
  letter-spacing: -0.025em;
  cursor: pointer;
}
.section-summary::-webkit-details-marker {
  display: none;
}
.section-summary::after {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  margin: 0 0.25rem 0.25rem;
  flex: none;
  border-right: 2px solid;
  border-bottom: 2px solid;
  transform: rotate(45deg);
}
.rates[open] > .section-summary::after {
  transform: rotate(225deg);
  margin-bottom: 0;
}
.entries:not(:empty) {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.entry {
  min-width: 0;
  padding: 0.7rem;
  background: #f2f6f0;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
}
.entry-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  margin-bottom: 0.5rem;
}
.icon-button {
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  font-size: 1.4rem;
  flex: none;
}
.extra-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap) 1.2rem;
  border-top: 1px solid var(--border);
  padding-block: 0.7rem;
  font-size: 0.9rem;
}
.extra-summary > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.extra-summary dd,
.extra-total {
  font-weight: 730;
  font-variant-numeric: tabular-nums;
}
.extra-total {
  margin-top: 0.65rem;
  text-align: end;
  overflow-wrap: anywhere;
}

dialog {
  width: min(calc(100% - 1.5rem), 29rem);
  max-height: min(38rem, calc(100% - 1.5rem));
  padding: 1rem;
  color: #182f27;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1rem 3.4rem #10261e40;
  overflow: auto;
}
dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
dialog::backdrop {
  background: #10261e91;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}
.rooms-list {
  display: grid;
  gap: 0.4rem;
  margin: 0 -0.3rem;
  padding: 0.3rem;
  overflow: auto;
  list-style: none;
}
.room-choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  width: 100%;
  min-height: 2.85rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--panel);
  color: var(--pine);
  font-weight: 620;
  text-align: start;
}
.room-choice:hover,
.room-choice[aria-current] {
  border-color: #79a48b;
  background: #e7f5ea;
}
.room-choice span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.room-choice small {
  flex: none;
  font-size: 0.75rem;
}
.danger {
  color: #942e25;
}

@media (max-width: 46rem) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "measurements" "results" "openings" "rates" "extras";
    gap: 0.75rem;
  }
  .walls-and-plan {
    min-height: 7.25rem;
  }
  .wall-number {
    font-size: clamp(1.9rem, 8vw, 3.4rem);
  }
}

@media (max-width: 26rem) {
  .shell {
    width: calc(100% - 1.5rem);
  }
  .dimension-fields {
    gap: 0.45rem;
  }
  .rate-fields {
    gap: 0.6rem;
  }
}

@media (max-width: 21rem) {
  .input-with-unit {
    padding-right: 0.35rem;
  }
  .input-with-unit input {
    padding-left: 0.35rem;
  }
}

.wall-number.long-value {
  font-size: clamp(1.35rem, 2.8vw, 2.25rem);
}
.quote-amount.long-value {
  font-size: clamp(1.35rem, 3vw, 2.25rem);
}
@container (max-width: 27rem) {
  .walls-and-plan:has(.long-value) {
    grid-template-columns: minmax(0, 1fr);
  }
}

.quote-incomplete {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
@container (max-width: 10.5rem) {
  .rate-fields
    .input-with-unit:has(input[data-rate], input[data-field="rate"]) {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .rate-fields
    .input-with-unit:has(input[data-rate], input[data-field="rate"])
    > span {
    padding: 0 0.25rem 0.3rem;
    text-align: end;
  }
}
@media (min-width: 46.01rem) and (min-height: 46rem) {
  .results:not(:has(.quote-breakdown[open])) {
    position: sticky;
    top: calc(var(--room-bar-offset) + 0.75rem);
  }
}

@container (max-width: 9rem) {
  .measurements-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

.measurement-hint {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}
.room-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem var(--gap);
  margin-top: 0.85rem;
}
.form-return {
  display: inline-flex;
  align-items: center;
}
.result-opening-actions {
  margin-top: 0.6rem;
}
.result-opening-actions .button {
  color: #f5fcf7;
  border-color: #80ad96;
  background: transparent;
}
.result-opening-actions .button:hover {
  background: #245542;
}
.result-opening-actions .button:focus-visible {
  outline-color: var(--mint);
}
.rates .form-return {
  margin-top: 0.4rem;
}
.dialog-actions {
  justify-content: space-between;
}
