:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10151c;
  --panel-2: #0b1016;
  --line: #26313e;
  --line-soft: #19222c;
  --text: #f3f6f8;
  --muted: #8e9ba9;
  --lime: #a8ee45;
  --blue: #4a96ff;
  --cyan: #67e8f9;
  --amber: #ffbd62;
  --violet: #b69cff;
  --danger: #ff6b72;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 8%, rgba(74, 150, 255, 0.09), transparent 28rem),
    radial-gradient(circle at 12% 42%, rgba(168, 238, 69, 0.05), transparent 24rem),
    var(--bg);
}
button, input, textarea { font: inherit; }
button { color: inherit; }
code, textarea, .metrics strong, .canvas-hud strong, .integrity { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.topbar {
  height: 76px;
  padding: 0 clamp(18px, 3vw, 52px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 11, 16, 0.88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 14px; }
.brand > span:last-child { display: grid; gap: 3px; }
.brand b { letter-spacing: .16em; font-size: 15px; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.brand-cube { width: 32px; height: 32px; position: relative; transform: rotate(30deg) skew(-5deg); }
.brand-cube i { position: absolute; width: 17px; height: 17px; border: 1px solid var(--lime); background: rgba(168,238,69,.11); }
.brand-cube i:nth-child(1) { left: 1px; top: 8px; }
.brand-cube i:nth-child(2) { left: 12px; top: 1px; background: rgba(74,150,255,.14); border-color: var(--blue); }
.brand-cube i:nth-child(3) { left: 12px; top: 16px; background: rgba(103,232,249,.11); border-color: var(--cyan); }
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.runtime-badges { display: flex; gap: 8px; }
.runtime-badges span, .devnet {
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 9px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: .1em;
  white-space: nowrap;
}
.language-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; background: #0a0f15; }
.language-switch > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.language-switch select {
  min-width: 108px;
  min-height: 32px;
  padding: 0 28px 0 12px;
  border: 0;
  border-radius: 999px;
  outline: 0;
  color: var(--lime);
  background: #0a0f15;
  font: 9px monospace;
  cursor: pointer;
}
.language-switch select:focus-visible { box-shadow: 0 0 0 2px rgba(168, 238, 69, .3); }

main { width: min(1600px, calc(100% - clamp(24px, 5vw, 80px))); margin: 0 auto; }
.intro { min-height: 222px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 34px 0 26px; }
.eyebrow { margin: 0 0 9px; color: var(--lime); font-size: 10px; letter-spacing: .16em; font-weight: 750; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 15px; max-width: 760px; font-size: clamp(30px, 4vw, 58px); letter-spacing: -.045em; line-height: 1.04; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.02em; }
.lede { margin-bottom: 0; max-width: 820px; color: #a9b4bf; line-height: 1.75; font-size: 14px; }
.lede code { color: var(--cyan); }
.flow { display: flex; align-items: center; color: var(--muted); font: 10px/1 monospace; letter-spacing: .1em; white-space: nowrap; }
.flow i { width: clamp(16px, 2.5vw, 48px); height: 1px; background: linear-gradient(90deg, var(--line), var(--lime)); margin: 0 5px; position: relative; }
.flow i::after { content: ""; position: absolute; right: 0; top: -2px; border-left: 4px solid var(--lime); border-top: 2px solid transparent; border-bottom: 2px solid transparent; }

.builder-shell { margin-bottom: 16px; display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.builder-shell > * { min-width: 0; }
.building-library-panel {
  height: calc(100vh - 108px);
  min-height: 560px;
  max-height: 806px;
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
}
.building-library-panel .panel-head { min-height: 66px; }
.library-count {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #314c2b;
  border-radius: 999px;
  color: var(--lime);
  background: rgba(168, 238, 69, .045);
  font: 8px/1 monospace;
  letter-spacing: .11em;
  white-space: nowrap;
}
.building-library-intro {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 7px;
}
.building-library-intro p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.building-library-intro span { color: #64717e; font: 7px/1.4 monospace; letter-spacing: .08em; }
.building-library-browser {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
}
.building-category-list {
  min-width: 0;
  padding: 8px 6px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #38495b #0a0f15;
}
.building-category-button {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 8px 7px 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: #778592;
  background: transparent;
  text-align: left;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.building-category-button:hover { color: var(--text); background: #0c1219; }
.building-category-button.active {
  border-color: #40562f;
  color: var(--lime);
  background: linear-gradient(90deg, rgba(168, 238, 69, .1), rgba(168, 238, 69, .025));
  box-shadow: inset 2px 0 0 var(--lime);
}
.building-category-button:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.building-category-button span { min-width: 0; font: 7px/1.4 monospace; letter-spacing: .08em; overflow-wrap: anywhere; }
.building-category-button b { color: #52616e; font: 8px/1 monospace; }
.building-category-button.active b { color: var(--lime); }
.building-library-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.building-library-column-head {
  min-height: 43px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.building-library-column-head strong { color: #dce5ec; font: 8px/1.3 monospace; letter-spacing: .08em; }
.building-library-column-head span { color: #5f6d79; font: 7px/1 monospace; white-space: nowrap; }
.building-library-list {
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 7px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #38495b #0a0f15;
}
.building-library-card {
  width: 100%;
  min-width: 0;
  min-height: 144px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: stretch;
  color: var(--text);
  background: #090e14;
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
.building-library-card:hover { border-color: #3a4d62; background: #0c121a; transform: translateY(-1px); }
.building-library-card.active {
  border-color: #587d39;
  background: linear-gradient(135deg, rgba(168, 238, 69, .075), rgba(74, 150, 255, .035) 62%, #0a0f15);
  box-shadow: inset 0 0 0 1px rgba(168, 238, 69, .1), 0 10px 30px rgba(0, 0, 0, .18);
}
.building-library-card.pending { border-color: #2d7182; background: rgba(103, 232, 249, .045); }
.building-library-card:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.building-library-marker {
  padding: 13px 7px 13px 0;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  color: #566574;
}
.building-library-marker i {
  width: 20px;
  height: 20px;
  position: relative;
  display: block;
  border: 1px solid #445362;
  border-radius: 3px;
  transform: rotate(30deg) skew(-8deg, -8deg);
  box-shadow: inset 5px 0 0 rgba(74, 150, 255, .08), inset 0 5px 0 rgba(168, 238, 69, .05);
}
.building-library-marker b { font: 7px/1 monospace; letter-spacing: .08em; }
.building-library-card.active .building-library-marker { color: var(--lime); border-color: rgba(168, 238, 69, .16); }
.building-library-card.active .building-library-marker i {
  border-color: var(--lime);
  box-shadow: inset 5px 0 0 rgba(74, 150, 255, .14), inset 0 5px 0 rgba(168, 238, 69, .12), 0 0 12px rgba(168, 238, 69, .12);
}
.building-library-panel.is-loading .building-library-card.pending .building-library-marker i { animation: library-pulse 900ms ease-in-out infinite alternate; }
@keyframes library-pulse { to { opacity: .45; transform: rotate(120deg) skew(-8deg, -8deg); } }
.building-library-copy { min-width: 0; padding: 12px 0 11px 10px; display: flex; flex-direction: column; align-items: flex-start; }
.building-library-copy > strong { margin-bottom: 5px; font-size: 14px; letter-spacing: -.015em; }
.building-library-copy > em {
  min-height: 33px;
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.building-library-stats {
  width: 100%;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.building-library-stats > span { min-width: 0; display: grid; gap: 3px; }
.building-library-stats b { overflow: hidden; color: #dbe4eb; font: 9px/1.2 monospace; text-overflow: ellipsis; white-space: nowrap; }
.building-library-stats i { overflow: hidden; color: #667481; font: 7px/1.2 monospace; font-style: normal; letter-spacing: .05em; text-overflow: ellipsis; white-space: nowrap; }
.building-library-status {
  min-height: 31px;
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  color: #657481;
  font: 8px/1.5 monospace;
}
.building-library-status.loading { color: var(--cyan); }
.building-library-status.ok { color: var(--lime); }
.building-library-status.error { color: var(--danger); }
.building-empty-state {
  width: 100%;
  margin: auto;
  padding: 14px;
  color: #64727f;
  font: 9px/1.6 monospace;
  text-align: center;
}
.style-preset:disabled,
.roof-swatch:disabled,
#toggleGlazing:disabled,
[data-format]:disabled,
#copyCode:disabled,
#downloadNcm:disabled,
#downloadJson:disabled,
#downloadBom:disabled { cursor: not-allowed; opacity: .42; }

.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(18,24,32,.96), rgba(10,14,20,.96)); border-radius: var(--radius); box-shadow: 0 24px 80px rgba(0,0,0,.24); overflow: hidden; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(360px, .72fr); gap: 16px; align-items: stretch; }
.viewport-card, .code-card { min-height: 806px; }
.panel-head { min-height: 72px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head.compact { min-height: 68px; }
.panel-head .eyebrow { margin-bottom: 5px; }
.view-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
button { border: 0; cursor: pointer; }
button.quiet { padding: 8px 11px; border: 1px solid var(--line); background: #0b1118; border-radius: 8px; font-size: 11px; color: var(--muted); }
button.quiet:hover, button.quiet.active { border-color: #46632d; color: var(--lime); background: rgba(168,238,69,.06); }

.canvas-shell { height: 530px; position: relative; background: radial-gradient(circle at 48% 35%, #192637 0, #0b1017 58%, #080b10 100%); overflow: hidden; }
.canvas-shell::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(to bottom, transparent, black 40%, black); }
#preview { width: 100%; height: 100%; display: block; touch-action: none; }
.canvas-hud { position: absolute; pointer-events: none; display: grid; gap: 3px; font-size: 9px; letter-spacing: .1em; color: var(--muted); }
.canvas-hud strong { color: var(--text); font-size: 12px; }
.top-left { left: 18px; top: 16px; }
.bottom-left { left: 18px; bottom: 14px; }
.concept-reference {
  width: min(184px, 28%);
  margin: 0;
  padding: 5px;
  position: absolute;
  right: 16px;
  top: 16px;
  border: 1px solid rgba(168, 238, 69, .25);
  border-radius: 9px;
  background: rgba(7, 11, 16, .86);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.concept-reference[hidden] { display: none; }
.concept-reference img { width: 100%; aspect-ratio: 3 / 2; border-radius: 5px; display: block; object-fit: contain; background: #10151c; }
.concept-reference figcaption { padding: 6px 4px 1px; color: var(--lime); font: 7px/1.3 monospace; letter-spacing: .08em; }
.axis { position: absolute; right: 18px; bottom: 16px; width: 44px; height: 44px; font: 10px monospace; color: var(--muted); }
.axis span { position: absolute; }
.axis .x { right: 0; bottom: 3px; color: #ff6b72; }
.axis .y { left: 18px; top: 0; color: var(--lime); }
.axis .z { left: 0; bottom: 3px; color: var(--blue); }
.axis::before, .axis::after { content: ""; position: absolute; left: 20px; bottom: 10px; transform-origin: left; height: 1px; width: 20px; background: currentColor; }
.axis::before { transform: rotate(-28deg); }
.axis::after { transform: rotate(210deg); }

.style-lab { padding: 15px 18px 14px; border-top: 1px solid var(--line-soft); background: linear-gradient(90deg, rgba(168,238,69,.04), transparent 62%); }
.style-lab-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 11px; }
.style-lab-head > div { display: grid; gap: 3px; }
.style-lab-head .eyebrow { margin-bottom: 1px; }
.style-lab-head strong { font-size: 14px; }
.style-lab-head span:not(.style-policy) { color: var(--muted); font-size: 9px; line-height: 1.45; }
.style-policy { padding: 6px 8px; border: 1px solid var(--line-soft); border-radius: 999px; color: #6f7d8a; font: 8px monospace; letter-spacing: .08em; white-space: nowrap; }
.style-presets { display: grid; grid-template-columns: repeat(6, minmax(82px, 1fr)); gap: 7px; }
.style-preset { min-width: 0; min-height: 58px; padding: 8px 7px; border: 1px solid var(--line-soft); border-radius: 9px; background: #090e14; color: var(--muted); display: grid; align-content: center; justify-items: center; gap: 7px; }
.style-preset:hover, .style-preset.active { border-color: color-mix(in srgb, var(--style-accent), #fff 18%); color: var(--text); background: color-mix(in srgb, var(--style-accent), transparent 93%); }
.style-preset strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 9px; letter-spacing: .04em; }
.style-palette { width: 44px; height: 13px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid rgba(255,255,255,.14); border-radius: 4px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,.28); }
.style-palette span { min-width: 0; }
.style-material-grid { margin-top: 8px; padding-bottom: 3px; display: grid; grid-template-columns: repeat(7, minmax(178px, 1fr)); gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.style-material { min-width: 178px; padding: 6px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0a0f15; display: flex; align-items: center; gap: 8px; }
.style-material.recommended { border-style: dashed; opacity: .66; }
.style-material-model { flex: 0 0 82px; width: 82px; height: 60px; border: 1px solid var(--line-soft); border-radius: 6px; }
.style-material > span { min-width: 0; display: grid; gap: 2px; }
.style-material small { color: var(--lime); font: 7px monospace; letter-spacing: .08em; }
.style-material strong, .style-material em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-material strong { font-size: 8px; }
.style-material em { color: var(--muted); font-size: 7px; font-style: normal; }

.roof-lab { min-height: 104px; padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: linear-gradient(90deg, rgba(74,150,255,.045), transparent 58%); }
.roof-lab-copy { min-width: 166px; display: grid; gap: 3px; }
.roof-lab-copy .eyebrow { margin-bottom: 1px; }
.roof-lab-copy strong { font-size: 13px; }
.roof-lab-copy > span { color: var(--muted); font-size: 9px; line-height: 1.45; }
.roof-variants { display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.roof-swatch { width: 72px; flex: 0 0 72px; display: grid; justify-items: center; gap: 6px; padding: 6px 4px 5px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); }
.roof-swatch:hover, .roof-swatch.active { border-color: color-mix(in srgb, var(--tile-color), #fff 18%); background: color-mix(in srgb, var(--tile-color), transparent 89%); color: var(--text); }
.roof-model-preview { width: 58px; height: 44px; display: block; border: 1px solid var(--line-soft); border-radius: 7px; background: #080c11; }
.roof-swatch span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; }
.material-strip { min-height: 87px; padding: 12px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: thin; }
.material-chip { flex: 0 0 auto; display: grid; grid-template-columns: 62px auto; grid-template-rows: auto auto; gap: 1px 9px; align-items: center; border: 1px solid var(--line-soft); background: #0b1016; padding: 7px 9px 7px 7px; border-radius: 9px; }
.material-chip-model { width: 62px; height: 48px; border-radius: 6px; grid-row: 1 / span 2; border: 1px solid var(--line-soft); }
.material-chip b { font-size: 10px; }
.material-chip small { color: var(--muted); font: 9px monospace; }

.code-card { display: flex; flex-direction: column; }
.status-dot { color: var(--muted); font: 9px monospace; text-transform: uppercase; letter-spacing: .08em; }
.status-dot i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px var(--lime); }
.format-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 12px 14px 0; gap: 6px; }
.format-tabs button { min-height: 36px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0a0f15; color: var(--muted); font-size: 10px; }
.format-tabs button.active { color: var(--lime); border-color: #4e6b35; background: rgba(168,238,69,.06); }
.code-wrap { margin: 10px 14px 0; height: 244px; position: relative; }
#codeOutput { resize: none; width: 100%; height: 100%; padding: 17px 16px 62px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #070a0e; color: #b9f866; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
#codeOutput:focus-visible { border-color: #516b3a; box-shadow: 0 0 0 2px rgba(168,238,69,.14); }
.code-actions { position: absolute; right: 9px; bottom: 9px; display: flex; align-items: center; gap: 8px; }
.code-action-button { min-width: 66px; min-height: 40px; border-radius: 7px; padding: 8px 13px; font-size: 10px; font-weight: 750; }
.code-action-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.code-action-button:disabled { cursor: wait; opacity: .58; }
.load-button { border: 1px solid #2b6672; background: #0c1b21; color: var(--cyan); }
.load-button:hover:not(:disabled) { border-color: var(--cyan); background: rgba(103,232,249,.1); }
.copy-button { border: 1px solid #3d4b2e; background: #121b10; color: var(--lime); }
.copy-button:hover { border-color: var(--lime); background: rgba(168,238,69,.1); }
.code-load-status { min-height: 18px; margin: 8px 16px 0; color: var(--muted); font: 9px/1.5 monospace; }
.code-load-status.ok { color: var(--lime); }
.code-load-status.error { color: var(--danger); }
.format-note { min-height: 48px; margin: 10px 16px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 10px 14px 0; }
.metric { min-height: 65px; padding: 10px 11px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0a0f15; display: grid; align-content: center; gap: 4px; }
.metric strong { color: var(--text); font-size: 15px; }
.metric span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.metric.good strong { color: var(--lime); }
.primary-actions { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; margin: 13px 14px 0; }
button.primary, button.secondary { min-height: 42px; border-radius: 9px; font-weight: 700; font-size: 11px; }
button.primary { background: var(--lime); color: #101609; }
button.primary:hover { filter: brightness(1.08); }
button.secondary { border: 1px solid var(--line); background: #111821; color: var(--text); }
.integrity { margin: 13px 14px 16px; padding: 10px 11px; border: 1px solid var(--line-soft); background: #090e14; border-radius: 9px; display: grid; gap: 4px; }
.integrity span { color: var(--muted); font-size: 8px; letter-spacing: .12em; }
.integrity code { color: var(--cyan); font-size: 9px; overflow-wrap: anywhere; }

.materials-workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(350px, .55fr); gap: 16px; margin-top: 16px; }
.bom-panel, .tile-recipe-panel { min-height: 560px; }
.bom-head-actions { display: flex; align-items: center; gap: 9px; }
.catalog-version, .tile-id { color: var(--cyan); border: 1px solid #244754; background: rgba(103,232,249,.045); padding: 7px 9px; border-radius: 999px; font: 8px monospace; letter-spacing: .1em; white-space: nowrap; }
button.secondary.small { min-height: 34px; padding: 0 12px; }
.bom-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 16px 4px; }
.bom-summary-item { min-height: 66px; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: #0a0f15; display: grid; align-content: center; gap: 4px; }
.bom-summary-item strong { font: 16px monospace; }
.bom-summary-item span { color: var(--muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.bom-summary-item.good strong { color: var(--lime); }
.bom-summary-item.blue strong { color: var(--blue); }
.bom-summary-item.amber strong { color: var(--amber); }
.bom-toolbar { display: flex; gap: 6px; padding: 13px 16px 9px; overflow-x: auto; scrollbar-width: thin; }
.bom-toolbar button { min-width: 50px; padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 999px; background: #0a0f15; color: var(--muted); font-size: 9px; white-space: nowrap; }
.bom-toolbar button:hover, .bom-toolbar button.active { color: var(--lime); border-color: #4e6b35; background: rgba(168,238,69,.06); }
.bom-table { margin: 0 16px; border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; }
.bom-table-head, .bom-row { display: grid; grid-template-columns: minmax(200px, 1fr) 118px 100px; align-items: center; column-gap: 12px; }
.bom-table-head { min-height: 34px; padding: 0 12px; background: #080c11; color: #65717e; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
#bomRows { max-height: 282px; overflow-y: auto; scrollbar-width: thin; }
.bom-row { min-height: 54px; padding: 7px 12px; border-top: 1px solid var(--line-soft); background: rgba(10,15,21,.68); }
.bom-row:hover { background: rgba(22,31,41,.7); }
.bom-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.bom-identity > i { flex: 0 0 27px; width: 27px; height: 27px; border-radius: 6px; box-shadow: inset 0 1px rgba(255,255,255,.2); }
.bom-identity > span { min-width: 0; display: grid; gap: 3px; }
.bom-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.bom-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 8px monospace; }
.bom-amount { color: var(--text); font: 11px monospace; }
.bom-stage { width: max-content; padding: 5px 7px; border-radius: 999px; font-size: 8px; }
.bom-stage.available { color: var(--lime); background: rgba(168,238,69,.07); border: 1px solid #3b522b; }
.bom-stage.gated { color: var(--amber); background: rgba(255,189,98,.07); border: 1px solid #55422b; }
.bom-footnote { margin: 11px 16px 15px; color: var(--muted); font-size: 9px; line-height: 1.6; }

.tile-recipe-panel { position: relative; }
.tile-preview { --tile-color: #4f91d8; --tile-accent: #84c8ff; height: 150px; margin: 18px 18px 12px; position: relative; border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 50% 25%, color-mix(in srgb, var(--tile-color), transparent 70%), transparent 55%), #090d13; }
.tile-preview::after { content: "GLAZED TILE / MATERIAL COLOR"; position: absolute; left: 12px; bottom: 10px; color: rgba(255,255,255,.34); font: 8px monospace; letter-spacing: .12em; }
.tile-preview i { position: absolute; width: 74px; height: 56px; border-radius: 10px 10px 15px 15px; transform: rotate(-10deg) skewY(4deg); background: linear-gradient(145deg, var(--tile-accent), var(--tile-color) 48%, color-mix(in srgb, var(--tile-color), #000 34%)); border: 1px solid color-mix(in srgb, var(--tile-accent), transparent 45%); box-shadow: inset 0 2px rgba(255,255,255,.22), 0 12px 22px rgba(0,0,0,.32); }
.tile-preview i::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, transparent 31%, rgba(0,0,0,.18) 32%, transparent 34%, transparent 65%, rgba(0,0,0,.18) 66%, transparent 68%); }
.tile-preview i:nth-child(1) { left: 9%; top: 24px; }
.tile-preview i:nth-child(2) { left: 30%; top: 15px; }
.tile-preview i:nth-child(3) { left: 51%; top: 24px; }
.tile-preview i:nth-child(4) { left: 20%; top: 67px; }
.tile-preview i:nth-child(5) { left: 41%; top: 58px; }
.tile-preview i:nth-child(6) { left: 62%; top: 67px; }
.tile-preview.emissive { box-shadow: inset 0 0 38px color-mix(in srgb, var(--tile-color), transparent 52%), 0 0 26px color-mix(in srgb, var(--tile-color), transparent 70%); }
.recipe-detail { margin: 0 18px; border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; }
.recipe-detail > div { min-height: 49px; display: grid; align-content: center; gap: 4px; padding: 8px 11px; background: #0a0f15; }
.recipe-detail > div + div { border-top: 1px solid var(--line-soft); }
.recipe-detail span { color: var(--muted); font-size: 8px; letter-spacing: .09em; text-transform: uppercase; }
.recipe-detail strong { font-size: 10px; line-height: 1.45; }
.heat-track { height: 48px; margin: 15px 26px 6px; position: relative; display: grid; grid-template-columns: repeat(4, 1fr); color: var(--muted); font: 8px monospace; text-align: center; }
.heat-track::before { content: ""; position: absolute; left: 10%; right: 10%; top: 34px; height: 2px; background: linear-gradient(90deg, #7dc9a8, #e3bd69, #ef865e, #ef4d57); }
.heat-track small { color: #596675; font-size: 7px; }
.heat-track i { position: absolute; width: 10px; height: 10px; top: 30px; margin-left: calc(12.5% - 5px); border-radius: 50%; background: #fff; box-shadow: 0 0 12px var(--amber); transition: left .25s ease; }
.recipe-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 5px 18px 0; }
.recipe-stats div { min-height: 55px; padding: 9px; border: 1px solid var(--line-soft); border-radius: 9px; background: #090e14; display: grid; align-content: center; gap: 4px; }
.recipe-stats strong { font: 13px monospace; color: var(--cyan); }
.recipe-stats span { color: var(--muted); font-size: 8px; }
.tile-recipe-panel > p { margin: 13px 18px 17px; color: var(--muted); font-size: 9px; line-height: 1.6; }

.building-model-catalog-panel { margin-top: 16px; }
.model-catalog-head-meta { display: flex; align-items: center; gap: 8px; }
.model-catalog-head-meta span, .model-catalog-head-meta a { padding: 7px 9px; border: 1px solid #244754; border-radius: 999px; color: var(--cyan); background: rgba(103,232,249,.045); font: 8px monospace; letter-spacing: .08em; text-decoration: none; white-space: nowrap; }
.model-catalog-head-meta a:hover { color: var(--lime); border-color: #46632d; }
.model-catalog-intro { padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.model-catalog-intro > p { max-width: 760px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.model-catalog-filters { display: flex; justify-content: flex-end; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.model-catalog-filters button { flex: 0 0 auto; min-height: 31px; padding: 0 10px; border: 1px solid var(--line-soft); border-radius: 999px; background: #090e14; color: var(--muted); font-size: 8px; white-space: nowrap; }
.model-catalog-filters button:hover, .model-catalog-filters button.active { color: var(--lime); border-color: #4e6b35; background: rgba(168,238,69,.06); }
.building-model-catalog { padding: 6px 16px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 9px; }
.model-material-card { min-width: 0; min-height: 166px; display: grid; grid-template-columns: 176px minmax(0, 1fr); border: 1px solid var(--line-soft); border-radius: 11px; overflow: hidden; background: linear-gradient(145deg, #0b1118, #080c11); }
.model-material-card.is-style { border-color: #304431; }
.model-material-card.is-used { box-shadow: inset 0 0 0 1px rgba(168,238,69,.08); }
.model-material-visual { position: relative; min-height: 132px; border-right: 1px solid var(--line-soft); background: #080c11; }
.catalog-material-model { display: block; width: 100%; height: 132px; }
.model-material-visual > span { position: absolute; left: 8px; top: 8px; padding: 4px 6px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; background: rgba(4,7,10,.72); color: #bac7d2; font: 7px monospace; letter-spacing: .08em; }
.model-material-body { min-width: 0; padding: 11px; }
.model-material-body h3 { margin: 8px 0 5px; font-size: 11px; }
.model-material-tags { min-height: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.model-material-tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 6px; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); font: 7px monospace; letter-spacing: .06em; }
.model-material-tag.role { color: var(--cyan); }
.model-material-tag.formal { color: var(--lime); border-color: #344d2a; }
.model-material-tag.placeholder { color: var(--amber); border-color: #55422b; }
.model-material-tag.used { color: #101609; border-color: var(--lime); background: var(--lime); }
.model-material-geometry { margin: 0 0 6px; color: #bac5cf; font: 8px/1.45 monospace; }
.model-material-usage { margin: 0 0 8px; color: var(--muted); font-size: 8px; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.model-material-meta { margin: 0; display: grid; gap: 4px; }
.model-material-meta > div { min-width: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 6px; }
.model-material-meta dt { color: #64717e; font: 7px monospace; letter-spacing: .07em; }
.model-material-meta dd { margin: 0; color: #aeb9c4; font-size: 7px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-catalog-footnote { margin: 0 16px 15px; color: #65717e; font-size: 8px; line-height: 1.5; }

.lower-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 16px; margin: 16px 0 42px; }
.pda-panel, .boundary-panel { min-height: 260px; padding-bottom: 18px; }
.pda-panel > p { margin: 17px 20px 14px; color: var(--muted); line-height: 1.65; font-size: 12px; }
.rpc-grid { margin: 0 20px; display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 8px; align-items: end; }
label { display: grid; gap: 6px; }
label span { color: var(--muted); font-size: 8px; letter-spacing: .1em; }
input { min-width: 0; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #080c11; color: var(--text); padding: 0 11px; outline: none; font-size: 11px; }
input:focus { border-color: var(--blue); }
.rpc-grid .primary { padding: 0 16px; }
#pdaStatus { display: block; margin: 13px 20px 0; color: var(--muted); font: 10px/1.5 monospace; }
#pdaStatus.error { color: var(--danger); }
#pdaStatus.ok { color: var(--lime); }
.boundary-panel { padding: 22px; }
.boundary-panel h2 { margin-bottom: 16px; }
.boundary-panel ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.75; }
.boundary-panel li + li { margin-top: 7px; }
.boundary-panel b { color: var(--text); }

footer { min-height: 74px; padding: 0 clamp(18px, 3vw, 52px); border-top: 1px solid var(--line-soft); color: #65717e; display: flex; align-items: center; justify-content: space-between; gap: 20px; font: 9px monospace; letter-spacing: .08em; }

@media (max-width: 1080px) {
  .runtime-badges span:not(:last-child), .flow { display: none; }
  .workspace, .materials-workspace, .lower-grid { grid-template-columns: 1fr; }
  .viewport-card { min-height: auto; }
  .code-card { min-height: 650px; }
  .rpc-grid { grid-template-columns: 1fr 1fr; }
  .rpc-grid button { grid-column: 1 / -1; }
  .model-catalog-intro { align-items: flex-start; flex-direction: column; }
  .model-catalog-filters { width: 100%; justify-content: flex-start; }
}

@media (max-width: 900px) {
  .builder-shell { grid-template-columns: 1fr; }
  .building-library-panel { height: auto; min-height: 0; max-height: none; position: relative; top: auto; }
  .building-library-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .building-library-browser { grid-template-columns: 1fr; }
  .building-category-list {
    padding: 7px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .building-category-button { flex: 0 0 142px; min-height: 42px; }
  .building-library-column { min-height: 220px; max-height: 320px; }
  .building-library-list { overflow-x: hidden; overflow-y: auto; }
  .building-library-card { min-height: 132px; }
}

@media (max-width: 680px) {
  .topbar { height: 66px; }
  .brand small, .runtime-badges { display: none; }
  .topbar-tools { gap: 0; }
  main { width: calc(100% - 20px); }
  .intro { min-height: 190px; padding: 30px 4px 22px; }
  h1 { font-size: 34px; }
  .lede { font-size: 12px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-head.compact { flex-direction: row; align-items: center; }
  .building-library-intro { grid-template-columns: 1fr; align-items: start; gap: 5px; }
  .view-actions { justify-content: flex-start; }
  .canvas-shell { height: 430px; }
  .concept-reference { width: 132px; right: 10px; top: 10px; }
  .style-lab-head { flex-direction: column; gap: 8px; }
  .style-presets { display: flex; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
  .style-preset { flex: 0 0 92px; }
  .style-material-grid { grid-template-columns: repeat(7, 178px); }
  .roof-lab { align-items: flex-start; flex-direction: column; }
  .roof-variants { width: 100%; justify-content: flex-start; }
  .workspace { gap: 10px; }
  .bom-head-actions { width: 100%; justify-content: space-between; }
  .bom-summary { grid-template-columns: repeat(2, 1fr); }
  .bom-table-head, .bom-row { grid-template-columns: minmax(145px, 1fr) 82px; }
  .bom-table-head span:last-child, .bom-stage { display: none; }
  .format-tabs button { font-size: 9px; }
  .rpc-grid { grid-template-columns: 1fr; }
  .rpc-grid button { grid-column: auto; }
  .devnet { display: none; }
  .model-catalog-head-meta { width: 100%; justify-content: space-between; }
  .building-model-catalog { grid-template-columns: 1fr; padding-inline: 10px; }
  .model-material-card { grid-template-columns: 128px minmax(0, 1fr); }
  .model-material-visual { min-height: 128px; }
  .catalog-material-model { height: 128px; }
  footer { flex-direction: column; align-items: flex-start; justify-content: center; }
}

@media (max-width: 430px) {
  .building-category-button { flex-basis: 124px; }
  .model-material-card { grid-template-columns: 1fr; }
  .model-material-visual { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .catalog-material-model { height: 150px; }
}
