.wrap {
  display: inline-flex;
}

/* Disclosure panel — portaled to body, positioned `fixed` by usePopover. The shared
   disclosure-popover surface (arch 10): elevated --layer-01, hairline border, --radius. */
.pop {
  position: fixed;
  z-index: 1000;
  width: 300px;
  max-height: 60vh;
  overflow: auto;
  padding: var(--space-4);
  background: var(--layer-01);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.title {
  margin: 0 0 var(--space-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.tree {
  font-size: 12px;
}

/* Bare wireframe: a crisp box, fill only the canvas. Passive structure, so the
   boxes carry the function (drop targets, later) — `--border-strong`, no chrome. */
.node {
  border: 1px solid var(--border-strong);
  background: var(--bg);
}
/* The padding is the *pull-out margin*: a frame's gutter, between its border and its
   child boxes, is the drop zone that lifts a view out into a new full-span row/column
   (vs. a box's own edge, which pairs or reorders). Sized for a comfortable target. */
.container {
  --pull-gutter: var(--space-5);
  --reveal-tint: color-mix(in srgb, var(--accent) 7%, transparent);
  position: relative;
  padding: var(--pull-gutter);
  cursor: pointer;
}
.leaf {
  min-height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* The mark glyph is a quiet identity hint, not chrome — muted, inherits theme. */
.markIcon {
  color: var(--text-secondary);
}
.node:hover {
  border-color: var(--text-secondary);
}

/* Draggable boxes (draft only) advertise the drag with a grab cursor; the body
   cursor flips to grabbing for the duration of an active drag (set in JS). */
.node[data-draggable] {
  cursor: grab;
}
.node[data-dragging] {
  opacity: 0.4;
}
/* Reorder (move) indicator (arch 10 §5): a 3px accent line on the target box's edge
   marks where the dragged view lands in the sequence. */
.node[data-drop-mode='move'][data-drop-edge='left'] {
  box-shadow: inset 3px 0 0 var(--accent);
}
.node[data-drop-mode='move'][data-drop-edge='right'] {
  box-shadow: inset -3px 0 0 var(--accent);
}
.node[data-drop-mode='move'][data-drop-edge='top'] {
  box-shadow: inset 0 3px 0 var(--accent);
}
.node[data-drop-mode='move'][data-drop-edge='bottom'] {
  box-shadow: inset 0 -3px 0 var(--accent);
}
/* Pair (wrap) indicator: the two views split into a new row/column. The target box is
   outlined, and the half the incoming view will take is shaded with a seam line at the
   split — so it previews the split, not just "drop here". */
.node[data-drop-mode='wrap'] {
  position: relative;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.node[data-drop-mode='wrap']::after {
  content: '';
  position: absolute;
  background: var(--accent-soft);
  pointer-events: none;
}
.node[data-drop-mode='wrap'][data-drop-edge='top']::after {
  inset: 0 0 50% 0;
  border-bottom: 2px solid var(--accent);
}
.node[data-drop-mode='wrap'][data-drop-edge='bottom']::after {
  inset: 50% 0 0 0;
  border-top: 2px solid var(--accent);
}
.node[data-drop-mode='wrap'][data-drop-edge='left']::after {
  inset: 0 50% 0 0;
  border-right: 2px solid var(--accent);
}
.node[data-drop-mode='wrap'][data-drop-edge='right']::after {
  inset: 0 0 0 50%;
  border-left: 2px solid var(--accent);
}
/* Pull-out indicator: the dragged view would lift out into a new full-span row/column
   here. A shaded band fills the frame's margin on the resolved side, capped by a solid
   accent line — the "shaded drop-zone" feedback (vs. the box-edge line of a pair/move). */
.node[data-drop-pull]::after {
  content: '';
  position: absolute;
  background: var(--accent-soft);
  pointer-events: none;
}
.node[data-drop-pull='top']::after {
  inset: 0 0 auto 0;
  height: var(--pull-gutter);
  border-top: 2px solid var(--accent);
}
.node[data-drop-pull='bottom']::after {
  inset: auto 0 0 0;
  height: var(--pull-gutter);
  border-bottom: 2px solid var(--accent);
}
.node[data-drop-pull='left']::after {
  inset: 0 auto 0 0;
  width: var(--pull-gutter);
  border-left: 2px solid var(--accent);
}
.node[data-drop-pull='right']::after {
  inset: 0 0 0 auto;
  width: var(--pull-gutter);
  border-right: 2px solid var(--accent);
}
/* Reveal-on-drag: while a drag is live, every frame's pull-out margins glow faintly so
   the targets are discoverable without hunting — across the container's own axis (a
   row's margins are top/bottom, a column's left/right). The active target reads
   stronger via the band above. */
.tree[data-drag-active] .container[data-orientation='horizontal'] {
  box-shadow:
    inset 0 var(--pull-gutter) 0 var(--reveal-tint),
    inset 0 calc(-1 * var(--pull-gutter)) 0 var(--reveal-tint);
}
.tree[data-drag-active] .container[data-orientation='vertical'] {
  box-shadow:
    inset var(--pull-gutter) 0 0 var(--reveal-tint),
    inset calc(-1 * var(--pull-gutter)) 0 0 var(--reveal-tint);
}
/* Selection mirrors the library's active-row language (arch 09 §4). */
.node.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.leaf.selected {
  background: var(--accent-soft);
}
.node:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.children {
  gap: var(--space-2);
}
.row {
  display: flex;
  flex-direction: row;
}
.row > * {
  flex: 1 1 0;
  min-width: 0;
}
.col {
  display: flex;
  flex-direction: column;
}
/* General concat wraps into a grid (honors `columns`). */
.grid {
  display: flex;
  flex-flow: row wrap;
}
.grid > * {
  flex: 1 1 84px;
}
/* Layer: one plotting space holding several marks (z-order). Render it as a single
   frame — a row of the child mark glyphs, badged as layered — not as separate boxes,
   so it reads as one space and the marks stay legible (vs. the concat box-per-view). */
.layerBox {
  position: relative;
}
.layered {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 40px;
}
/* A layer's mark is a bare glyph, not a boxed leaf — the frame is the box. The
   transparent border keeps the hover/selection outline (from `.node`) consistent. */
.layerMark {
  min-height: 0;
  padding: var(--space-2) var(--space-3);
  border-color: transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.layerBadge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  color: var(--text-placeholder);
  pointer-events: none;
}

/* Facet / repeat: one authored child stands for many generated cells — a card
   peeking out behind hints at the multiples. */
.generated {
  position: relative;
}
.generated::before {
  content: '';
  position: absolute;
  inset: 5px -5px -5px 5px;
  border: 1px solid var(--border);
  z-index: -1;
}

.caption {
  margin: var(--space-3) 0 0;
  min-height: 1.4em;
  color: var(--text-secondary);
  font-size: 11px;
}
.caption code {
  font-family: var(--font-mono);
  color: var(--text);
}
.muted {
  color: var(--text-placeholder);
}

/* Drag chip: follows the cursor during a drag, naming the pending action ("New row
   above", "Pair into a column", "Reorder"). Inverted ink-on-bg for contrast on any
   theme; above the popover (z 1000) since it portals to the body. */
.dragChip {
  position: fixed;
  z-index: 1100;
  pointer-events: none;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--bg);
  background: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.dragChip[data-empty] {
  opacity: 0.6;
}

/* Redundant single-child wrapper: a frame holding one view adds no structure. A soft
   warning hairline marks it as cleanable (not broken); the prompt below offers the fix. */
.node[data-degenerate] {
  border-style: dashed;
  border-color: var(--support-warning-fg);
}
.warning {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: 11px;
  color: var(--support-warning-fg);
  background: color-mix(in srgb, var(--support-warning) 12%, var(--bg));
  border: var(--border-width) solid color-mix(in srgb, var(--support-warning) 40%, var(--bg));
  border-radius: var(--radius);
}
.warning span {
  flex: 1;
}
.simplify {
  flex-shrink: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
}
.simplify:hover {
  text-decoration: underline;
}
.simplify:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
