:root {
  --ink: #18211f;
  --muted: #66736f;
  --line: #d9dfdc;
  --panel: #f8faf9;
  --paper: #ffffff;
  --mvr-green: #12613d;
  --mvr-red: #b6342b;
  --gold: #c7922d;
  --focus: #0f6f51;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: #eef2f0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.upload-button {
  border: 1px solid #b9c4bf;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover,
.upload-button:hover {
  border-color: var(--focus);
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-action {
  border-color: var(--mvr-green);
  background: var(--mvr-green);
  color: #ffffff;
  font-weight: 850;
  box-shadow: 0 6px 16px rgba(18, 97, 61, 0.18);
}

.primary-action:hover {
  border-color: #0a4f30;
  background: #0f5536;
}

.topbar {
  min-height: 72px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #090909;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.brand-mark strong {
  display: block;
  font-size: 17px;
  line-height: 1.15;
}

.brand-mark span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

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

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mvr-green);
  border-color: var(--mvr-green);
  color: #fff;
  font-weight: 700;
}

.upload-button input {
  display: none;
}

.upload-button-wide {
  width: 100%;
}

.workspace {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 376px;
}

.stage-panel {
  padding: 18px;
  width: 100%;
  min-width: 0;
}

.canvas-shell {
  position: relative;
  width: 100%;
  height: calc(100vh - 318px);
  min-height: 420px;
  display: grid;
  place-items: center;
  background: #202723;
  border: 1px solid #1b211e;
  border-radius: 8px;
  overflow: hidden;
}

#visualizerCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #e9efec;
  text-align: center;
  pointer-events: none;
}

.comparison-panel {
  margin-top: 12px;
  width: 100%;
  max-width: 100%;
  --compare-position: 50%;
  display: block;
  overflow: hidden;
}

.comparison-panel[hidden] {
  display: none;
}

.comparison-frame {
  min-width: 0;
  border: 1px solid #1b211e;
  border-radius: 8px;
  background: #202723;
  overflow: hidden;
}

.comparison-slider-stage {
  position: relative;
  width: 100%;
  height: clamp(220px, 42vw, 520px);
  background: #202723;
  overflow: hidden;
}

.comparison-slider-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.comparison-proposed-clip {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--compare-position));
  overflow: hidden;
}

.comparison-proposed-clip canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
}

.comparison-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare-position);
  width: 3px;
  transform: translateX(-50%);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28), 0 0 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.comparison-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--mvr-green);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.comparison-tag {
  position: absolute;
  top: 10px;
  z-index: 2;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  color: #ffffff;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.comparison-tag-original {
  left: 10px;
}

.comparison-tag-proposed {
  right: 10px;
}

.comparison-slider-control {
  width: 100%;
  margin: 0;
  min-height: 44px;
  accent-color: var(--mvr-green);
  background: #f8faf9;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

body.has-generated-image[data-current-step="generate"] .canvas-shell {
  display: none;
}

body.has-generated-image[data-current-step="generate"] .comparison-panel {
  margin-top: 0;
}

.empty-state strong {
  font-size: 24px;
}

.empty-state span {
  color: #b9c5bf;
}

.tool-panel {
  min-width: 0;
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
}

.control-group {
  padding: 0 0 18px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.control-group:last-child {
  border-bottom: 0;
}

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.estimate-ticker {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(18, 97, 61, 0.28);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(22, 63, 54, 0.12);
}

.estimate-ticker span {
  color: #3f4c48;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.estimate-ticker strong {
  color: var(--mvr-green);
  font-size: 22px;
}

.wizard-dot {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #c8d2cd;
  border-radius: 8px;
  background: #ffffff;
  color: #53605c;
  font-size: 12px;
  font-weight: 800;
}

.wizard-dot.is-active {
  border-color: var(--mvr-green);
  background: var(--mvr-green);
  color: #ffffff;
}

.wizard-dot.is-complete {
  border-color: #7aa891;
  background: #e8f3ed;
  color: var(--mvr-green);
}

.wizard-step[hidden],
.product-section[hidden],
.pricing-section[hidden],
.accent-section[hidden],
[hidden] {
  display: none !important;
}

.wizard-step > button,
#continueToProjectButton {
  position: sticky;
  bottom: 0;
  z-index: 6;
  width: 100%;
  margin: 14px 0 0;
}

.wizard-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px -2px -2px;
  padding: 10px 2px 2px;
  background: linear-gradient(180deg, rgba(248, 250, 249, 0), var(--panel) 24%);
}

.wizard-actions button {
  width: 100%;
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: #4d5a56;
  font-size: 12px;
  font-weight: 800;
}

.measurement-row span:not(#measureUnit) {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: #edf2ef;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.product-section {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
}

.product-section strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.pricing-section {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
}

.pricing-section strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.add-on-quantity {
  margin-left: 30px;
}

.step-list {
  margin: 4px 0 8px;
  padding-left: 18px;
  color: #43504b;
  font-size: 12px;
  line-height: 1.45;
}

.step-list li + li {
  margin-top: 4px;
}

.toggle-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.check-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: #394642;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.area-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.area-pill {
  padding: 8px 10px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
  color: #4e5b57;
  font-size: 12px;
  line-height: 1.35;
}

.area-pill strong {
  display: block;
  color: #202a26;
  font-size: 12px;
}

.group-label {
  display: block;
  margin-bottom: 8px;
  color: #3f4c48;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #b9c4bf;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
}

.segmented.two-up {
  grid-template-columns: repeat(2, 1fr);
}

.segment,
.job-type {
  border: 0;
  border-radius: 0;
  min-height: 42px;
  background: transparent;
}

.segment + .segment,
.job-type + .job-type {
  border-left: 1px solid #d5ded9;
}

