/* The editing surface represents a narrow embedded form, independently of the monitor. */
.editor-shell:has(.editor-build) {
  display: flex; flex-direction: column; min-height: 100dvh;
}
.editor-content.editor-build {
  display: flex; flex: 1; flex-direction: column; width: 100%; max-width: none; padding: 0;
}
.editor-build > .workspace-tabs {
  box-sizing: border-box; width: 100%; max-width: var(--editor-content-width);
  margin: 0 auto; padding-inline: var(--editor-gutter); border-bottom: 0;
}
.editor-build > .canvas-panel {
  display: flex; flex: 1; flex-direction: column; min-width: 0;
}
.builder-stage {
  --stage-background: #eef0f3;
  --sheet-gap: clamp(28px, 3vw, 52px);
  --caption-height: 44px;
  --form-text: var(--form-text-color);
  position: relative;
  isolation: isolate;
  flex: 1;
  overflow: clip;
  min-height: 60vh;
  padding: 8px 0 48px;
  background: var(--stage-background);
  border-block: 1px solid #dce0e7;
}
.builder-lane {
  container: builder-lane / inline-size;
  position: relative;
  width: min(640px, var(--form-width, 640px), calc(100% - 28px));
  margin-inline: auto;
}
.builder-stage .builder-sheet {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 0;
  border-radius: var(--form-radius, 10px);
  background: var(--form-surface-background, #fff);
}
.builder-stage .builder-sheet:not(:where(.form-outlined)) {
  padding: clamp(14px, 3.5cqw, 28px) clamp(8px, 2.5cqw, 22px);
  border: 0;
  box-shadow: 0 2px 7px #26344212, 0 0 0 1px #24345110;
}
.builder-lane:has(.form-canvas.form-outlined) {
  width: min(var(--form-width), calc(100% - 28px));
}
.builder-sheets { position: relative; }
.builder-sheet-caption, .neighbor-caption {
  display: flex;
  align-items: center;
  min-height: var(--caption-height);
  color: #586373;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}
.builder-sheet-caption {
  position: sticky; top: 0; z-index: 7;
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 4px 8px;
  padding-block: 4px 6px; background: var(--stage-background);
}
.builder-page-picker, .builder-insert-tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.builder-page-picker h2 {
  margin: 0; font-size: 14px; color: #374252; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.builder-page-picker select {
  min-width: 0; max-width: 100%; padding: 5px 4px; font: inherit; color: #374252;
  border: 1px solid #cbd0da; border-radius: 6px; background: #fff; text-overflow: ellipsis;
}
.builder-sheet-caption .add-page-button { flex: none; width: 30px; padding-inline: 0; font-size: 16px; }
.builder-sheet-caption :is(.add-page-button, select, .button, summary) { min-height: 32px; }
.builder-insert-tools .button { padding: 5px 9px; font-size: 12px; white-space: nowrap; }
.builder-page-options { position: relative; flex: none; z-index: 6; }
.builder-page-options summary {
  list-style: none; cursor: pointer; padding: 7px 10px; border-radius: 6px;
  color: #525b6c; font-size: 12px;
}
.builder-page-options summary::-webkit-details-marker { display: none; }
.builder-page-options summary:hover, .builder-page-options[open] summary { background: #e0e4e9; }
.page-option-list {
  position: absolute; right: 0; top: 100%; width: 216px; padding: 9px;
  background: #fff; border: 1px solid #dce0e7; border-radius: 9px;
  box-shadow: 0 5px 24px #27324925;
}
.page-option-list label { display: grid; gap: 5px; padding: 5px; font-size: 12px; color: #505c6a; }
.page-option-list select { width: 100%; padding: 5px; font: inherit; }
.page-option-list button { display: block; width: 100%; border: 0; padding: 8px; text-align: left; background: transparent; font: inherit; font-size: 12px; }
.page-option-list button:hover:not(:disabled) { background: #f3f2fb; }
.builder-neighbor {
  position: absolute;
  top: calc(0px - var(--caption-height));
  width: 100%;
  max-height: 100%;
  padding-top: var(--caption-height);
  overflow: hidden;
  border-radius: 0 0 10px 10px;
}
.builder-neighbor.previous { right: calc(100% + var(--sheet-gap)); }
.builder-neighbor.next { left: calc(100% + var(--sheet-gap)); }
.builder-neighbor .builder-sheet { opacity: .5; transition: opacity .15s; }
.builder-neighbor:hover .builder-sheet, .builder-neighbor:focus-within .builder-sheet { opacity: .82; }
.neighbor-action {
  position: absolute; inset: 0; z-index: 1; width: 100%;
  border: 0; background: transparent; padding: 0; cursor: pointer;
}
.neighbor-action:focus-visible { outline: 3px solid var(--accent, #6658e8); outline-offset: -3px; }
.neighbor-caption { position: absolute; inset: 0 4px auto; gap: .35em; font-size: 12px; }
.previous .neighbor-caption { justify-content: end; }
.builder-add-row {
  display: block; margin: 14px auto 0; background: transparent;
  border: 1px dashed #acb4c2; border-radius: 6px; padding: 7px 18px; color: #525e70;
}
.builder-empty-page { padding: 24px; text-align: center; }
.builder-sheet .row-container { position: relative; padding: 0; margin: 0; border: 0; }
.builder-sheet .row-container.selected { outline: 1px dashed #9b8cd7; outline-offset: 2px; }
.builder-sheet .row-toolbar {
  position: absolute; top: 0; right: calc(100% + 4px); z-index: 3;
  flex-flow: column; gap: 0; padding: 2px; min-height: 0;
  background: #fff; border: 1px solid #dedfe9; border-radius: 5px;
  opacity: 0; pointer-events: none;
}
.builder-sheet .row-toolbar > div { display: flex; flex-direction: column; }
.builder-sheet .row-container:is(:hover,:focus-within,.selected) > .row-toolbar { opacity: 1; pointer-events: auto; }
.builder-sheet .form-row { gap: 22px; }
.builder-sheet .form-column { min-width: 0; min-height: 0; gap: 0; }
.builder-sheet .field-card {
  margin: 0 0 22px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; box-shadow: none; color: var(--field-text, var(--form-text-color));
}
.builder-sheet .field-card:is(:hover,:focus-within,.selected) {
  outline: 1px solid #9a8be0; outline-offset: 4px; z-index: 2;
}
.builder-sheet .field-card .field-actions {
  position: absolute; right: 0; bottom: -18px; z-index: 5;
  margin: 0; padding: 1px 3px; min-height: 0; flex-wrap: wrap;
  border: 1px solid #d9d3eb; border-radius: 6px; background: #fff;
}
.builder-sheet .field-type { display: none; }
.builder-sheet .field-card .field-actions .icon-button { min-width: 23px; min-height: 23px; font: 12px/1.2 system-ui, sans-serif; padding: 2px 4px; }
.builder-sheet .column-add:not(.empty-column) {
  position: absolute; bottom: 0; right: 0; width: auto; margin: 0;
  padding: 1px 5px; min-height: 17px; opacity: 0; pointer-events: none;
}
.builder-sheet .form-column { position: relative; }
.builder-sheet .form-column:is(:hover,:focus-within) > .column-add { opacity: 1; pointer-events: auto; }
.builder-sheet .empty-column { border: 1px dashed #b9b0d9; padding: 12px; margin: 0 0 18px; color: #716190; }
.builder-sheet .field-select .render-field { margin: 0; }
.builder-sheet .field-card .inline-edit {
  font-family: inherit; font-size: 16px; line-height: 1.5;
  padding: 0; border: 0; color: var(--field-text, var(--form-text-color)); border-radius: 3px;
}
.builder-sheet .field-card .field-card-label { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.builder-sheet .inline-choices { gap: 4px; }
.builder-sheet .inline-choice { align-items: baseline; padding: 0; }
.builder-sheet .inline-choice > i, .builder-sheet .checkbox-sample > i { width: 17px; height: 17px; align-self: flex-start; margin-top: 4px; }
.builder-sheet .inline-choice-label { overflow: hidden; }
.builder-sheet .inline-choice-add { display: none; }
.builder-sheet .field-card:is(:hover,:focus-within,.selected) .inline-choice-add { display: block; }
.builder-sheet .field-card .input-sample {
  min-height: 44px; padding: 9px 12px; align-items: center;
  background: var(--form-field-background); color: var(--form-text-color); border: 1px solid #e4e5ee; border-radius: 6px;
}
.builder-sheet .field-card .inline-placeholder { color: var(--form-placeholder); font-size: 16px; }
.builder-sheet.form-outlined .field-card .input-sample {
  border-color: color-mix(in srgb, var(--form-text-color) 48%, var(--form-surface-background));
  padding: .6rem .75rem; border-radius: .4rem; min-height: 2.85rem;
}
.builder-sheet.form-outlined .content-field textarea.inline-edit {
  padding: 0; border: 0; min-height: 0; background: transparent; resize: none;
}
.builder-sheet .field-select .field-help { margin: 0 0 8px; }
.builder-sheet .field-card .inline-help { font-size: 14px; color: var(--field-text, var(--form-secondary)); }
.builder-sheet .field-edit-extra, .builder-sheet .empty-description { display: none; }
.builder-sheet .field-card:is(.selected,:focus-within) :is(.field-edit-extra,.empty-description) { display: block; }
.builder-sheet .field-edit-extra { margin-top: 8px; }
.builder-sheet .field-edit-extra label { font-size: 12px; }
.builder-sheet .field-card:not(:hover,.selected,:focus-within) textarea.inline-edit::placeholder { color: transparent; }
.builder-sheet .choice-checked { background: var(--form-accent); border-color: var(--form-accent); box-shadow: inset 0 0 0 3px white; }
.builder-sheet .inline-choices-horizontal { flex-direction: row; flex-wrap: wrap; }
.builder-sheet .inline-choices-horizontal .inline-choice { max-width: 100%; }
.builder-rich-editor { position: relative; min-width: 0; flex: 1; }
.builder-rich-display { white-space: pre-wrap; overflow-wrap: anywhere; }
.builder-sheet .field-select { font-size: 16px; line-height: 1.5; }
.builder-sheet .builder-rich-display:has(.required-marker) .builder-authored-copy,
.builder-sheet .builder-rich-display:has(.required-marker) .builder-authored-copy > p:last-child { display: inline; }
.builder-sheet [data-field-text-color] .builder-rich-display [style*="color:"]:not(a, a *) { color: var(--field-text) !important; }
.builder-sheet .field-card .builder-rich-display p { margin: 0; color: inherit; font: inherit; line-height: 1.65; }
.builder-sheet .builder-rich-editor:not(:focus-within) > textarea { position: absolute; inset: 0; width: 100%; height: 100% !important; opacity: 0; }
.builder-rich-editor:focus-within .builder-rich-display { display: none; }
.builder-content-editor { position: relative; min-width: 0; }
.builder-content-editor [contenteditable] {
  cursor: text; min-height: 1.5em; overflow-wrap: anywhere; border-radius: 3px;
}
.builder-content-editor [contenteditable]:focus-visible {
  outline: 2px solid #7460c8; outline-offset: 3px;
}
.builder-sheet .builder-content-editor p { font-size: inherit; line-height: inherit; color: inherit; }
.builder-content-editor .content-formatting {
  display: none; align-items: center; gap: 2px;
  padding: 3px; background: white; color: #374252; border: 1px solid #d9d3eb;
  border-radius: 6px; box-shadow: 0 2px 8px #26344219;
}
.builder-sheet .content-formatting {
  position: absolute; z-index: 6; left: 0; bottom: calc(100% + 5px);
}
.builder-content-editor:focus-within .content-formatting,
.builder-tool .content-formatting { display: inline-flex; }
.content-formatting button {
  min-width: 30px; min-height: 30px; padding: 4px 7px; border: 0; border-radius: 3px;
  background: white; color: inherit; font: 14px/1.25 system-ui, sans-serif; cursor: pointer;
}
.content-formatting button:is(:hover,[aria-pressed="true"]) { color: #473189; background: #efebfa; }
.content-formatting button:focus-visible { outline: 2px solid #7460c8; }
.builder-tool .builder-content-editor [contenteditable] {
  margin: 0 0 6px; padding: 8px 10px; border: 1px solid #d9d3eb;
  min-height: 64px; font-size: 16px; line-height: 1.5;
}
.builder-sheet .field-card .inline-edit:focus-visible { outline: 2px solid #8570d2; outline-offset: 2px; }
@container builder-lane (max-width: 600px) {
  .builder-sheet .form-row, .builder-sheet .render-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@container builder-lane (max-width: 520px) {
  .builder-sheet-caption { grid-template-columns: minmax(0,1fr) auto; }
  .builder-page-options { grid-column: 2; grid-row: 1; }
  .builder-insert-tools { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
}
@media (max-width: 1040px) {
  .neighbor-caption span { display: none; }
}
@media (max-width: 760px) {
  .builder-neighbor { display: none; }
  .builder-stage { padding-top: 5px; }
  .builder-sheet .row-toolbar { top: -18px; right: auto; left: 0; flex-direction: row; }
  .builder-sheet .row-toolbar > div { flex-direction: row; }
}
@media (hover: none) {
  .builder-sheet .field-card:not(.selected):not(:focus-within) .field-actions { visibility: hidden; opacity: 0; }
  .builder-sheet .field-card:not(.selected):not(:focus-within) > .field-insert { opacity: 0; pointer-events: none; }
}
@media (max-width: 600px) {
  .builder-lane { width: min(var(--form-width, 640px), calc(100% - 16px)); }
  .builder-sheet .field-card .field-actions { bottom: -23px; }
}
@media (prefers-reduced-motion: reduce) {
  .builder-neighbor .builder-sheet { transition: none; }
}

/* Touch controls sit after the content so the first tap always reaches the field. */
@media (max-width: 760px) {
  .content-formatting button { min-height: 40px; min-width: 40px; }
  .builder-sheet .row-container { display: flex; flex-direction: column; }
  .builder-sheet .row-container > .row-toolbar {
    order: 1; align-self: flex-start; margin: 0 0 12px;
    top: 100%; left: 0; opacity: 0; pointer-events: none;
  }
  .builder-sheet .row-container:not(:focus-within,.selected,:has(.field-card.selected)) > .row-toolbar {
    opacity: 0; pointer-events: none;
  }
  .builder-sheet .row-container:is(:focus-within,.selected,:has(.field-card.selected)) > .row-toolbar {
    position: static; opacity: 1; pointer-events: auto;
  }
  .builder-sheet .row-toolbar button { min-width: 40px; min-height: 40px; }
  .builder-sheet .field-card { display: flex; flex-wrap: wrap; gap: 4px; }
  .builder-sheet .field-select { flex: 0 0 100%; min-width: 0; }
  .builder-sheet .field-card:not(.selected):not(:focus-within) > :is(.field-actions,.field-insert) {
    opacity: 0; pointer-events: none;
  }
  .builder-sheet .field-card:is(.selected,:focus-within) > .field-actions {
    position: static; flex: 0 0 100%; justify-content: flex-start;
    margin-top: 4px; padding: 0; border: 0; gap: 3px;
  }
  .builder-sheet .field-card .field-actions .icon-button { min-width: 40px; min-height: 44px; }
  .builder-sheet .field-card:is(.selected,:focus-within) > .field-insert {
    position: static; display: inline-flex; flex: 1 1 50px; justify-content: center; align-items: center;
    width: auto; height: 44px; border-radius: 5px; gap: 2px;
    box-shadow: none; font-size: 14px; color: #5e477e;
  }
  .builder-sheet .field-card > .field-insert::after { content: attr(data-side); font-size: 12px; text-transform: capitalize; }
  .builder-sheet .field-card > .field-insert:disabled { display: none; }
  .builder-sheet .form-column:not(:focus-within):not(.active-column) > .column-add:not(.empty-column) {
    opacity: 0; pointer-events: none;
  }
  .builder-sheet .form-column:is(:focus-within,.active-column) > .column-add:not(.empty-column) {
    position: static; align-self: flex-start; min-height: 40px; margin: 0 0 8px;
    opacity: 1; pointer-events: auto;
  }
}
