.cad-preview {
  margin: 22px 0 18px;
  border: 1px solid #b7c7d6;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}
.cad-preview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid #d8e0ea;
}
.cad-preview-heading h2 { margin: 0 0 6px; }
.cad-preview-heading p { font-size: 13px; }
.cad-preview-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cad-preview-tools button, .cad-template-button, .preview-link, .cad-layer-row input { font-family: inherit; cursor: pointer; }
.cad-preview-tools button {
  border: 1px solid #9fb0c0;
  background: #fff;
  color: #17324a;
  border-radius: 4px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-weight: 700;
}
.cad-preview-tools button[aria-pressed="true"] { background: #0f766e; color: #fff; border-color: #0f766e; }
.cad-preview-workspace { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 520px; }
.cad-template-picker {
  background: #f8fafc;
  border-right: 1px solid #d8e0ea;
  padding: 12px;
  overflow: auto;
  max-height: 520px;
}
.cad-picker-label { font-size: 12px; font-weight: 700; color: #52616d; margin: 0 0 8px; }
.cad-template-list, .cad-layer-list { display: grid; gap: 6px; }
.cad-template-button {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 8px;
}
.cad-template-button[aria-pressed="true"] { border-color: #0f766e; box-shadow: inset 3px 0 #0f766e; background: #ecfdf5; }
.cad-template-button span { font-size: 11px; color: #64748b; }
.cad-layer-panel, .cad-entity-panel { margin-top: 16px; padding-top: 14px; border-top: 1px solid #d8e0ea; }
.cad-layer-row { display: grid; grid-template-columns: 16px 15px minmax(0, 1fr); align-items: center; gap: 7px; padding: 5px 4px; border-radius: 3px; font-size: 11px; color: #334155; }
.cad-layer-row:hover { background: #eaf1f7; }
.cad-layer-swatch { width: 13px; height: 13px; border-radius: 2px; border: 1px solid rgba(15, 23, 42, .32); }
.cad-layer-row code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; }
.cad-layer-row small { display: block; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cad-entity-panel { color: #52616d; font-size: 11px; line-height: 1.5; }
.cad-entity-facts { display: grid; gap: 5px; margin: 0; }
.cad-entity-facts div { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 6px; }
.cad-entity-facts dt { color: #64748b; }
.cad-entity-facts dd { margin: 0; overflow-wrap: anywhere; color: #17212b; }
.cad-stage-column { display: block; min-width: 0; }
.cad-stage {
  width: 100%;
  aspect-ratio: 841 / 594;
  min-height: 0;
  background-color: #fff;
  background-image: linear-gradient(#e8eef4 1px, transparent 1px), linear-gradient(90deg, #e8eef4 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
}
.cad-preview[data-cad-theme="dark"] .cad-stage {
  background-color: #17212b;
  background-image: linear-gradient(rgba(148, 163, 184, .17) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, .17) 1px, transparent 1px);
}
.cad-stage canvas { display: block; }
.cad-preview-meta { display: grid; gap: 4px; padding: 10px 14px; border-top: 1px solid #d8e0ea; background: #fbfdff; font-size: 12px; color: #52616d; }
.cad-preview-meta strong { color: #17324a; }
.cad-preview-meta [data-preview-status][data-tone="error"] { color: #b42318; }
.cad-preview-meta [data-preview-status][data-tone="port"] { color: #be123c; }
.cad-preview-meta [data-preview-status][data-tone="entity"] { color: #075985; }
.preview-link { border: 0; background: transparent; color: #075985; padding: 0; font-size: 12px; }
.preview-link:hover { text-decoration: underline; }
@media(max-width:760px) {
  .cad-preview-heading { display: block; }
  .cad-preview-tools { margin-top: 12px; }
  .cad-preview-workspace { grid-template-columns: 1fr; }
  .cad-template-picker { border-right: 0; border-bottom: 1px solid #d8e0ea; max-height: 290px; }
  .cad-stage { min-height: 0; }
}
