/*
 * askdown.dev builder — layout, editor, visual editor, JSON view.
 * Loaded on /builder and /forms/:id/edit only. Tokens come from site.css.
 */

.builder {
  --ed-font-size: 13.5px;
  --ed-line-height: 22px;
  --ed-pad: 12px;
  --split: 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100dvh - var(--header-h));
  background: var(--bg);
}

.builder:not(.builder--mounted) {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Toolbar
 * ------------------------------------------------------------------------- */

.bt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.55rem var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.bt-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 14rem;
}

.bt-back {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  color: var(--text-2);
}

.bt-back:hover {
  background: var(--surface-2);
  color: var(--text);
}

.bt-back .icon-back {
  transform: rotate(90deg);
}

.bt-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.bt-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  font-variation-settings: "opsz" 24;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.bt-save {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.bt-save[data-state="saving"]::before,
.bt-save[data-state="saved"]::before,
.bt-save[data-state="unsaved"]::before,
.bt-save[data-state="error"]::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: 0.05em;
}

.bt-save[data-state="saved"]::before {
  background: var(--success);
}

.bt-save[data-state="unsaved"]::before {
  background: var(--warm);
}

.bt-save[data-state="saving"]::before {
  background: var(--info);
  animation: pulse 1s ease-in-out infinite;
}

.bt-save[data-state="error"] {
  color: var(--error);
}

.bt-save[data-state="error"]::before {
  background: var(--error);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.bt-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.bt .icon {
  width: 1rem;
  height: 1rem;
}

.bt-url {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  padding: 0.35rem var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--success-soft);
  font-size: 0.85rem;
}

.bt-url-label {
  font-weight: 600;
  color: var(--success);
}

.bt-url-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Dropdown menus (details/summary) */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
  user-select: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu .icon-chevron {
  width: 0.85rem;
  height: 0.85rem;
  margin-left: -0.1rem;
  opacity: 0.7;
}

.menu[open] > summary {
  border-color: var(--accent);
}

