:root {
  color-scheme: light;
  --bg: #edf0f3;
  --panel: #ffffff;
  --panel-soft: #f5f6f7;
  --ink: #17202a;
  --muted: #697480;
  --line: #dce1e5;
  --accent: #0878c9;
  --accent-soft: #e9f5fd;
  --shadow: 0 24px 70px rgba(20, 27, 35, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 410px) 1fr;
  gap: 14px;
  padding: 14px;
}

.sidebar, .viewer-panel {
  background: var(--panel);
  border: 1px solid rgba(20, 27, 35, 0.08);
  box-shadow: var(--shadow);
  border-radius: 22px;
  overflow: hidden;
}

.sidebar { overflow-y: auto; scrollbar-width: thin; }

.brand-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand-mark { width: 40px; height: 40px; position: relative; transform: rotate(-7deg); }
.brand-mark span { position: absolute; left: 3px; right: 3px; height: 8px; border-radius: 2px; background: var(--ink); transform: skewX(-30deg); }
.brand-mark span:nth-child(1) { top: 6px; }
.brand-mark span:nth-child(2) { top: 16px; background: var(--accent); }
.brand-mark span:nth-child(3) { top: 26px; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.brand-subtitle { color: var(--muted); font-size: 11px; margin-top: 2px; }
.live-pill { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #effaf4; color: #267049; border-radius: 999px; font-size: 11px; font-weight: 700; }
.live-pill i { width: 7px; height: 7px; background: #35a76a; border-radius: 50%; box-shadow: 0 0 0 4px rgba(53,167,106,.12); }

.panel-section { padding: 23px 24px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 17px; }
.section-heading.compact { align-items: center; }
.eyebrow { margin: 0 0 4px; color: var(--accent); text-transform: uppercase; font-weight: 800; letter-spacing: .14em; font-size: 9px; }
h1, h2 { margin: 0; letter-spacing: -0.04em; }
h1 { font-size: 23px; }
h2 { font-size: 19px; }
.section-number { color: #d7dce0; font-weight: 900; font-size: 26px; letter-spacing: -.05em; }

.roof-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.roof-card {
  min-height: 92px;
  padding: 10px 6px 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: .18s ease;
}
.roof-card:hover { transform: translateY(-2px); border-color: #bac2c9; }
.roof-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.roof-card svg { width: 60px; height: 39px; fill: none; stroke: #5f6973; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.roof-card svg .accent { stroke: var(--accent); stroke-width: 3; opacity: 0; }
.roof-card[aria-pressed="true"] svg .accent { opacity: 1; }
.roof-card span { font-size: 11px; font-weight: 700; }

.control-list { display: grid; gap: 17px; }
.range-control { display: grid; gap: 8px; }
.control-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.control-label b { font-weight: 700; }
.control-label output { color: var(--muted); font-variant-numeric: tabular-nums; }
.range-row { display: grid; grid-template-columns: 1fr 88px; align-items: center; gap: 12px; }
input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.number-input, select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  color: var(--ink);
  outline: none;
}
.number-input { padding: 0 9px; text-align: right; font-variant-numeric: tabular-nums; }
.number-input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,120,201,.1); }
.select-label, .color-heading { display: block; font-size: 11px; color: var(--muted); margin-bottom: 7px; }
select { padding: 0 11px; }
.rule-note { min-height: 30px; margin: 8px 0 16px; font-size: 10px; line-height: 1.45; color: var(--muted); }
.swatch-row { display: flex; gap: 10px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--swatch); box-shadow: 0 0 0 1px var(--line); cursor: pointer; transition: .16s ease; }
.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 2px var(--ink); }

.viewer-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; }
.viewer-header {
  min-height: 75px;
  padding: 12px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.viewer-header h2 { font-size: 22px; }
.viewer-title-block { grid-column: 2; text-align: center; white-space: nowrap; }
.viewer-title-block .eyebrow { margin-bottom: 3px; }
.viewer-header-spacer { grid-column: 3; min-width: 0; }
.view-actions { display: flex; gap: 6px; padding: 4px; background: var(--panel-soft); border-radius: 11px; }
.view-actions button { border: 0; background: transparent; border-radius: 8px; padding: 8px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.view-actions button:hover, .view-actions button.active { background: #fff; box-shadow: 0 2px 8px rgba(20,27,35,.08); }

.viewer-stage { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at 55% 42%, #fff 0%, #f5f6f7 40%, #e7eaed 100%); }
.roof-tools-anchor {
  position: absolute;
  top: 16px;
  left: 18px;
  z-index: 24;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* The shared Tools button stays in its original shell DOM so all shared-ui
   styling continues to apply. These rules only relocate it visually. */
.roof-relocated-tools-button {
  position: fixed !important;
  top: var(--roof-tools-top, 0) !important;
  left: var(--roof-tools-left, 0) !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 80 !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: auto !important;
}
#canvasHost { position: absolute; inset: 0; }
#canvasHost canvas { display: block; width: 100%; height: 100%; }
.stage-hint { position: absolute; left: 18px; bottom: 17px; color: #747f89; font-size: 10px; padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.72); backdrop-filter: blur(8px); pointer-events: none; }
.model-options { display: flex; gap: 7px; }
.model-options label { display: flex; align-items: center; gap: 7px; min-height: 34px; background: var(--panel-soft); border: 1px solid rgba(20,27,35,.08); border-radius: 9px; padding: 7px 9px; font-size: 10px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.model-options input { accent-color: var(--accent); }

.metrics-bar { display: grid; grid-template-columns: repeat(4, 1fr); min-height: 82px; border-top: 1px solid var(--line); background: #fff; }
.metrics-bar article { padding: 16px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.metrics-bar article:last-child { border-right: 0; }
.metrics-bar span { color: var(--muted); font-size: 10px; }
.metrics-bar strong { font-size: 17px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.dimension-label {
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(24, 31, 39, .88);
  color: white;
  font: 700 10px/1 Inter, ui-sans-serif, sans-serif;
  white-space: nowrap;
  box-shadow: 0 5px 16px rgba(0,0,0,.16);
  pointer-events: none;
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; }
  .sidebar { max-height: none; }
  .viewer-panel { min-height: 690px; }
}

@media (max-width: 580px) {
  .app-shell { padding: 0; gap: 0; }
  .sidebar, .viewer-panel { border-radius: 0; border-left: 0; border-right: 0; }
  .roof-type-grid { grid-template-columns: repeat(2, 1fr); }
  .viewer-header { align-items: stretch; gap: 10px; }
  .view-actions { flex-wrap: wrap; justify-content: flex-start; }
  .metrics-bar { grid-template-columns: repeat(2, 1fr); }
  .metrics-bar article:nth-child(2) { border-right: 0; }
  .metrics-bar article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

.viewer-actions-wrap {
  grid-column: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.estimate-button {
  min-height: 42px;
  border: 1px solid rgba(8, 120, 201, .24);
  border-radius: 11px;
  padding: 7px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  justify-items: start;
  gap: 1px;
  cursor: pointer;
  transition: .18s ease;
}

.estimate-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 7px 18px rgba(8, 120, 201, .12);
}

.estimate-button span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.estimate-button strong {
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.bom-panel {
  position: fixed;
  z-index: 100;
  inset: 14px 14px 14px auto;
  width: min(720px, calc(100vw - 28px));
  max-width: none;
  height: calc(100dvh - 28px);
  max-height: calc(100dvh - 28px);
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(20, 27, 35, .10);
  border-radius: 22px;
  box-shadow: 0 34px 110px rgba(12, 18, 24, .28);
  overflow: hidden;
}

.bom-panel:not([open]) {
  display: none;
}

.bom-panel[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: bom-panel-in .22s cubic-bezier(.22, .7, .2, 1);
}


.bom-scroll-region {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

.bom-scroll-region::-webkit-scrollbar { width: 10px; }
.bom-scroll-region::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(91, 103, 114, .42);
  background-clip: padding-box;
}
.bom-scroll-region::-webkit-scrollbar-track { background: transparent; }

.bom-panel::backdrop {
  background: rgba(14, 20, 27, .36);
  backdrop-filter: blur(2px);
  animation: bom-backdrop-in .18s ease;
}

@keyframes bom-panel-in {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes bom-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bom-header {
  min-height: 76px;
  padding: 17px 20px 15px 23px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.bom-header h2 { font-size: 23px; }

.bom-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 11px;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.bom-close:hover { background: #fff; border-color: #b8c0c7; }

.bom-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 9px;
  padding: 15px 22px 10px;
}

.bom-summary article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  padding: 12px 13px;
  display: grid;
  gap: 5px;
}

.bom-summary span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bom-summary strong {
  font-size: 16px;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bom-summary .bom-total-card {
  background: var(--accent-soft);
  border-color: rgba(8, 120, 201, .25);
}

.bom-summary .bom-total-card strong { color: var(--accent); }

.bom-disclaimer {
  margin: 0 22px 13px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #fff8f3;
  color: #6e5e54;
  font-size: 10px;
  line-height: 1.5;
  border-radius: 0 8px 8px 0;
}

.bom-selection-toolbar {
  margin: 0 22px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.bom-selection-toolbar > div {
  display: flex;
  gap: 6px;
}

.bom-selection-toolbar button {
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-soft);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.bom-selection-toolbar button:hover:not(:disabled),
.bom-selection-toolbar button:focus-visible:not(:disabled) {
  border-color: rgba(8, 120, 201, .45);
  background: var(--accent-soft);
}

.bom-selection-toolbar button:disabled {
  opacity: .42;
  cursor: default;
}

.bom-check-cell {
  width: 38px;
  min-width: 38px;
  text-align: center !important;
}

.bom-check-cell input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.bom-table tbody tr.is-excluded td:not(.bom-check-cell) {
  opacity: .42;
}

.bom-table tbody tr.is-excluded td:nth-child(n+3) {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.bom-table tbody tr.is-excluded td {
  background: rgba(127, 127, 127, .045);
}

.bom-table-wrap {
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
  margin: 0 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  scrollbar-width: thin;
}

.bom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10px;
}

.bom-table th,
.bom-table td {
  padding: 9px 9px;
  border-bottom: 1px solid #e8ebee;
  text-align: right;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
  white-space: nowrap;
}

.bom-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f2f4;
  color: #5e6872;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bom-table th:nth-child(3),
.bom-table td:nth-child(3) {
  min-width: 230px;
  text-align: left;
  white-space: normal;
}

.bom-table th:nth-child(2),
.bom-table td:nth-child(2) { text-align: center; width: 38px; }
.bom-table th:nth-child(4),
.bom-table td:nth-child(4) { text-align: center; }
.bom-table tbody tr:last-child td { border-bottom: 0; }
.bom-table tbody tr:hover td { background: #fafbfb; }
.bom-table td strong { display: block; font-weight: 700; }
.bom-table td small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }

.bom-assumptions {
  padding: 14px 22px 13px;
  border-top: 1px solid var(--line);
}

.bom-assumptions h3 {
  margin: 0 0 9px;
  font-size: 11px;
}

.assumption-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.assumption-grid div {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 8px;
  background: var(--panel-soft);
  display: grid;
  gap: 2px;
}

.assumption-grid span { color: var(--muted); font-size: 8px; }
.assumption-grid strong { font-size: 10px; font-variant-numeric: tabular-nums; }
.bom-assumptions p { margin: 9px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }

.bom-footer {
  padding: 13px 22px 17px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.primary-action,
.secondary-action {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.secondary-action { border: 1px solid var(--line); background: #fff; }
.primary-action:hover { filter: brightness(.96); }
.secondary-action:hover { border-color: #aeb7bf; background: var(--panel-soft); }

@media (max-width: 1180px) {
  .estimate-button strong { display: none; }
}

@media (max-width: 1120px) {
  .viewer-header {
    grid-template-columns: 1fr;
    padding: 12px 16px;
  }
  .viewer-actions-wrap,
  .viewer-title-block,
  .viewer-header-spacer { grid-column: 1; }
  .viewer-title-block { grid-row: 1; }
  .viewer-actions-wrap { grid-row: 2; justify-content: center; }
  .viewer-header-spacer { display: none; }
}

@media (max-width: 760px) {
  .viewer-actions-wrap { align-items: center; flex-direction: row; justify-content: flex-start; }
  .estimate-button { min-height: 34px; display: flex; align-items: center; gap: 7px; }
  .estimate-button strong { display: block; }
  .bom-panel { inset: 0; width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .bom-summary { grid-template-columns: repeat(2, 1fr); }
  .bom-summary .bom-total-card { grid-column: 1 / -1; }
  .assumption-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Custom roof plan proof-of-concept */
.custom-plan-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, #fafbfc, #f3f5f6);
}

.custom-plan-panel[hidden],
.custom-plan-dropzone[hidden],
.custom-plan-file[hidden],
.custom-viewer-notice[hidden] {
  display: none !important;
}

.custom-plan-copy {
  display: grid;
  gap: 4px;
  margin-bottom: 11px;
}

.custom-plan-copy strong { font-size: 12px; }
.custom-plan-copy span { color: var(--muted); font-size: 9px; line-height: 1.45; }

.custom-plan-dropzone {
  min-height: 112px;
  border: 1px dashed #aeb7bf;
  border-radius: 11px;
  background: rgba(255, 255, 255, .76);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  cursor: pointer;
  transition: .18s ease;
}

.custom-plan-dropzone:hover,
.custom-plan-dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.custom-plan-dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.custom-plan-icon { color: var(--accent); font-size: 24px; font-weight: 700; line-height: 1; }
.custom-plan-main { font-size: 11px; font-weight: 800; }
.custom-plan-types { color: var(--muted); font-size: 9px; }

.custom-plan-file {
  min-height: 62px;
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(8, 120, 201, .22);
  border-radius: 11px;
  background: #fff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.custom-plan-file-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.custom-plan-file-details { min-width: 0; display: grid; gap: 3px; }
.custom-plan-file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.custom-plan-file-details small { color: var(--muted); font-size: 8px; }
.custom-plan-file button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  font-size: 18px;
}
.custom-plan-file button:hover { border-color: #aeb7bf; background: #fff; }

.model-options label.disabled { opacity: .48; cursor: not-allowed; }

.custom-viewer-notice {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: min(360px, calc(100% - 42px));
  transform: translate(-50%, -50%);
  padding: 19px 20px;
  border: 1px solid rgba(20, 27, 35, .10);
  border-radius: 15px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 18px 50px rgba(20, 27, 35, .13);
  backdrop-filter: blur(12px);
  text-align: center;
  pointer-events: none;
}

.custom-viewer-notice-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 9px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 900;
}
.custom-viewer-notice strong { display: block; font-size: 14px; }
.custom-viewer-notice p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.bom-empty-row td { padding: 28px 16px !important; text-align: center !important; white-space: normal !important; }
.bom-empty-row td strong { font-size: 12px; }
.bom-empty-row td small { margin-top: 5px !important; font-size: 9px !important; }
.secondary-action:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 760px) {
  .roof-tools-anchor { top: 12px; left: 12px; }
}

/* Roof implementation of the opt-in shared viewport tools. */
.shared-ui-host .roof-relocated-tools-toolbar {
  position: fixed !important;
  top: var(--roof-tools-top, 0) !important;
  left: var(--roof-tools-left, 0) !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 920 !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: auto !important;
}

.shared-ui-host .roof-relocated-tools-toolbar .tools-toolbar__panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}

.shared-ui-host .roof-relocated-tools-toolbar .tools-toolbar__panel.is-open {
  display: flex;
}

.shared-ui-host .round-tool {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(17, 29, 35, 0.08);
  border-radius: 50%;
  color: #152633;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 22px rgba(20, 32, 39, 0.12);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.shared-ui-host .round-tool:hover:not(:disabled),
.shared-ui-host .round-tool:focus-visible:not(:disabled) {
  color: #0878c9;
  transform: translateY(-1px);
}

.shared-ui-host .round-tool.is-active {
  color: #fff;
  background: #0878c9;
}

.shared-ui-host .round-tool:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.shared-ui-host .round-tool > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.shared-ui-host .round-tool svg {
  display: block;
  width: 24px;
  height: 24px;
}

.roof-environment-panel {
  position: fixed;
  top: var(--roof-environment-top, 140px);
  left: var(--roof-environment-left, 106px);
  z-index: 940;
  width: var(--roof-environment-width, 390px);
  max-width: calc(100vw - 24px);
  padding: 24px;
  border: 1px solid rgba(20, 27, 35, 0.1);
  border-radius: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 18px 54px rgba(24, 39, 47, 0.2);
  backdrop-filter: blur(18px);
}

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

.roof-environment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.roof-environment-header h2 {
  font-size: 18px;
  letter-spacing: -0.035em;
}

.roof-environment-header button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #17202a;
  background: transparent;
  cursor: pointer;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.roof-environment-header button:hover,
.roof-environment-header button:focus-visible { background: #eef1f3; }

.roof-environment-control {
  display: grid;
  gap: 9px;
  margin-bottom: 24px;
}

.roof-environment-control__heading,
.roof-environment-control__ends {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.roof-environment-control__heading label {
  font-size: 13px;
  font-weight: 800;
}

.roof-environment-control__heading output,
.roof-environment-control__ends {
  color: #3c4c59;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.roof-environment-control input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #0878c9;
}

.roof-night-preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 14px 15px;
  border: 1px solid #dce2e6;
  border-radius: 14px;
  cursor: pointer;
}

.roof-night-preview__icon {
  color: #17202a;
  font-size: 25px;
  line-height: 1;
}

.roof-night-preview__copy {
  display: grid;
  gap: 3px;
}

.roof-night-preview__copy strong { font-size: 13px; }
.roof-night-preview__copy small { color: var(--muted); font-size: 10px; }
.roof-night-preview input { position: absolute; opacity: 0; pointer-events: none; }

.roof-switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #cbd2d7;
  transition: background 160ms ease;
}

.roof-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(18, 28, 36, 0.22);
  content: '';
  transition: transform 160ms ease;
}

.roof-night-preview input:checked + .roof-switch { background: #0878c9; }
.roof-night-preview input:checked + .roof-switch::after { transform: translateX(18px); }
.roof-night-preview input:focus-visible + .roof-switch { outline: 3px solid rgba(8, 120, 201, 0.2); outline-offset: 2px; }

.viewer-stage.is-night-preview {
  background: radial-gradient(circle at 55% 42%, #24334d 0%, #15233a 48%, #091321 100%);
}

.viewer-stage.is-night-preview .stage-hint {
  color: #d5dfeb;
  background: rgba(11, 22, 37, 0.72);
}

.compass-label {
  display: grid;
  min-width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid rgba(17, 29, 35, 0.14);
  border-radius: 50%;
  color: #223240;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 10px rgba(16, 28, 36, 0.16);
  font-size: 10px;
  font-weight: 900;
  pointer-events: none;
}

.compass-label--north { color: #c72f3d; }

body.shared-ui-dark-mode .roof-environment-panel {
  color: #e7eef3;
  background: rgba(20, 31, 45, 0.985);
  border-color: rgba(255, 255, 255, 0.1);
}

body.shared-ui-dark-mode .roof-environment-header button,
body.shared-ui-dark-mode .roof-night-preview__icon { color: #e7eef3; }
body.shared-ui-dark-mode .roof-environment-header button:hover { background: rgba(255, 255, 255, 0.08); }
body.shared-ui-dark-mode .roof-environment-control__heading output,
body.shared-ui-dark-mode .roof-environment-control__ends,
body.shared-ui-dark-mode .roof-night-preview__copy small { color: #b9c6d0; }
body.shared-ui-dark-mode .roof-night-preview { border-color: rgba(255, 255, 255, 0.12); }
body.shared-ui-dark-mode .shared-ui-host .round-tool { color: #e7eef3; background: rgba(20, 31, 45, 0.96); border-color: rgba(255, 255, 255, 0.11); }
body.shared-ui-dark-mode .shared-ui-host .round-tool.is-active { color: #fff; background: #0878c9; }

@media (max-width: 760px) {
  .roof-environment-panel {
    padding: 19px;
    border-radius: 16px;
  }

  .roof-environment-header { margin-bottom: 20px; }
  .roof-environment-control { margin-bottom: 20px; }
}

/* Rainwater-system reference drawer. */
.roof-components-backdrop {
  position: fixed;
  inset: var(--shared-topbar-height, 47px) 0 0;
  z-index: 950;
  background: rgba(14, 24, 31, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  backdrop-filter: blur(2px);
  transition: opacity 180ms ease, visibility 180ms ease;
}
.roof-components-backdrop.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

.roof-components-drawer {
  position: fixed;
  top: var(--shared-topbar-height, 47px);
  right: 0;
  bottom: 0;
  z-index: 970;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(860px, calc(100vw - 94px));
  color: var(--ink);
  background: #f7f8f9;
  border-left: 1px solid rgba(20, 27, 35, 0.1);
  box-shadow: -24px 0 60px rgba(19, 31, 39, 0.18);
  transform: translateX(calc(100% + 30px));
  visibility: hidden;
  pointer-events: none;
  transition: transform 230ms cubic-bezier(.22, .72, .22, 1), visibility 230ms ease;
}
.roof-components-drawer.is-open { transform: translateX(0); visibility: visible; pointer-events: auto; }
body.roof-components-open { overflow: hidden; }

.roof-components-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 17px 22px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
}
.roof-components-header .eyebrow { margin-bottom: 3px; }
.roof-components-header h2 { font-size: 22px; letter-spacing: -.035em; }
.roof-components-header button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}
.roof-components-header button:hover,
.roof-components-header button:focus-visible { background: #eef1f3; border-color: #dde2e5; }

.roof-components-toolbar {
  padding: 13px 22px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.roof-components-toolbar > label {
  display: block;
  margin-bottom: 6px;
  color: #334550;
  font-size: 10px;
  font-weight: 800;
}
.roof-components-search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #d9dfe3;
  border-radius: 11px;
  background: #f8fafb;
}
.roof-components-search-row > span { color: #5f6c76; font-size: 22px; line-height: 1; }
.roof-components-search-row input {
  min-width: 0;
  padding: 10px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 12px;
}
.roof-components-search-row small { color: var(--muted); font-size: 9px; white-space: nowrap; }

.roof-components-content {
  display: grid;
  grid-template-columns: minmax(245px, .8fr) minmax(380px, 1.35fr);
  gap: 18px;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.roof-components-content::-webkit-scrollbar { width: 9px; }
.roof-components-content::-webkit-scrollbar-thumb { background: #c3cbd0; border: 2px solid #f7f8f9; border-radius: 999px; }

.roof-system-overview {
  position: sticky;
  top: 0;
  align-self: start;
  margin: 0;
  overflow: hidden;
  border: 1px solid #dfe4e7;
  border-radius: 15px;
  background: #fff;
}
.roof-system-overview-image {
  display: grid;
  min-height: 360px;
  place-items: start center;
  padding: 12px 10px 4px;
  background: #fff;
}
.roof-system-overview img { display: block; width: 100%; max-height: 430px; object-fit: contain; }
.roof-system-overview figcaption {
  display: grid;
  gap: 5px;
  padding: 14px 15px 16px;
  border-top: 1px solid #edf0f2;
}
.roof-system-overview figcaption strong { font-size: 12px; }
.roof-system-overview figcaption span { color: var(--muted); font-size: 9px; line-height: 1.55; }

.roof-component-results { min-width: 0; }
.roof-component-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.roof-component-card {
  position: relative;
  display: grid;
  grid-template-rows: 132px auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dfe4e7;
  border-radius: 13px;
  background: #fff;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.roof-component-card:hover { border-color: #b9d8ec; box-shadow: 0 8px 22px rgba(20, 42, 57, 0.08); transform: translateY(-1px); }
.roof-component-card[hidden] { display: none; }
.roof-component-number {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 1;
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid #173342;
  border-radius: 6px;
  color: #173342;
  background: rgba(255, 255, 255, 0.96);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.roof-component-card img { display: block; width: 100%; height: 132px; object-fit: contain; background: #fff; }
.roof-component-copy { padding: 10px 12px 13px; border-top: 1px solid #f0f2f3; }
.roof-component-copy h3 { margin: 0; font-size: 11px; line-height: 1.35; }
.roof-component-copy p { margin: 6px 0 0; color: #49606d; font-size: 8.5px; line-height: 1.55; }
.roof-components-empty {
  margin: 0;
  padding: 42px 18px;
  border: 1px dashed #cad2d7;
  border-radius: 13px;
  color: var(--muted);
  background: #fff;
  text-align: center;
  font-size: 11px;
}

body.shared-ui-dark-mode .roof-components-drawer { color: #e7eef3; background: #111c28; border-left-color: rgba(255, 255, 255, 0.1); }
body.shared-ui-dark-mode .roof-components-header,
body.shared-ui-dark-mode .roof-components-toolbar,
body.shared-ui-dark-mode .roof-component-card,
body.shared-ui-dark-mode .roof-system-overview,
body.shared-ui-dark-mode .roof-components-empty { background: #162331; border-color: rgba(255, 255, 255, 0.1); }
body.shared-ui-dark-mode .roof-components-search-row { background: #101b27; border-color: rgba(255, 255, 255, 0.14); }
body.shared-ui-dark-mode .roof-components-search-row input { color: #e7eef3; }
body.shared-ui-dark-mode .roof-components-toolbar > label,
body.shared-ui-dark-mode .roof-component-copy p { color: #b9c6d0; }
body.shared-ui-dark-mode .roof-component-copy { border-top-color: rgba(255, 255, 255, 0.08); }
body.shared-ui-dark-mode .roof-components-header button { color: #e7eef3; }
body.shared-ui-dark-mode .roof-components-header button:hover { background: rgba(255, 255, 255, 0.08); }

@media (max-width: 820px) {
  .roof-components-drawer { width: min(690px, calc(100vw - 66px)); }
  .roof-components-content { grid-template-columns: 1fr; }
  .roof-system-overview { position: static; }
  .roof-system-overview-image { min-height: 250px; }
}
@media (max-width: 560px) {
  .roof-components-drawer { width: 100vw; }
  .roof-components-header { padding: 14px 16px; }
  .roof-components-toolbar { padding: 11px 16px 13px; }
  .roof-components-content { padding: 12px; }
  .roof-component-grid { grid-template-columns: 1fr; }
  .roof-component-card { grid-template-columns: 120px minmax(0, 1fr); grid-template-rows: auto; min-height: 126px; }
  .roof-component-card img { width: 120px; height: 100%; min-height: 126px; }
  .roof-component-copy { display: flex; flex-direction: column; justify-content: center; border-top: 0; border-left: 1px solid #f0f2f3; }
}