.segment.is-active,
.job-type.is-active {
  background: var(--mvr-green);
  color: #fff;
  font-weight: 800;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.button-row.stack {
  grid-template-columns: 1fr;
}

.detection-group button {
  width: 100%;
}

.detection-status {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.detection-status.is-loading,
.ai-render-status.is-loading {
  color: #3f4c48;
  font-weight: 700;
}

.detection-status.is-loading::before,
.ai-render-status.is-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  display: inline-block;
  margin-right: 7px;
  border: 2px solid #cfd8d3;
  border-top-color: var(--mvr-green);
  border-radius: 999px;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

.detection-note {
  margin: 8px 0 0;
  color: #5b6864;
  font-size: 12px;
  line-height: 1.35;
}

.detection-status.is-ok {
  color: var(--mvr-green);
}

.detection-status.is-error {
  color: var(--mvr-red);
}

.ai-render-group button {
  width: 100%;
  margin-top: 8px;
}

.ai-render-status {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ai-render-status.is-ok {
  color: var(--mvr-green);
}

.ai-render-status.is-error {
  color: var(--mvr-red);
}

.ai-render-note {
  margin: 8px 0 0;
  color: #5b6864;
  font-size: 12px;
  line-height: 1.35;
}

.generate-action {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
}

.measurement-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  align-items: center;
}

.measurement-note {
  margin: 8px 0 0;
  color: #5b6864;
  font-size: 12px;
  line-height: 1.35;
}

.process-note,
.important-note,
.warning-note {
  margin: 10px 0 0;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.process-note {
  padding: 9px 10px;
  border: 1px solid #d3dcd7;
  background: #ffffff;
  color: #44514d;
}

.important-note {
  padding: 12px;
  border: 1px solid rgba(18, 97, 61, 0.25);
  background: #eaf5ef;
  color: #21302b;
  font-weight: 750;
}

.warning-note {
  padding: 10px;
  border: 1px solid #e4c66a;
  background: #fff4c4;
  color: #514111;
  font-weight: 750;
}

.field-help {
  margin: 6px 0 10px;
  color: #5b6864;
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #b9c4bf;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.35;
}

#measureUnit {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: #edf2ef;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.product-tile {
  min-height: 118px;
  padding: 8px;
  display: grid;
  grid-template-rows: 54px auto;
  gap: 8px;
  border: 1px solid #cbd5d0;
  border-radius: 8px;
  background: var(--paper);
  text-align: left;
}

.product-tile.is-selected {
  border-color: var(--mvr-red);
  box-shadow: 0 0 0 2px rgba(182, 52, 43, 0.16);
}

.swatch {
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background-color: #777;
}

.product-name {
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.product-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.product-source {
  display: block;
  margin-top: 4px;
  color: #52625d;
  font-size: 10px;
  line-height: 1.25;
}

.workflow-group .button-row {
  margin-top: 10px;
}

.workflow-hint {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
  color: #4e5b57;
  font-size: 12px;
  line-height: 1.35;
}

.workflow-hint.is-ok {
  border-color: #8cc3a6;
  background: #edf8f2;
  color: #173f2c;
}

.workflow-hint.is-error {
  border-color: #e4a6a0;
  background: #fff1ef;
  color: #7c2118;
}

.workflow-hint span::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--gold);
  vertical-align: 1px;
}

.sub-label {
  margin-top: 14px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-item {
  padding: 10px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: var(--paper);
}

.summary-item strong {
  display: block;
  font-size: 13px;
}

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

.estimate-breakdown {
  display: grid;
  gap: 8px;
}

.estimate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid #d3dcd7;
  border-radius: 8px;
  background: #ffffff;
}

.estimate-row strong,
.estimate-row small {
  display: block;
}

.estimate-row strong {
  color: #26312d;
  font-size: 13px;
  line-height: 1.25;
}

.estimate-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.estimate-row b {
  color: #26312d;
  font-size: 13px;
  white-space: nowrap;
}

.estimate-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--mvr-green);
  color: #ffffff;
}

.estimate-total span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.estimate-total strong {
  font-size: 20px;
}

.estimate-note {
  margin: 10px 0 0;
  color: #5b6864;
  font-size: 12px;
  line-height: 1.4;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.estimate-summary strong {
  color: var(--mvr-green);
}

.delivery-status {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.delivery-status.is-ok {
  color: var(--mvr-green);
}

.delivery-status.is-error {
  color: var(--mvr-red);
}

@media (max-width: 920px) {
  body {
    background: #f8faf9;
  }

  .topbar {
    min-height: 0;
    padding: 10px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
  }

  .stage-panel {
    padding: 10px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .canvas-shell {
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .comparison-slider-stage {
    height: min(58vw, 360px);
  }

  .comparison-frame canvas {
    height: 118px;
  }

  .tool-panel {
    width: 100%;
    max-width: 100vw;
    padding: 12px 10px calc(96px + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .brand-icon {
    width: 40px;
    height: 40px;
  }

  .brand-mark strong {
    font-size: 15px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .control-group {
    padding-bottom: 14px;
    margin-bottom: 14px;
  }
}

@media (max-width: 480px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .comparison-slider-stage {
    height: min(58vw, 230px);
  }

  .wizard-progress {
    gap: 6px;
  }

  .wizard-dot {
    min-width: 0;
  }
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.privacy-page {
  min-height: 100vh;
  padding: 28px 16px;
  background: var(--bg);
}

.privacy-document {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.privacy-document h1,
.privacy-document h2,
.privacy-document p {
  margin-top: 0;
}

.privacy-document h1 {
  color: var(--green);
  font-size: clamp(28px, 4vw, 44px);
}

.privacy-document h2 {
  margin-top: 24px;
  font-size: 18px;
}
