:root {
  color-scheme: light;
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #66727e;
  --line: #d9dde0;
  --line-strong: #b9c0c6;
  --brand: #274c43;
  --brand-2: #9a6a38;
  --accent: #366da2;
  --success: #2d6a4f;
  --warning: #a15c21;
  --shadow: 0 16px 44px rgba(28, 36, 44, 0.13);
  --radius: 8px;
  --sidebar: 390px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 3vw, 42px);
  background: rgba(246, 244, 239, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  gap: 2px;
}

.brand span,
.eyebrow {
  color: var(--brand-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand strong {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.top-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(39, 76, 67, 0.22);
}

.secondary-button {
  background: #e6edf2;
  color: #17364f;
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar);
  gap: 24px;
  padding: 24px clamp(18px, 3vw, 42px) 42px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.panel,
.estimate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.05);
}

.panel {
  padding: clamp(18px, 2.4vw, 28px);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
  gap: clamp(18px, 3vw, 36px);
  align-items: center;
  border-top: 4px solid var(--brand);
}

.intro-panel h1 {
  margin: 4px 0 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.intro-panel p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.split-heading {
  align-items: flex-end;
}

.section-heading h1,
.section-heading h2 {
  margin: 4px 0 0;
  line-height: 1.08;
}

.section-heading h1 {
  font-size: clamp(1.8rem, 3.4vw, 3.2rem);
}

.section-heading h2 {
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.section-note {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.tier-card {
  position: relative;
  display: grid;
  grid-template-rows: 220px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.tier-card[aria-pressed="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(39, 76, 67, 0.18);
}

.tier-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tier-card-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.tier-card h3,
.product-card h3,
.included-block h3 {
  margin: 0;
  font-size: 1rem;
}

.tier-card p,
.product-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.tier-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tier-pill,
.source-pill,
.estimate-header span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef3f0;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
}

.layout-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.choice-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #eef5fb;
}

.freestanding-addon {
  grid-column: 1 / -1;
}

.freestanding-addon[data-layout-addon="true"] {
  border-color: var(--accent);
  background: #eef5fb;
}

.freestanding-addon input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.choice-button strong {
  display: block;
  margin-bottom: 4px;
}

.choice-button span {
  color: var(--muted);
  font-size: 0.92rem;
}

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.tab-button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}

.item-include-row {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.include-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.include-toggle input,
.prep-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.include-toggle strong,
.include-toggle small {
  display: block;
}

.include-toggle small {
  margin-top: 2px;
  color: var(--muted);
}

.finish-picker {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.finish-picker strong,
.finish-picker small {
  display: block;
}

.finish-picker small {
  margin-top: 2px;
  color: var(--muted);
}

.finish-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.finish-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 850;
  cursor: pointer;
}

.finish-button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.finish-button span {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  background-position: center;
  background-size: cover;
  flex: 0 0 auto;
}

.custom-finish-field {
  display: grid;
  gap: 8px;
  max-width: 420px;
  font-weight: 800;
}

.custom-finish-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 12px;
}

.product-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.product-card[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(54, 109, 162, 0.18);
}

.product-card[data-included="false"] {
  opacity: 0.72;
}

.product-thumb {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #f4f5f3;
}

.product-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 10px;
}

.product-card-header > span {
  min-width: 0;
}

.product-card-header h3,
.product-card-header p {
  overflow-wrap: anywhere;
}

.product-price {
  color: var(--ink);
  font-size: clamp(0.92rem, 1vw, 1.12rem);
  font-weight: 900;
  text-align: right;
  overflow-wrap: anywhere;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

.product-footer > * {
  min-width: 0;
}

.product-footer a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.select-product {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
}

.product-card[data-selected="true"] .select-product {
  background: var(--accent);
}

.source-pill {
  background: #f4ede5;
  color: var(--warning);
  white-space: normal;
}

.measurement-grid,
.contact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.measure-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.measure-card label,
.contact-form label,
.concept-note-field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

.measure-card span,
.contact-form span,
.concept-note-field span {
  font-size: 0.9rem;
}

.measure-card input,
.contact-form input,
.contact-form textarea,
.concept-note-field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.concept-note-field {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.measure-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.photo-uploader {
  display: grid;
  gap: 14px;
}

#bathPhotoUpload {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-box {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 96px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfbfa;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: rgba(39, 76, 67, 0.16);
  touch-action: manipulation;
}

.upload-box span {
  color: var(--ink);
  font-weight: 900;
}

.upload-box small,
.concept-preview p {
  color: var(--muted);
  line-height: 1.45;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.photo-thumb {
  display: grid;
  gap: 8px;
  margin: 0;
}

.photo-thumb img,
.concept-preview img,
.proposal-concept img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  object-fit: cover;
}

.photo-thumb img {
  aspect-ratio: 4 / 3;
}

.photo-thumb figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.photo-thumb button {
  min-height: 28px;
  padding: 0 8px;
  border-radius: var(--radius);
  background: #fff3f2;
  color: var(--warning);
  font-weight: 900;
}

.concept-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#conceptStatus {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.concept-preview {
  display: grid;
  gap: 10px;
}