.menu-list {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 30;
  min-width: 14rem;
  max-height: min(60vh, 26rem);
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.bt-left .menu-list,
.vadd .menu-list {
  right: auto;
  left: 0;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.menu-item-title {
  font-weight: 600;
}

.menu-item-desc {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------------------------------------------------------------------------
 * Body: tabs, panes, splitter
 * ------------------------------------------------------------------------- */

.bbody {
  position: relative;
  display: grid;
  grid-template-columns: var(--split) 6px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "editor split tabs"
    "editor split right";
  flex: 1 1 auto;
  min-height: 0;
}

.bbody--resizing {
  cursor: col-resize;
  user-select: none;
}

.bbody--resizing .bpane {
  pointer-events: none;
}

.btabs {
  grid-area: tabs;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.btab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.btab {
  flex: none;
}

.btab .icon {
  flex: none;
  width: 1rem;
  height: 1rem;
}

.btab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btab[aria-selected="true"] {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

.btab--editor {
  display: none;
}

.bpane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bpane--editor {
  grid-area: editor;
  background: var(--surface);
  border-right: 0;
}

.bpane--right {
  grid-area: right;
  overflow: auto;
  background: var(--bg);
}

.bsplit {
  grid-area: split;
  position: relative;
  background: var(--border);
  cursor: col-resize;
  touch-action: none;
  transition: background-color 120ms ease;
}

.bsplit::after {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.bsplit:hover,
.bbody--resizing .bsplit,
.bsplit:focus-visible {
  background: var(--accent);
  outline: none;
}

@media (max-width: 860px) {
  .bbody {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "tabs"
      "pane";
  }

  .btab--editor {
    display: inline-flex;
  }

  .btabs {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .bsplit {
    display: none;
  }

  .bpane--editor,
  .bpane--right {
    grid-area: pane;
  }

  .bbody[data-mobile="editor"] .bpane--right,
  .bbody[data-mobile="right"] .bpane--editor {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
 * Editor
 * ------------------------------------------------------------------------- */

.bpane-editor-host {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.ed {
  --ed-gutter-w: 3.5rem;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--ed-font-size);
  line-height: var(--ed-line-height);
  tab-size: 2;
  background: var(--surface);
}

.ed-gutter {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 2;
  width: 3.5ch;
  min-width: 2.75rem;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-align: right;
  user-select: none;
  pointer-events: none;
}

.ed-gutter-inner {
  padding: var(--ed-pad) 0;
  will-change: transform;
}

.ed-ln {
  position: relative;
  height: var(--ed-line-height);
  padding-right: 0.6rem;
  font-size: 0.85em;
  opacity: 0.7;
  pointer-events: auto;
}

.ed-ln--current {
  opacity: 1;
  color: var(--text);
  font-weight: 500;
}

.ed-ln--error,
.ed-ln--warning {
  opacity: 1;
}

.ed-ln--error::before,
.ed-ln--warning::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--error);
}

.ed-ln--warning::before {
  background: var(--warm);
}

.ed .ed-layer,
.ed textarea.ed-input {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  padding: var(--ed-pad) var(--ed-pad) var(--ed-pad) calc(var(--ed-gutter-w) + 0.85rem);
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
  tab-size: inherit;
}

.ed-layer {
  z-index: 0;
  pointer-events: none;
  will-change: transform;
  min-width: 100%;
  padding-right: 4rem;
  padding-bottom: 50vh; /* mirror the textarea's bottom slack */
}

.ed-hl {
  margin: 0;
  padding: 0;
  overflow: visible;
  font: inherit;
  color: var(--text);
  background: transparent;
}

.ed-hl code {
  display: block;
  padding: 0;
  font: inherit;
  background: none;
  white-space: pre;
}

.ed-curline {
  position: absolute;
  left: var(--ed-gutter-w);
  right: 0;
  top: 0;
  height: var(--ed-line-height);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  pointer-events: none;
  will-change: transform;
}

.ed-curline--flash {
  animation: ed-flash 900ms ease-out;
}

@keyframes ed-flash {
  0% {
    background: var(--accent-soft-2);
  }
  100% {
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  }
}

.ed textarea.ed-input {
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding-bottom: 50vh;
  border: 0;
  border-radius: 0;
  outline: none;
  resize: none;
  overflow: auto;
  color: transparent;
  caret-color: var(--text);
  background: transparent;
  box-shadow: none;
}

.ed textarea.ed-input:focus {
  outline: none;
  box-shadow: none;
  border: 0;
}

.ed-input::selection {
  background: var(--accent-soft-2);
}

.ed-input::placeholder {
  color: var(--muted);
}

.ed-status {
  flex: none;
  padding: 0.2rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: right;
}

/* Problems panel */

.problems {
  flex: none;
  max-height: 40%;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
}

.problems-summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.problems-summary::-webkit-details-marker {
  display: none;
}

.problems-summary::after {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.6;
  transition: transform 120ms ease;
}

.problems[open] .problems-summary::after {
  transform: rotate(-135deg);
}

.problems-summary .icon {
  width: 1rem;
  height: 1rem;
}

.problems--errors .problems-summary {
  color: var(--error);
}

.problems--has:not(.problems--errors) .problems-summary {
  color: var(--warm);
}

.icon-ok {
  color: var(--success);
}

.problems-list {
  list-style: none;
  margin: 0;
  padding: 0 0.35rem 0.35rem;
  overflow: auto;
}

.problems:not(.problems--has) .problems-list {
  display: none;
}

.problem {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.problem:hover,
.problem:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.problem-loc {
  flex: none;
  min-width: 3.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.problem--error .problem-loc {
  color: var(--error);
}

.problem--warning .problem-loc {
  color: var(--warm);
}

/* ---------------------------------------------------------------------------
 * Preview
 * ------------------------------------------------------------------------- */

.preview-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1rem clamp(0.75rem, 3vw, 2rem) 3rem;
  overscroll-behavior: contain;
}

.preview-note {
  max-width: var(--askdown-max-width, 42rem);
  margin: 0 auto 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.preview-empty {
  max-width: 24rem;
  margin: 4rem auto;
  padding: 2rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.preview-mount .askdown {
  padding-left: 0;
  padding-right: 0;
}

.preview-mount .askdown-label {
  cursor: pointer;
}

/* ---------------------------------------------------------------------------
 * JSON
 * ------------------------------------------------------------------------- */

.bpane--json {
  padding: 0.75rem 1rem 2rem;
  gap: 0.6rem;
}

.json-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.json-tools .muted {
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.json-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ---------------------------------------------------------------------------
 * Visual editor
 * ------------------------------------------------------------------------- */

.bpane--visual {
  overflow: auto;
  padding: 1rem clamp(0.75rem, 3vw, 1.5rem) 4rem;
}

.visual {
  display: grid;
  gap: 1rem;
  max-width: 48rem;
  margin: 0 auto;
}

.vsettings,
.vpage {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.vsettings .vcard-head {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.vpage-head {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.vpage-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.vpage-num {
  flex: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.vpage-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem 1rem;
}

.vpage-meta .vf {
  flex: 1 1 12rem;
}

.vpage-meta .vcard-tools {
  margin-left: auto;
}

.vpage-items {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
}

.vpage-empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.vcard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.vcard:focus-within {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.vcard--content {
  border-style: dashed;
}

.vcard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.vcard-kind {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.vcard-kind .icon {
  width: 1rem;
  height: 1rem;
}

.vcard-tools {
  display: flex;
  gap: 0.15rem;
  margin-left: auto;
}

.vcard-body {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem 1rem;
}

.vf {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1 1 9rem;
}

.vf--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  padding: 0.35rem 0;
}

.vf-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.vf--inline .vf-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
}

.vf-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.vf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem 0.85rem;
}

.builder .vf-input,
.builder .vf-select {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.builder .vf-input:focus,
.builder .vf-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.builder .vf-input--label {
  font-size: 1rem;
  font-weight: 600;
}

.builder .vf-input--title {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.builder .vf-input--mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.builder .vf-input--num {
  max-width: 7rem;
}

.builder .vf-textarea {
  resize: vertical;
  min-height: 2.25rem;
  line-height: 1.45;
}

.builder .vf-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b665c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 1rem;
  cursor: pointer;
}

.builder .vf-type {
  width: auto;
  min-width: 10rem;
  font-weight: 600;
}

.builder .vf-check {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.vbtn {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.vbtn .icon {
  width: 1rem;
  height: 1rem;
}

.vbtn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.vbtn--danger:hover {
  background: var(--error-soft);
  color: var(--error);
}

.vbtn--text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  height: auto;
  padding: 0.35rem 0.7rem;
  border-color: var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface);
}

.vbtn--text:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.vopts-wrap {
  display: grid;
  gap: 0.5rem;
}

.vopts {
  display: grid;
  gap: 0.35rem;
}

.vopt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.vopt > .vf-input {
  flex: 1 1 10rem;
}

.vopt .vf-goto {
  flex: 0 1 13rem;
  min-height: 2rem;
  font-size: 0.8rem;
}

.vopt-tools {
  display: flex;
  gap: 0.1rem;
  margin-left: auto;
}

.vadd {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 0.85rem 0.85rem;
}

.vadd--page {
  justify-content: center;
  padding: 0.5rem 0 2rem;
}

.vadd-menu .menu-list {
  top: auto;
  bottom: calc(100% + 0.35rem);
  min-width: 15rem;
  columns: 1;
}

.vadd-menu .menu-item {
  padding: 0.4rem 0.7rem;
}

/* ---------------------------------------------------------------------------
 * Drag & drop, toasts
 * ------------------------------------------------------------------------- */

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 2rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.builder--dragging .drop-overlay {
  display: grid;
}

.drop-overlay-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 2rem;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

.drop-overlay-inner .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 60;
  max-width: min(90vw, 32rem);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 1rem);
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast--show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast[data-kind="error"] {
  background: var(--error);
  color: #fff;
}

/* ---------------------------------------------------------------------------
 * No-JS fallback (server-rendered, hidden once the builder mounts)
 * ------------------------------------------------------------------------- */

.builder-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.builder-nojs {
  max-width: var(--content-w);
  width: 100%;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--gutter);
}

.fallback-editor {
  margin-top: 1rem;
}

.fallback-editor summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
}

.fallback-editor textarea {
  width: 100%;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.diagnostics-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.diagnostic {
  padding: 0.35rem 0.75rem;
  margin-bottom: 0.25rem;
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
}

.diagnostic-error {
  border-color: var(--error);
  background: var(--error-soft);
}

.diagnostic-warning {
  border-color: var(--warm);
  background: var(--warm-soft);
}

@media (max-width: 640px) {
  .bt {
    padding: 0.5rem 0.75rem;
  }

  .bt-right .button:not(.button-primary) > span,
  .bt-right .menu > summary > span {
    display: none;
  }

  .bt-right .button,
  .bt-right .menu > summary {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }
}
