:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #edf2f5;
  --line: #d8e0e5;
  --text: #17212b;
  --muted: #657484;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --amber: #b7791f;
  --red: #b42318;
  --blueprint: #102d38;
  --blueprint-grid: #224652;
  --concrete: #f0bb55;
  --surface-line: #79d1cb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: #17212b;
  color: #ffffff;
  border-bottom: 1px solid #0f1720;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.topbar p {
  margin: 4px 0 0;
  color: #b8c3cc;
  font-size: 14px;
}

.server-state {
  min-width: 86px;
  padding: 6px 10px;
  border: 1px solid #3d4d5c;
  border-radius: 6px;
  color: #d7e2ea;
  text-align: center;
  font-size: 13px;
}

.server-state.ok {
  border-color: #2dd4bf;
  color: #99f6e4;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.editor-pane,
.result-pane {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.editor-pane > .toolbar { order: 0; }
.editor-pane > #inputHint { order: 1; }
.editor-pane > .stage-overview { order: 2; }
.editor-pane > .construction-overview { order: 3; }
.editor-pane > .draft-editor { order: 4; }
.editor-pane > .engineering-plan { order: 5; }
.editor-pane > .dev-tools { order: 6; }

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.workflow-state {
  margin-left: auto;
  color: var(--muted);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.workflow-state.draft-active {
  color: var(--teal-dark);
}

.draft-editor {
  flex: 0 0 auto;
  margin: 0 14px 14px;
  overflow: hidden;
  border: 1px solid #b9c9cf;
  border-radius: 8px;
  background: #f8fbfc;
}

.draft-editor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--line);
  background: #edf4f5;
}

.draft-editor-head h2 {
  margin: 3px 0 4px;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.draft-editor-head p {
  max-width: 580px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.draft-editor-head > strong {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #b8c9ce;
  border-radius: 4px;
  color: #36545e;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.draft-kicker {
  color: var(--teal-dark);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.draft-template-bar {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(260px, 2fr) auto auto;
  align-items: end;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.draft-template-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 8px;
}

.draft-template-fields > *,
.draft-template-bar > *,
.draft-context-panel > * {
  min-width: 0;
}

.draft-template-field,
.draft-tool-field,
.draft-coordinate {
  display: grid;
  gap: 4px;
}

.draft-template-field span,
.draft-tool-field span,
.draft-coordinate span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.draft-tools {
  display: flex;
  align-items: end;
  gap: 6px;
  padding: 9px 12px;
  overflow-x: auto;
  border-bottom: 1px solid #1b424e;
  background: #173946;
}

.draft-tools button,
.draft-tools select,
.draft-tools input {
  height: 32px;
  border-color: #45616b;
}

.draft-tools button {
  background: #204754;
  color: #d8e9ec;
}

.draft-tools button.active {
  background: var(--concrete);
  border-color: var(--concrete);
  color: #28220f;
}

.draft-tool-field {
  flex: 0 0 96px;
}

.draft-tool-field.snap-field {
  flex-basis: 116px;
}

.draft-tool-field span {
  color: #a9c0c7;
}

.draft-tool-divider {
  align-self: stretch;
  width: 1px;
  margin: 0 3px;
  background: #45616b;
}

.draft-mode-help {
  align-self: center;
  min-width: 220px;
  margin-right: auto;
  color: #b7cbd0;
  font-size: 11px;
}

.draft-layer-toggle {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #c4d6da;
  font-size: 11px;
  white-space: nowrap;
}

.draft-layer-toggle input {
  width: 16px;
  height: 16px;
}

.draft-board-wrap {
  position: relative;
  background: var(--blueprint);
}

#draftSvg {
  display: block;
  width: 100%;
  height: clamp(390px, 55vh, 680px);
  cursor: crosshair;
  touch-action: none;
}

.engineering-plan {
  margin: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.engineering-plan > summary {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.engineering-plan .geometry-preview {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.draft-board-bg {
  fill: url(#draft-grid);
}

.draft-grid-small {
  fill: none;
  stroke: #173a45;
  stroke-width: 1;
}

.draft-grid-major {
  fill: none;
  stroke: var(--blueprint-grid);
  stroke-width: 1.5;
}

.draft-axis {
  fill: none;
  stroke: var(--concrete);
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 8;
}

.draft-axis.wall {
  stroke: #f19c65;
}

.draft-axis.slab_boundary {
  stroke-dasharray: 16 8;
}

.draft-axis.selected-segment {
  stroke: #ffffff;
  stroke-width: 12;
}

.draft-axis.selected-element {
  stroke: #f7d58b;
  stroke-width: 12;
}

.draft-axis-hit {
  cursor: pointer;
  stroke: transparent;
  stroke-linecap: round;
  stroke-width: 34;
}

.draft-surface {
  stroke: var(--surface-line);
  stroke-dasharray: 10 7;
  stroke-width: 3;
  opacity: 0.82;
}

.draft-placement-line {
  pointer-events: none;
  stroke: #f4c95d;
  stroke-linecap: butt;
  stroke-width: 7;
  opacity: 0.96;
}

.draft-placement-line.node {
  stroke: #ef8c62;
}

.draft-placement-line.addon {
  stroke: #c59cff;
  stroke-dasharray: 5 3;
}

.draft-placement-joint {
  pointer-events: none;
  stroke: #102f39;
  stroke-width: 2;
}

.draft-point {
  cursor: pointer;
  fill: #eef8f8;
  stroke: #14313b;
  stroke-width: 4;
}

.draft-point:hover,
.draft-point.selected {
  fill: var(--concrete);
  stroke: #fff3d2;
}

.draft-point.pending {
  pointer-events: none;
  fill: #ffffff;
  stroke: var(--concrete);
  stroke-dasharray: 4 3;
}

.draft-point.move-target {
  fill: #8ce3dc;
  stroke: #d9fffc;
}

.draft-point-hit {
  cursor: pointer;
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
}

.draft-preview-line,
.draft-move-preview {
  pointer-events: none;
  stroke: #ffffff;
  stroke-dasharray: 14 8;
  stroke-linecap: round;
  stroke-width: 5;
}

.draft-move-preview {
  stroke: #8ce3dc;
}

.draft-interaction-layer {
  pointer-events: none;
}

.draft-snap-guide {
  pointer-events: none;
  stroke: #89e3dc;
  stroke-dasharray: 6 8;
  stroke-width: 2;
  opacity: 0.72;
}

.draft-snap-marker {
  pointer-events: none;
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
}

.draft-snap-marker.point,
.draft-snap-marker.intersection {
  stroke: var(--concrete);
}

.draft-snap-label {
  pointer-events: none;
  fill: #dffaf7;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  paint-order: stroke;
  stroke: var(--blueprint);
  stroke-width: 5px;
}

.draft-measure-label {
  pointer-events: none;
  fill: #fff4d6;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  paint-order: stroke;
  stroke: var(--blueprint);
  stroke-width: 6px;
}

.draft-node {
  pointer-events: none;
  fill: #e87058;
  stroke: #ffd7ce;
  stroke-width: 3;
}

.draft-node.cross {
  fill: #bd6ad8;
}

.draft-node-label,
.draft-pending-label {
  fill: #d8eaed;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.draft-empty-title,
.draft-empty-copy {
  fill: #dcebed;
  text-anchor: middle;
}

.draft-empty-title {
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 27px;
}

.draft-empty-copy {
  fill: #88a9b2;
  font-size: 18px;
}

.draft-board-legend {
  position: absolute;
  right: 10px;
  bottom: 9px;
  display: flex;
  gap: 12px;
  padding: 6px 8px;
  border: 1px solid #31515b;
  border-radius: 4px;
  background: rgba(10, 35, 44, 0.9);
  color: #b9cdd2;
  font-size: 10px;
}

.draft-board-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.draft-board-legend i {
  display: block;
  width: 18px;
  border-top: 3px solid var(--concrete);
}

.draft-board-legend i.surface {
  border-top: 2px dashed var(--surface-line);
}

.draft-board-legend i.placement {
  border-top-color: #f4c95d;
  border-top-width: 5px;
}

.draft-board-legend i.node {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 50%;
  background: #e87058;
}

.draft-inspector {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1.2fr);
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.draft-context {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.draft-context-empty {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 76px;
}

.draft-context-empty strong {
  font-size: 13px;
}

.draft-context-empty span {
  color: var(--muted);
  font-size: 12px;
}

.draft-context-panel {
  display: flex;
  align-items: end;
  gap: 8px;
  overflow-x: auto;
}

.draft-context-panel > label {
  display: grid;
  flex: 0 0 98px;
  gap: 4px;
}

.draft-context-panel > label span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.draft-context-title {
  display: grid;
  flex: 1 0 145px;
  align-self: center;
  gap: 3px;
}

.draft-context-title strong {
  font-size: 13px;
}

.draft-context-title span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.draft-context-panel button {
  flex: 0 0 auto;
}

.draft-editor[data-profile="touch"] .draft-tools button,
.draft-editor[data-profile="touch"] .draft-tools select,
.draft-editor[data-profile="touch"] .draft-context-panel button,
.draft-editor[data-profile="touch"] .draft-context-panel input,
.draft-editor[data-profile="touch"] .draft-context-panel select {
  min-height: 44px;
}

.draft-editor[data-profile="touch"] .draft-point-hit {
  r: 36;
}

.draft-editor[data-profile="touch"] #draftSvg {
  height: 340px;
}

.draft-point-editor {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 90px 90px auto;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.draft-point-editor > strong {
  align-self: center;
  font-size: 13px;
}

.draft-diagnostics {
  min-width: 0;
  padding: 10px 12px;
}

.draft-diagnostics-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: #38515a;
  font-size: 12px;
}

.draft-diagnostics-list {
  display: grid;
  gap: 6px;
  max-height: 124px;
  overflow: auto;
}

.draft-diagnostics-list p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.draft-diagnostic {
  display: grid;
  height: auto;
  padding: 7px 8px;
  border-left: 4px solid #7c8d94;
  border-radius: 3px;
  text-align: left;
}

.draft-diagnostic.blocking {
  border-left-color: var(--red);
}

.draft-diagnostic.info {
  border-left-color: var(--surface-line);
}

.draft-diagnostic:disabled {
  cursor: default;
  opacity: 1;
}

.draft-diagnostic strong {
  font-size: 10px;
}

.draft-diagnostic span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.draft-json-details {
  border-top: 1px solid var(--line);
}

.draft-json-details summary {
  padding: 8px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.draft-json-details pre {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #f4f7f8;
  font-size: 11px;
}

.stage-overview,
.construction-overview {
  flex: 0 0 auto;
  margin: 14px 14px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  overflow: hidden;
}

.dev-tools {
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.dev-tools summary {
  padding: 9px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dev-tools-body {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.dev-json {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.construction-actions {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.stage-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  overflow-x: auto;
  background: #ffffff;
}

.stage-tab {
  flex: 0 0 auto;
  height: 34px;
  min-width: 92px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #eef3f6;
  font-size: 13px;
}

.stage-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.stage-tab.add {
  min-width: 38px;
  width: 38px;
  padding: 0;
  color: var(--teal);
  font-size: 18px;
}

.stage-detail-line {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.stage-details-empty {
  padding: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.stage-detail-item {
  min-width: 0;
}

.stage-detail-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.stage-detail-item strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.stage-detail-line > span {
  color: var(--muted);
  font-size: 12px;
}

.construction-list {
  padding: 10px;
}

.construction-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.construction-tab {
  min-height: 36px;
  padding-inline: 14px;
  border-color: #b9c9cf;
  background: #f1f5f7;
  color: #29424b;
}

.construction-tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.construction-tab.disabled {
  opacity: 0.55;
  text-decoration: line-through;
}

.construction-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.construction-selected {
  padding: 0 10px 10px;
}

.construction-settings {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
}

.construction-settings > summary {
  padding: 9px 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.construction-settings-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
  border-top: 1px solid var(--line);
}

.construction-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.construction-table th,
.construction-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.construction-table th {
  color: var(--muted);
  background: #f6f8fa;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.construction-table th:nth-child(1) {
  width: auto;
}

.construction-table th:nth-child(2) {
  width: 68px;
}

.construction-table th:nth-child(3) {
  width: 42px;
}

.construction-table th:nth-child(4) {
  width: 86px;
}

.construction-table tbody tr {
  cursor: pointer;
  background: #ffffff;
}

.construction-table tbody tr.active {
  background: #e8f3f0;
  box-shadow: inset 3px 0 0 var(--teal);
}

.construction-table tbody tr.disabled {
  color: var(--muted);
  background: #f5f7f9;
}

.construction-table tbody tr.active.disabled {
  background: #eef3f2;
}

.construction-table .compact-input {
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
}

.construction-table .compact-input.quantity {
  width: 54px;
  padding: 0 2px 0 6px;
  text-align: right;
}

.construction-table .compact-toggle {
  justify-content: center;
  min-height: 30px;
  padding: 0;
}

.construction-table .compact-toggle input {
  width: 16px;
  height: 16px;
}

.construction-table button.subtle {
  width: 76px;
  padding: 0 8px;
}

.selected-construction-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.selected-construction-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.selected-construction-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.selected-construction-head span {
  color: var(--muted);
  font-size: 12px;
}

.selected-construction-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px;
  background: var(--line);
}

.selected-construction-body div {
  min-width: 0;
  padding: 7px 8px;
  background: #f8fafb;
}

.selected-construction-body span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.selected-construction-body strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.construction-parameter-editor {
  display: grid;
  gap: 8px;
}

.construction-parameter-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.construction-parameter-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.construction-parameter-empty {
  padding: 8px;
  border: 1px dashed #c7d1d9;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.construction-parameter-empty.compact {
  padding: 6px 8px;
  border-style: solid;
  background: #f8fafb;
  font-size: 11px;
}

.parameter-check {
  min-height: 36px;
}

.selected-construction-actions {
  display: flex;
  justify-content: flex-start;
}

.construction-elements {
  display: grid;
  gap: 8px;
}

.construction-element-list {
  display: grid;
  gap: 6px;
}

.construction-element-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 7px 9px;
  text-align: left;
}

.construction-element-row.active {
  border-color: var(--teal);
  background: #e8f3f0;
}

.construction-element-text {
  display: grid;
  min-width: 0;
}

.construction-element-text strong,
.construction-element-text span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.construction-element-text span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.construction-element-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.element-dialog {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(20, 33, 45, 0.22);
}

.element-dialog::backdrop {
  background: rgba(18, 27, 36, 0.32);
}

.element-dialog-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #ffffff;
}

.element-dialog-head,
.element-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.element-dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.element-dialog-body {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
}

.element-dialog-form,
.element-parameter-fields {
  display: grid;
  gap: 10px;
}

.element-preview-svg {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.element-preview-bg {
  fill: #f8fafb;
}

.element-preview-shape {
  fill: rgba(47, 132, 121, 0.12);
  stroke: var(--teal);
  stroke-width: 3;
}

.element-preview-attachment {
  fill: rgba(47, 132, 121, 0.14);
  stroke: var(--teal);
  stroke-width: 3;
}

.element-preview-line {
  stroke: var(--teal);
  stroke-width: 5;
  stroke-linecap: round;
}

.element-preview-base-line {
  stroke: #8fa1ad;
  stroke-width: 5;
  stroke-linecap: round;
}

.element-preview-joint-line {
  stroke: var(--amber);
  stroke-dasharray: 7 5;
  stroke-width: 3;
}

.element-preview-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
}

.element-preview-label.muted {
  fill: var(--muted);
  font-size: 12px;
}

.element-preview-label.side {
  text-anchor: start;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.field.small {
  flex: 0 0 auto;
}

.field span,
.json-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
button {
  height: 36px;
  border: 1px solid #c4ced6;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

select {
  width: 100%;
  padding: 0 10px;
}

input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #c4ced6;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

button {
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #8fa0ae;
}

button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

button.primary:hover {
  background: var(--teal-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.danger {
  border-color: #f2b8b5;
  color: var(--red);
}

button.subtle {
  height: 30px;
  background: #ffffff;
  font-size: 12px;
}

.json-label {
  padding: 14px 14px 8px;
}

.geometry-preview {
  flex: 0 0 auto;
  margin: 14px 14px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f6f8fa;
}

.preview-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.preview-header strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.plan-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.plan-mode-toggle .mode {
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.preview-header.sub {
  border-top: 1px solid var(--line);
}

#geometrySvg {
  display: block;
  width: 100%;
  height: 150px;
}

#elevationSvg {
  display: block;
  width: 100%;
  height: 230px;
}

.plan-bg,
.plan-empty-bg {
  fill: #ffffff;
}

.plan-segment-hit {
  cursor: pointer;
  stroke: transparent;
  stroke-linecap: round;
  stroke-width: 24;
}

.plan-segment {
  cursor: pointer;
  stroke: #2563eb;
  stroke-linecap: round;
  stroke-width: 7;
}

.plan-pour-arrow {
  pointer-events: none;
  stroke: #0f766e;
  stroke-linecap: round;
  stroke-width: 4;
}

.plan-pour-arrow-head {
  fill: #0f766e;
  pointer-events: none;
}

.plan-formwork-marker {
  pointer-events: none;
  stroke: #111827;
  stroke-linecap: butt;
  stroke-width: 5;
}

.plan-inner-segment {
  fill: none;
  stroke: #14b8a6;
  stroke-dasharray: 16 9;
  stroke-linecap: round;
  stroke-width: 6;
}

.plan-segment-group.selected .plan-segment {
  stroke: var(--teal);
  stroke-width: 10;
}

.plan-segment-group.construction-selected .plan-segment {
  stroke: #0f766e;
  stroke-width: 8;
}

.plan-segment-group.element-selected .plan-segment {
  stroke: #7c5b1f;
  stroke-width: 9;
}

.plan-segment-group.selected.construction-selected .plan-segment {
  stroke-width: 11;
}

.plan-segment-group.selected.element-selected .plan-segment {
  stroke-width: 12;
}

.plan-segment-group.warning-info .plan-segment {
  stroke: #64748b;
}

.plan-segment-group.warning-warning .plan-segment {
  stroke: var(--amber);
}

.plan-segment-group.warning-error .plan-segment,
.plan-segment-group.warning-blocking .plan-segment {
  stroke: var(--red);
}

.plan-segment-group.selected.warning-warning .plan-segment,
.plan-segment-group.selected.warning-error .plan-segment,
.plan-segment-group.selected.warning-blocking .plan-segment {
  stroke-width: 11;
}

.plan-label,
.plan-point-label {
  fill: #253443;
  font-size: 24px;
  font-weight: 700;
  paint-order: stroke;
  pointer-events: auto;
  stroke: #ffffff;
  stroke-width: 5px;
}

.plan-label {
  cursor: pointer;
  text-anchor: middle;
}

.plan-point {
  fill: #ffffff;
  stroke: #17212b;
  stroke-width: 3;
}

.segment-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.segment-summary > span,
.segment-summary div {
  min-height: 46px;
  padding: 8px 10px;
  background: #ffffff;
}

.segment-summary > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.segment-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.segment-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.elevation-bg {
  fill: #ffffff;
}

.elevation-axis,
.elevation-side-line {
  stroke: #c8d3db;
  stroke-width: 2;
}

.elevation-panel {
  fill: #d7ede9;
  stroke: var(--teal);
  stroke-width: 2;
}

.elevation-panel:nth-of-type(2n) {
  fill: #e7f1fb;
  stroke: #2563eb;
}

.elevation-panel.overhang {
  fill: #fff4cf;
  stroke: var(--amber);
}

.elevation-panel.junction-back-panel {
  stroke-width: 3;
}

.elevation-panel.addon,
.elevation-panel.addon.overhang {
  fill: #f3e8ff;
  stroke: #7e22ce;
  stroke-width: 3;
  stroke-dasharray: 7 4;
}

.addon-placement-row td {
  background: #faf5ff;
  color: #581c87;
}

.elevation-corner {
  fill: #fde68a;
  stroke: #b45309;
  stroke-width: 2.5;
}

.elevation-corner.inner {
  fill: #fecaca;
  stroke: #b91c1c;
}

.elevation-corner.outer {
  fill: #bfdbfe;
  stroke: #1d4ed8;
}

.elevation-corner.overhang {
  stroke-dasharray: 8 5;
}

.elevation-label,
.elevation-side-label,
.elevation-dimension {
  fill: #253443;
  font-size: 18px;
  font-weight: 700;
  dominant-baseline: middle;
  paint-order: stroke;
  pointer-events: none;
  stroke: #ffffff;
  stroke-width: 4px;
  text-anchor: middle;
}

.elevation-side-label,
.elevation-dimension {
  fill: var(--muted);
  font-size: 16px;
}

.elevation-side-label {
  text-anchor: start;
}

.elevation-side-label.element-row {
  font-size: 10px;
}

.elevation-dimension {
  text-anchor: start;
}

.elevation-label.narrow {
  font-size: 15px;
}

.elevation-label.corner {
  font-size: 14px;
}

.elevation-empty {
  fill: var(--muted);
  font-size: 22px;
  font-weight: 700;
  text-anchor: middle;
}

textarea {
  flex: 0 0 260px;
  min-height: 260px;
  margin: 0 14px;
  padding: 12px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #13202b;
  background: #fbfcfd;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.dev-tools textarea {
  flex: 0 0 auto;
  width: 100%;
  min-height: 220px;
  margin: 0;
  resize: vertical;
}

.dev-tools .json-label {
  padding: 0;
}

.hint {
  min-height: 32px;
  margin: 0;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.hint.error {
  color: var(--red);
}

.result-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.result-header h2 {
  margin: 0;
  font-size: 18px;
}

.result-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  padding: 6px 10px;
  border-radius: 999px;
  background: #dfe7ec;
  color: #3b4b58;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status.ok {
  background: #d1fae5;
  color: #065f46;
}

.status.ok_with_warnings {
  background: #fef3c7;
  color: var(--amber);
}

.status.failed {
  background: #fee4e2;
  color: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metrics div {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  overflow-x: auto;
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #eef3f6;
}

.tab.active {
  background: #ffffff;
  border-bottom-color: #ffffff;
}

.panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.panel.active {
  display: block;
}

.panel-tools {
  display: flex;
  align-items: end;
  gap: 6px;
  margin-bottom: 10px;
}

.panel-tools.wrap {
  flex-wrap: wrap;
  gap: 10px;
}

.mode {
  height: 32px;
  background: #eef3f6;
  font-size: 13px;
}

.mode.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.filter-field {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

.filter-field span,
.check-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.filter-field select {
  height: 32px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 4px;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.construction-toggle {
  align-items: center;
  height: 36px;
}

.empty {
  padding: 24px;
  border: 1px dashed #c7d1d9;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f6f8fa;
  color: #4a5a68;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table .group-row th {
  position: static;
  padding: 8px 10px;
  background: #e8f3f0;
  color: #0f766e;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.unfoldings-list {
  display: grid;
  gap: 14px;
}

.unfolding-stage,
.unfolding-construction {
  display: grid;
  gap: 10px;
}

.unfolding-stage {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.unfolding-stage:last-child {
  border-bottom: 0;
}

.unfolding-construction {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.unfolding-section-head,
.unfolding-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.unfolding-section-head h3,
.unfolding-section-head h4,
.unfolding-card-head h5 {
  margin: 0;
  color: #20303d;
}

.unfolding-section-head h3 {
  font-size: 16px;
}

.unfolding-section-head h4 {
  font-size: 14px;
}

.unfolding-card-head h5 {
  font-size: 13px;
}

.unfolding-section-head span,
.unfolding-card-head span,
.unfolding-card-meta,
.unfolding-unmapped-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.unfolding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 10px;
}

.unfolding-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid #d8e1e7;
  border-radius: 6px;
  background: #ffffff;
}

.unfolding-card-meta {
  margin-top: 4px;
  min-height: 16px;
}

.unfolding-svg {
  display: block;
  width: 100%;
  height: 210px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
}

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

.unfolding-unmapped-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f6f8fa;
}

.unfolding-unmapped-list strong {
  font-size: 13px;
}

pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1720;
  color: #d7e2ea;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .editor-pane,
  .result-pane {
    min-height: 520px;
  }

  .toolbar,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dev-tools-body {
    grid-template-columns: 1fr;
  }

  .draft-template-bar,
  .draft-inspector,
  .draft-point-editor {
    grid-template-columns: 1fr;
  }

  .draft-entry-options {
    grid-template-columns: 1fr;
  }

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

  .draft-point-editor {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .draft-context {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .draft-context-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .draft-tools {
    flex-wrap: wrap;
    align-items: center;
    overflow-x: visible;
  }

  .draft-tool-divider {
    display: none;
  }

  .draft-layer-toggle {
    flex: 1 1 180px;
  }

  .draft-context-title {
    grid-column: 1 / -1;
  }

  .draft-context-panel > label,
  .draft-context-panel button {
    width: 100%;
  }

  .draft-mode-help {
    display: none;
  }

  #draftSvg {
    height: 240px;
  }

  .draft-board-legend {
    display: none;
  }

  .element-dialog-body {
    grid-template-columns: 1fr;
  }

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

  .unfolding-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
