:root {
  color-scheme: light;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #17201b;
  --muted: #66706a;
  --line: #d9ded8;
  --panel: #f7f8f5;
  --paper: #ffffff;
  --accent: #1f6f5b;
  --accent-2: #a86b32;
  --dark: #27302b;
  --focus: #d7e8df;
  --shadow: 0 18px 45px rgba(28, 34, 30, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef1ed;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  min-height: 100vh;
}

.viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  min-width: 0;
  background: linear-gradient(180deg, #fbfcf9 0%, #e5e9e2 100%);
}

.topbar,
.panel-head,
.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.contact-menu {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(360px, 92vw);
  max-width: 92vw;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
  padding: 24px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  overflow-y: auto;
}
.contact-menu[open] { animation: drawer-in 180ms ease-out; }
.contact-menu::backdrop { background: rgb(0 0 0 / 24%); }
.menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.menu-heading h2 { font-size: 20px; margin: 0; }
.menu-contact, .menu-export { padding: 24px 0; border-bottom: 1px solid var(--line); }
.contact-menu h3 { margin: 0 0 16px; font-size: 15px; }
.menu-contact a { display: block; color: var(--ink); padding: 10px 0; overflow-wrap: anywhere; }
.menu-contact a[hidden] { display: none; }
#download-pdf { width: 100%; min-height: 44px; padding: 12px; }
#pdf-status { font-size: 13px; line-height: 1.5; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .contact-menu[open] { animation: none; } }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--dark);
  color: #fff;
  font-size: 18px;
}
.brand-logo { display: block; width: 210px; max-width: 100%; height: auto; }
.topbar .brand { min-width: 0; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar .brand-logo { width: 210px; }
  .topbar .status { flex-basis: 100%; }
}

.status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.status strong {
  color: var(--ink);
}

.viewport {
  position: relative;
  min-height: 420px;
  overflow: hidden;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.scene-overlay {
  position: absolute;
  left: 18px;
  top: 18px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.scene-overlay > * {
  pointer-events: auto;
}

.view-tabs,
.tool-grid,
.segmented,
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool,
.icon-tool,
.wide-command,
.primary-command,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  min-height: 38px;
}

.tool {
  padding: 0 12px;
  font-weight: 700;
  font-size: 13px;
}

.tool.active,
.segmented button.active,
.model-card.active,
.glazing-card.active,
.swatch.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--focus);
}

.icon-tool {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-weight: 800;
  font-size: 18px;
}

.tool-grid {
  max-width: 314px;
}

.tool-grid .reset {
  width: 84px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.78);
}

.summary-strip div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.summary-strip span,
.step-title span,
.field-label,
.dialog-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-strip strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.config-panel {
  max-height: 100vh;
  overflow: auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
}

.panel-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  font-weight: 800;
}

.step {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.step-title {
  display: grid;
  gap: 2px;
  margin-bottom: 14px;
}

.step-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

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

.model-grid.single {
  grid-template-columns: 1fr;
}

.model-card,
.glazing-card,
.segmented button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.model-card {
  min-height: 92px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.model-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border-radius: 5px;
  background: var(--panel);
}

.model-card strong,
.glazing-card strong {
  font-size: 15px;
}

.model-card span,
.glazing-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.segmented.four {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented button {
  min-height: 54px;
  padding: 8px;
  text-align: center;
  font-weight: 800;
}

.range-row,
.meter-row,
.select-row,
.toggle-row {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.range-row span,
.meter-row span,
.select-row,
.toggle-row {
  font-weight: 700;
}

.range-row span,
.meter-row > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meter-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.meter-input-wrap input {
  min-width: 0;
  border: 0;
  outline: 0;
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--ink);
  background: transparent;
}

.meter-input-wrap span {
  color: var(--muted);
}

.quick-lengths {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quick-lengths button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 800;
}

.quick-lengths button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field-label {
  margin: 12px 0 8px;
}

.swatch {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 800;
  font-size: 12px;
}

.swatch i {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 50%;
}

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

.mounting-grid {
  display: grid;
  gap: 10px;
}

.mounting-card {
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.mounting-card strong {
  font-size: 14px;
}

.mounting-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mounting-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--focus);
}

.glazing-card {
  min-height: 76px;
  padding: 12px;
}

.glass-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px 10px;
}

.glass-card i {
  grid-row: span 2;
  width: 34px;
  height: 54px;
  border: 1px solid rgba(33, 45, 42, 0.22);
  border-radius: 4px;
  box-shadow: inset 8px 0 16px rgba(255, 255, 255, 0.42), inset -5px 0 12px rgba(48, 66, 66, 0.14);
}

.metric-note,
.price-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.wide-command,
.primary-command {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.primary-command {
  border-color: #174f41;
  background: var(--accent);
  color: #fff;
}

.wide-command.secondary {
  background: var(--panel);
  color: var(--ink);
}

.compact-grid {
  display: grid;
  gap: 12px;
}

.select-row select {
  width: 100%;
  padding: 0 12px;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-row input,
.privacy input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

dialog {
  width: min(680px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(17, 25, 22, 0.42);
}

.quote-form {
  padding: 22px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dialog-head h2 {
  margin: 2px 0 0;
}

.locked-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  font-size: 13px;
}

.locked-summary strong {
  display: block;
  margin-top: 4px;
}

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

.form-grid input,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 10px 12px;
}

.form-grid textarea {
  grid-column: 1 / -1;
  min-height: 92px;
  resize: vertical;
}

.quote-trap {
  position: absolute;
  left: -9999px;
}

.privacy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.quote-status {
  min-height: 20px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.quote-status.success {
  color: #1d6a4f;
}

.quote-status.error {
  color: #9a3429;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .viewer-panel {
    min-height: 72vh;
  }

  .config-panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar,
  .summary-strip,
  .panel-head,
  .step {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .viewport {
    min-height: 420px;
  }

  .scene-overlay {
    left: 10px;
    top: 10px;
    right: 10px;
  }

  .summary-strip,
  .model-grid,
  .glazing-grid,
  .form-grid,
  .locked-summary {
    grid-template-columns: 1fr;
  }

  .segmented.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }
}
/* Side dimensions stay aligned on narrow screens. */
.side-field { display: grid; grid-template-columns: minmax(0, 1fr) 100px 36px; gap: 8px; align-items: center; margin: 12px 0; }
.side-field .icon-tool { width: 36px; height: 36px; }
.side-field input, .side-field select, #side-count { min-width: 0; width: 100%; padding: 9px; border: 1px solid #cbd1ce; border-radius: 4px; background: white; color: #17201b; }
#side-count { width: 70px; }
.side-field select { grid-column: 1 / -1; }