.concept-preview img {
  max-height: 560px;
}

.wide-field,
.form-actions {
  grid-column: 1 / -1;
}

#submitStatus {
  min-height: 24px;
  margin: 0;
  color: var(--success);
  font-weight: 800;
}

.estimate-panel {
  position: sticky;
  top: 88px;
  align-self: start;
}

.estimate-card {
  padding: 20px;
}

.estimate-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.estimate-header h2 {
  margin: 4px 0 0;
  font-size: 2.45rem;
  line-height: 1;
}

.range-meter {
  height: 10px;
  margin: 18px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebee;
}

.range-meter span {
  display: block;
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-2);
  transition: width 180ms ease;
}

.range-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.estimate-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 18px;
}

.estimate-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.estimate-stats dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.estimate-stats dd {
  margin: 6px 0 0;
  font-weight: 900;
}

.summary-list {
  display: grid;
  gap: 10px;
  max-height: 410px;
  overflow: auto;
  padding-right: 4px;
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.summary-row strong {
  display: block;
  font-size: 0.92rem;
}

.summary-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-row em {
  font-style: normal;
  font-weight: 900;
}

.remove-line {
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: #fff3f2;
  border: 1px solid #ecc8c3;
  color: var(--warning);
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.empty-summary {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 800;
}

.included-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.included-block ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--muted);
  line-height: 1.55;
}

.prep-line label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.prep-line span {
  display: grid;
  gap: 1px;
}

.prep-line small {
  color: var(--ink);
  font-weight: 900;
}

.prep-line[data-included="false"] span {
  text-decoration: line-through;
  opacity: 0.68;
}

.proposal {
  display: none;
}

.proposal-page {
  background: #fff;
  color: #111827;
}

.proposal-header,
.proposal-hero,
.proposal-contact {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.proposal-header {
  border-bottom: 2px solid #111827;
  padding-bottom: 18px;
}

.proposal-header h1,
.proposal-header p,
.proposal-hero h2,
.proposal-hero p {
  margin: 0;
}

.proposal-header h1 {
  margin-top: 4px;
  font-size: 28px;
}

.proposal-hero {
  align-items: center;
  margin: 24px 0;
  padding: 18px;
  border: 1px solid #d1d5db;
}

.proposal-hero img {
  width: 220px;
  height: 150px;
  object-fit: cover;
}

.proposal-concept {
  margin: 18px 0;
}

.proposal-concept:empty {
  display: none;
}

.proposal-concept h3 {
  margin: 0 0 10px;
}

.proposal-concept img {
  max-height: 420px;
}

.proposal-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
}

.proposal-table th,
.proposal-table td {
  padding: 10px;
  border-bottom: 1px solid #d1d5db;
  text-align: left;
  vertical-align: top;
}

.proposal-table th:last-child,
.proposal-table td:last-child {
  text-align: right;
}

.proposal-notes {
  margin-top: 24px;
  padding: 14px 18px;
  background: #f3f4f6;
}

.proposal-disclaimer {
  margin-top: 22px;
  color: #4b5563;
  font-size: 12px;
}

@media (max-width: 1120px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }

  .estimate-panel {
    position: static;
  }

  .summary-list {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .topbar,
  .section-heading,
  .split-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .tier-grid,
  .product-grid,
  .layout-options,
  .measurement-grid,
  .contact-form,
  .intro-panel,
  .photo-preview-grid {
    grid-template-columns: 1fr;
  }

  .tier-card {
    grid-template-rows: 210px 1fr;
  }

  .category-tabs {
    justify-content: flex-start;
  }
}

@media print {
  @page {
    margin: 0.55in;
  }

  body {
    background: #fff;
  }

  .app-shell {
    display: none;
  }

  .proposal {
    display: block;
  }

  .proposal-page {
    break-inside: avoid;
  }
}
