/* ContentBlocks — Admin (builder shell) styles */

/* Design tokens (colors, radii) — every rule below reads var(--cb-*) rather
   than a literal, so the chrome is restyled by overriding tokens. */
@import "tokens-8S5Oikn.css";

/* Form widgets, scoped under .cb-shell. Pairs with cb_form_theme.html.twig. */
@import "forms-F7dvDkf.css";

/* ---- Launcher (form widget area) ----
   OUTSIDE cb-shell, so no form-theme tokens: keep these self-contained. */

.cb-launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cb-launcher__button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: var(--cb-accent);
  color: var(--cb-on-solid);
  border: 1px solid var(--cb-accent);
  border-radius: var(--cb-radius-sm);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}
.cb-launcher__button:hover {
  background: var(--cb-accent-strong);
  border-color: var(--cb-accent-strong);
}
.cb-launcher__button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(var(--cb-accent-rgb), 0.25);
}

.cb-launcher__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  background: var(--cb-badge-bg);
  color: var(--cb-badge-fg);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* ---- Dialog wrapper (fullscreen) ---- */

.cb-builder-dialog {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--cb-surface);
}

.cb-builder-dialog::backdrop {
  background: rgba(var(--cb-shadow-rgb), 0.6);
}

/* The host page keeps its scrollbar beside the fullscreen dialog otherwise. */
html:has(.cb-builder-dialog[open]),
body:has(.cb-builder-dialog[open]) {
  overflow: hidden;
}

/* ---- Shell layout ---- */

.cb-shell {
  /* Positioning context for the floating undo snackbar. */
  position: relative;
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100%;
  width: 100%;
  background: var(--cb-surface);
  color: var(--cb-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  /* Drives the grid column below. A descendant must NOT redeclare it, or
     it shadows the live value JS writes here. */
  --cb-sidebar-width: 340px;
  --cb-sidebar-collapsed-width: 32px;
}

.cb-shell__topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 1rem;
  background: var(--cb-panel);
  border-bottom: 1px solid var(--cb-line);
  gap: 1rem;
  /* Make room for the progress bar that sits on the shell's top edge. */
  position: relative;
}

/* ---- Top-bar progress indicator ---- */

/* Pinned above the topbar while a request is in flight; collapsed to zero
   height when idle so it takes no space. */
.cb-shell__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  z-index: 10;
  pointer-events: none;
  transition: height 0.12s ease-out;
}
.cb-shell--loading .cb-shell__progress {
  height: 2px;
  background: rgba(var(--cb-accent-rgb), 0.15);
}
.cb-shell__progress::after {
  content: "";
  display: block;
  height: 100%;
  width: 30%;
  background: var(--cb-accent);
  animation: cb-shell-progress 1.1s ease-in-out infinite;
}
@keyframes cb-shell-progress {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(150%);
  }
  100% {
    transform: translateX(350%);
  }
}

.cb-shell__topbar-left {
  justify-self: start;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.cb-shell__topbar-right {
  justify-self: end;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.cb-shell__close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: var(--cb-muted);
}
.cb-shell__close:hover {
  color: var(--cb-text);
}

/* ---- Topbar "Actions" menu ----
   A row of ghost buttons made the rare and the constant look equal. */

.cb-shell__actions {
  position: relative;
}

.cb-shell__actions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--cb-radius-sm);
  color: var(--cb-accent);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}
.cb-shell__actions-toggle:hover,
.cb-shell__actions-toggle--open {
  background: rgba(var(--cb-accent-rgb), 0.08);
  border-color: rgba(var(--cb-accent-rgb), 0.25);
}
.cb-shell__actions-caret {
  font-size: 0.7rem;
  transition: transform 0.12s ease;
}
.cb-shell__actions-toggle--open .cb-shell__actions-caret {
  transform: rotate(180deg);
}

.cb-shell__actions-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 240px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--cb-panel);
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius);
  box-shadow: 0 8px 24px rgba(var(--cb-shadow-rgb), 0.16);
}
.cb-shell__actions-list[hidden] {
  display: none;
}

.cb-shell__actions-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: 0;
  border-radius: var(--cb-radius-sm);
  color: var(--cb-text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}
.cb-shell__actions-item:hover,
.cb-shell__actions-item:focus-visible {
  background: var(--cb-accent-bg);
  color: var(--cb-accent-darker);
}
/* In the topbar an icon was noise next to a labelled button; in a menu it is
   the fastest way to tell two rows apart, so here it shows. */
.cb-shell__actions-item .cb-shell__btn-icon {
  width: 1.15rem;
  flex: none;
  text-align: center;
  color: var(--cb-muted);
}
.cb-shell__actions-item:hover .cb-shell__btn-icon,
.cb-shell__actions-item:focus-visible .cb-shell__btn-icon {
  color: inherit;
}

/* ---- Tree panel ----
   Floats over the preview: the edit sidebar already owns the left track. */

.cb-shell__tree-toggle,
.cb-shell__public-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--cb-radius-sm);
  color: var(--cb-accent);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease;
}
.cb-shell__public-link,
.cb-shell__public-link:hover,
.cb-shell__public-link:focus {
  text-decoration: none;
}
.cb-shell__tree-toggle:hover,
.cb-shell__tree-toggle--open,
.cb-shell__public-link:hover {
  background: rgba(var(--cb-accent-rgb), 0.08);
  border-color: rgba(var(--cb-accent-rgb), 0.25);
}

/* Absolute against .cb-shell — hence its place beside <main> in the markup —
   so it clears the sidebar whatever width it has been dragged to. */
.cb-tree {
  position: absolute;
  top: 68px;
  left: calc(var(--cb-sidebar-width) + 16px);
  z-index: 28;
  width: 320px;
  /* Not derived from the sidebar's width: once the editor drags the panel,
     `left` is an inline pixel value and that constraint no longer holds. */
  max-width: calc(100% - 32px);
  max-height: calc(100% - 84px);
  display: flex;
  flex-direction: column;
  background: var(--cb-panel);
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius);
  box-shadow: 0 12px 32px rgba(var(--cb-shadow-rgb), 0.18);
  overflow: hidden;
}
.cb-shell--sidebar-collapsed .cb-tree {
  left: calc(var(--cb-sidebar-collapsed-width) + 16px);
}
.cb-tree[hidden] {
  display: none;
}

/* The whole header is the drag handle, so the panel can be moved off
   whatever it is covering. `touch-action` keeps a touch-drag from scrolling. */
.cb-tree__header {
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--cb-panel-2);
  background: var(--cb-panel-3);
}
.cb-tree__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cb-text);
}
.cb-tree__close {
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  color: var(--cb-muted);
}
.cb-tree__close:hover {
  color: var(--cb-text);
}
/* Lifted while moving, so it reads as picked up rather than redrawn. */
.cb-tree--dragging {
  box-shadow: 0 20px 48px rgba(var(--cb-shadow-rgb), 0.28);
}
.cb-tree--dragging .cb-tree__header {
  cursor: grabbing;
}

.cb-tree__body {
  padding: 0.5rem;
  overflow-y: auto;
}
.cb-tree__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cb-tree__status {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--cb-muted);
}
.cb-tree__status:empty {
  display: none;
}

.cb-tree__section + .cb-tree__section {
  margin-top: 2px;
}
.cb-tree__children {
  margin-left: 0.75rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--cb-line);
}
.cb-tree__blocks {
  list-style: none;
  margin: 0;
  padding: 0;
  /* Dropping into an empty column needs a target with height. */
  min-height: 18px;
}

/* The row owns the scale and the name inherits it, so the column rule below
   can drop its own subtree back to caption size. */
.cb-tree__row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.25rem;
  border-radius: var(--cb-radius-xs);
  min-width: 0;
  font-size: 0.8125rem;
}
.cb-tree__row:hover {
  background: var(--cb-panel-3);
}
.cb-tree__row--section {
  font-weight: 600;
}
.cb-tree__row--column {
  color: var(--cb-faint);
  font-size: var(--cb-caption-size);
  letter-spacing: var(--cb-caption-tracking);
  text-transform: uppercase;
}
.cb-tree__row--column:hover {
  background: transparent;
}
.cb-tree__row--selected,
.cb-tree__row--selected:hover {
  background: var(--cb-accent-bg);
  color: var(--cb-accent-darker);
}

.cb-tree__drag {
  flex: none;
  color: var(--cb-faint);
  cursor: grab;
  /* Or a touch-drag on the handle is hijacked by the panel's scroll. */
  touch-action: none;
  font-size: 0.8rem;
  line-height: 1;
}
.cb-tree__twisty {
  flex: none;
  width: 1rem;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--cb-muted);
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}

.cb-tree__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  /* Resets the button's own font; the row above decides the size. */
  font: inherit;
  text-align: left;
}
.cb-tree__name--action {
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

/* The column preset (`col-6`), which has no glyph to stand for it. */
.cb-tree__chip {
  flex: none;
  padding: 0.05rem 0.3rem;
  border-radius: var(--cb-radius-xs);
  background: var(--cb-panel-2);
  color: var(--cb-muted);
  font-family: var(--cb-font-mono);
  font-size: var(--cb-caption-size);
  font-weight: 400;
}

/* A block says its type as a glyph: repeating the type as a word beside a
   label that is often the type itself read as noise. */
.cb-tree__icon {
  flex: none;
  display: inline-flex;
  color: var(--cb-muted);
}
.cb-tree__icon svg {
  width: 15px;
  height: 15px;
  display: block;
}
.cb-tree__icon--missing {
  color: var(--cb-danger);
}
.cb-tree__row--selected .cb-tree__icon {
  color: inherit;
}

/* Revealed on hover or keyboard focus: two glyphs per row, on every row,
   read as clutter in a list this dense. */
.cb-tree__actions {
  flex: none;
  display: flex;
  gap: 1px;
  opacity: 0;
}
.cb-tree__row:hover .cb-tree__actions,
.cb-tree__row:focus-within .cb-tree__actions {
  opacity: 1;
}
.cb-tree__act {
  padding: 0 0.2rem;
  background: transparent;
  border: 0;
  color: var(--cb-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
}
.cb-tree__act:hover {
  color: var(--cb-text);
}

/* ---- Modal pickers ----
   Anchoring put a 360px column in the corner of a 1600px screen. */

.cb-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 29;
  /* Tinted with the chrome accent rather than neutral black: the dimmed
     builder should still read as this tool, not as a generic overlay. */
  background: rgba(var(--cb-accent-rgb), 0.22);
  backdrop-filter: blur(1.5px);
}
.cb-modal-backdrop[hidden] {
  display: none;
}

.cb-replace-picker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 96px);
  display: flex;
  flex-direction: column;
  background: var(--cb-panel);
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius);
  box-shadow: 0 18px 48px rgba(var(--cb-shadow-rgb), 0.28);
  z-index: 30;
  overflow: hidden;
}
.cb-replace-picker[hidden] {
  display: none;
}

.cb-replace-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--cb-panel-2);
  background: var(--cb-panel-3);
}
.cb-replace-picker__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cb-text);
}
.cb-replace-picker__close {
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  color: var(--cb-muted);
}
.cb-replace-picker__close:hover {
  color: var(--cb-text);
}

.cb-replace-picker__body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

/* ---- Section library, in the empty sidebar ----
 * Not a modal: with nothing selected, the list *is* what the panel is for. */
.cb-sidebar-library {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--cb-line);
  /* Long libraries scroll inside the panel rather than pushing the
     add-section buttons — the primary action — out of reach. */
  min-height: 0;
}
.cb-sidebar-library__label {
  margin: 0;
  color: var(--cb-text-2);
  font-family: var(--cb-font-mono);
  font-size: var(--cb-caption-size);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--cb-caption-tracking);
}
.cb-sidebar-library .cb-template-picker__list {
  /* Roomier than the flat list it replaced: the rows are thumbnail cards now,
     and at 40vh barely two of them fitted. */
  max-height: 55vh;
  overflow-y: auto;
}

.cb-replace-picker__search,
.cb-template-picker__search {
  width: 100%;
  padding: 0.375rem 0.5rem;
  background: var(--cb-field-bg);
  color: var(--cb-text);
  border: 1px solid var(--cb-line-strong);
  border-radius: var(--cb-radius-sm);
  font: inherit;
}
/* These two sit outside the form theme, so without this they fall back to the
   browser's default focus ring — a black box in the middle of the chrome. */
.cb-replace-picker__search:focus,
.cb-template-picker__search:focus {
  outline: none;
  border-color: var(--cb-accent);
  box-shadow: 0 0 0 3px rgba(var(--cb-accent-rgb), 0.18);
}

.cb-replace-picker__list,
.cb-template-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.cb-replace-picker__item,
.cb-template-picker__item {
  display: flex;
}
.cb-replace-picker__item-btn,
.cb-template-picker__item-btn {
  flex: 1 1 auto;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--cb-radius-xs);
  padding: 0.375rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--cb-text);
  cursor: pointer;
}
.cb-replace-picker__item-btn:hover,
.cb-replace-picker__item-btn:focus-visible,
.cb-template-picker__item-btn:hover,
.cb-template-picker__item-btn:focus-visible {
  background: rgba(var(--cb-accent-rgb), 0.08);
  border-color: rgba(var(--cb-accent-rgb), 0.25);
  outline: none;
}

.cb-replace-picker__status,
.cb-template-picker__status {
  margin: 0;
  color: var(--cb-muted);
  font-size: 0.85rem;
  min-height: 1rem;
}
.cb-replace-picker__status:empty,
.cb-template-picker__status:empty {
  display: none;
}

/* Shares the replace picker's shell, but these rows are cards. Declared
   after it, whose denser gap suits rows and not cards. */
.cb-template-picker__list {
  gap: 0.5rem;
}
.cb-template-picker__item {
  align-items: center;
  gap: 0.25rem;
  /* Anchors the delete button over the card's top-right corner — beside the
     name it would eat width the thumbnail needs. */
  position: relative;
}
.cb-template-picker__item-btn {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.cb-template-picker__item-name {
  /* One line: names are editor-typed and can run long, and a card that grows
     with its name breaks the grid rhythm the thumbnails create. */
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* These matched a class the library's rows never carry, so an incompatible
   template looked exactly like an insertable one. */
.cb-template-picker__item--disabled .cb-template-picker__item-btn {
  color: var(--cb-faint);
  cursor: not-allowed;
}
.cb-template-picker__item--disabled .cb-template-picker__item-btn:hover {
  background: transparent;
  border-color: transparent;
}
/* Some blocks will be skipped. Still clickable: the marker warns without
   taking the useful insert away. */
.cb-template-picker__item--partial .cb-template-picker__item-name::after {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.4rem;
  border-radius: 50%;
  background: var(--cb-warning);
  color: var(--cb-on-solid);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}
.cb-template-picker__delete {
  /* Permanently visible rather than on hover: it is already in the tab
     order, and a control you can focus but not see is worse. */
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  background: var(--cb-panel);
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius-xs);
  padding: 0.25rem 0.375rem;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--cb-faint);
  cursor: pointer;
}
.cb-template-picker__delete:hover,
.cb-template-picker__delete:focus-visible {
  background: rgba(var(--cb-danger-rgb), 0.1);
  border-color: rgba(var(--cb-danger-rgb), 0.3);
  color: var(--cb-danger);
  outline: none;
}
.cb-template-picker__more {
  margin-top: 0.25rem;
  align-self: center;
  background: transparent;
  border: 1px solid rgba(var(--cb-accent-rgb), 0.3);
  border-radius: var(--cb-radius-xs);
  padding: 0.375rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--cb-accent);
  cursor: pointer;
}
.cb-template-picker__more:hover,
.cb-template-picker__more:focus-visible {
  background: rgba(var(--cb-accent-rgb), 0.08);
  outline: none;
}

/* ---- Section-template thumbnail ("poster") ----
   See docs/internals/section-templates.md#why-the-poster-is-a-spec */
.cb-template-poster {
  display: flex;
  gap: 3px;
  /* Within bounds, since a fixed frame left a short section floating in
     dead space — which reads as a thumbnail that failed to load. */
  min-height: 3.5rem;
  max-height: 12rem;
  padding: 4px;
  background: var(--cb-surface);
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius-xs);
  overflow: hidden;
}
.cb-template-poster__col {
  /* flex-grow carries the column's real preset (col-4 → 4); basis 0 makes the
     ratio depend on that alone and not on the tiles inside. */
  flex: 0 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}
.cb-template-poster__tile {
  display: block;
  flex: 0 0 auto;
  min-height: 6px;
  padding: 2px 3px;
  border-radius: 2px;
  background: var(--cb-panel);
  color: var(--cb-text-2);
  font-size: 7px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-template-poster__tile--heading {
  font-weight: 700;
  font-size: 8px;
  color: var(--cb-text);
}
.cb-template-poster__tile--text {
  color: var(--cb-muted);
  /* Two lines of real copy, then cut — enough to tell two text blocks apart. */
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.cb-template-poster__tile--image {
  /* A picture is what the eye recognises a section by, so it claims the
     room the text tiles do not need. */
  flex: 1 1 auto;
  min-height: 3.25rem;
  padding: 0;
  background: var(--cb-panel-2);
}
.cb-template-poster__tile--image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}
.cb-template-poster__tile--button {
  align-self: flex-start;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--cb-accent);
  color: var(--cb-on-solid);
  font-size: 7px;
}
.cb-template-poster__tile--rule {
  min-height: 0;
  height: 1px;
  padding: 0;
  margin: 2px 0;
  background: var(--cb-line-strong);
}
/* A block with nothing to preview says its own name rather than showing an
   empty shape — "Tableau" is information, a blank rectangle is not. */
.cb-template-poster__tile--generic {
  background: transparent;
  border: 1px dashed var(--cb-line-strong);
  color: var(--cb-faint);
}
/* Genuinely empty content (a title block with no title yet) — a plain bar,
   because there is nothing to name. */
.cb-template-poster__tile--blank {
  min-height: 5px;
  background: var(--cb-line);
}
/* A block type this build no longer registers. The card's tooltip lists them;
   the poster shows *where* they sit. */
.cb-template-poster__tile--missing {
  border: 1px dashed rgba(var(--cb-danger-rgb), 0.5);
  background: rgba(var(--cb-danger-rgb), 0.06);
  color: var(--cb-danger);
}
.cb-template-poster__more {
  flex: 0 0 auto;
  align-self: flex-start;
  color: var(--cb-faint);
  font-size: 7px;
  line-height: 1.4;
}

/* ---- Poster on a coloured section ----
   Tiles turn translucent, or an opaque fill tiles white over the colour. */
.cb-template-poster--tinted {
  border-color: rgba(var(--cb-shadow-rgb), 0.18);
}
.cb-template-poster--tinted .cb-template-poster__tile {
  background: rgba(255, 255, 255, 0.55);
}
.cb-template-poster--tinted .cb-template-poster__tile--generic,
.cb-template-poster--tinted .cb-template-poster__tile--rule {
  background: transparent;
}
.cb-template-poster--tinted .cb-template-poster__tile--rule {
  background: rgba(var(--cb-shadow-rgb), 0.35);
}

.cb-template-poster--dark .cb-template-poster__tile {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.cb-template-poster--dark .cb-template-poster__tile--heading {
  color: #fff;
}
.cb-template-poster--dark .cb-template-poster__tile--text,
.cb-template-poster--dark .cb-template-poster__tile--generic,
.cb-template-poster--dark .cb-template-poster__more {
  color: rgba(255, 255, 255, 0.75);
}
.cb-template-poster--dark .cb-template-poster__tile--generic {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.35);
}
.cb-template-poster--dark .cb-template-poster__tile--rule {
  background: rgba(255, 255, 255, 0.4);
}
.cb-template-poster--dark .cb-template-poster__tile--blank {
  background: rgba(255, 255, 255, 0.28);
}
/* A tile's own stored colour wins, and its copy then answers for itself: a
   red card is dark ground inside a light section. Declared last. */
.cb-template-poster .cb-template-poster__tile--on-dark,
.cb-template-poster--dark .cb-template-poster__tile--on-dark {
  color: #fff;
}
.cb-template-poster .cb-template-poster__tile--on-light,
.cb-template-poster--dark .cb-template-poster__tile--on-light {
  color: var(--cb-text);
}

/* ---- Import / Export dialog ----
   A native modal <dialog>; the import panel shows the step in data-step. */

.cb-transfer {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: calc(var(--cb-radius) + 4px);
  background: var(--cb-panel);
  color: var(--cb-text);
  box-shadow: 0 24px 64px rgba(var(--cb-shadow-rgb), 0.28);
  overflow: hidden;
}
.cb-transfer[open] {
  display: flex;
  flex-direction: column;
  animation: cb-transfer-in 0.22s ease-out;
}
.cb-transfer[open]::backdrop {
  animation: cb-transfer-fade 0.2s ease-out;
}
.cb-transfer::backdrop {
  background: rgba(var(--cb-shadow-rgb), 0.45);
  backdrop-filter: blur(2px);
}
@keyframes cb-transfer-in {
  from { opacity: 0; transform: translateY(8px); }
}
@keyframes cb-transfer-fade {
  from { opacity: 0; }
}
.cb-transfer svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cb-transfer__header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.5rem 1.5rem 1.25rem;
}
.cb-transfer__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--cb-radius);
  background: var(--cb-accent);
  color: var(--cb-on-solid);
}
.cb-transfer__badge svg {
  width: 1.3rem;
  height: 1.3rem;
}
.cb-transfer__heading {
  flex: 1;
  min-width: 0;
}
.cb-transfer__title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cb-transfer__subtitle {
  margin: 0.15rem 0 0;
  color: var(--cb-muted);
  font-size: 0.84rem;
}
.cb-transfer__close {
  flex: none;
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cb-muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.cb-transfer__close svg {
  width: 1.05rem;
  height: 1.05rem;
}
.cb-transfer__close:hover {
  background: var(--cb-panel-3);
  color: var(--cb-text);
}
.cb-transfer.is-busy .cb-transfer__close {
  visibility: hidden;
}

/* Tabs: a tint says which one is on, no frame around them. */
.cb-transfer__tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 1.5rem;
  padding: 0.25rem;
  border-radius: var(--cb-radius);
  background: var(--cb-panel-3);
}
.cb-transfer__tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: var(--cb-radius-sm);
  background: transparent;
  color: var(--cb-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.cb-transfer__tab svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}
.cb-transfer__tab:hover {
  color: var(--cb-text);
}
.cb-transfer__tab[aria-selected="true"] {
  background: var(--cb-panel);
  color: var(--cb-accent-darker);
}
.cb-transfer__tab[aria-selected="true"] svg {
  color: var(--cb-accent);
}
.cb-transfer__tab:focus-visible {
  outline: 2px solid var(--cb-accent);
  outline-offset: 1px;
}
.cb-transfer.is-busy .cb-transfer__tab {
  pointer-events: none;
}

.cb-transfer__panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
  overflow-y: auto;
  animation: cb-transfer-fade 0.2s ease-out;
}
.cb-transfer__panel[hidden] {
  display: none;
}

/* Export: the archive and what goes in it. */
.cb-transfer__hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.cb-transfer__archive {
  flex: none;
  width: 4rem;
  height: auto;
  overflow: visible;
}
.cb-transfer .cb-transfer__archive-sheet {
  fill: var(--cb-panel);
  stroke: var(--cb-accent);
  stroke-width: 2.5;
}
.cb-transfer .cb-transfer__archive-fold {
  fill: rgba(var(--cb-accent-rgb), 0.12);
  stroke: var(--cb-accent);
  stroke-width: 2.5;
}
.cb-transfer .cb-transfer__archive-zip {
  stroke: var(--cb-accent-soft);
  stroke-width: 3.5;
}
.cb-transfer .cb-transfer__archive-tag {
  fill: var(--cb-accent);
  stroke: none;
}
.cb-transfer .cb-transfer__archive-label {
  fill: var(--cb-accent-darker);
  stroke: none;
  font: 700 9px/1 var(--cb-font-mono);
  letter-spacing: 0.08em;
}
.cb-transfer .cb-transfer__archive-media {
  stroke: var(--cb-on-solid);
  stroke-width: 1.6;
  transform-origin: 47px 51px;
  transition: opacity 0.25s, transform 0.25s ease-out;
}
.cb-transfer .cb-transfer__archive-media rect {
  fill: var(--cb-success);
  stroke: var(--cb-panel);
  stroke-width: 2;
}
.cb-transfer.is-without-media .cb-transfer__archive-media {
  opacity: 0;
  transform: scale(0.5);
}
.cb-transfer__hero-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.cb-transfer__lead {
  margin: 0;
  color: var(--cb-text-2);
  font-size: 0.88rem;
  line-height: 1.5;
}
/* Figures carry the weight; the labels step back. */
.cb-transfer__counts {
  display: flex;
  gap: 2rem;
  margin: 0;
}
.cb-transfer__count {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.1rem;
  transition: opacity 0.2s;
}
.cb-transfer__count dd {
  margin: 0;
  color: var(--cb-text);
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cb-transfer__count dt {
  color: var(--cb-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.cb-transfer.is-without-media .cb-transfer__count--media {
  opacity: 0.35;
}
/* Read out when the numbers arrive; the tiles show them. */
.cb-transfer__stats {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cb-transfer__option {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: var(--cb-radius);
  background: var(--cb-panel-3);
  cursor: pointer;
}
.cb-transfer__option-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel);
  color: var(--cb-muted);
  transition: color 0.2s;
}
.cb-transfer__option-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}
.cb-transfer__option:has(:checked) .cb-transfer__option-icon {
  color: var(--cb-accent);
}
.cb-transfer__switch {
  flex: none;
  appearance: none;
  position: relative;
  width: 2.5rem;
  height: 1.4rem;
  margin: 0;
  border-radius: 999px;
  background: var(--cb-line-hover);
  cursor: pointer;
  transition: background-color 0.2s;
}
.cb-transfer__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.4rem - 6px);
  height: calc(1.4rem - 6px);
  border-radius: 50%;
  background: var(--cb-on-solid);
  transition: transform 0.2s ease-out;
}
.cb-transfer__switch:checked {
  background: var(--cb-accent);
}
.cb-transfer__switch:checked::after {
  transform: translateX(1.1rem);
}
.cb-transfer__switch:focus-visible {
  outline: 2px solid var(--cb-accent);
  outline-offset: 2px;
}
.cb-transfer__option-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.2rem;
}
.cb-transfer__option-label {
  font-weight: 600;
  font-size: 0.92rem;
}
.cb-transfer__option-hint {
  color: var(--cb-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.cb-transfer__size {
  flex: none;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-family: var(--cb-font-mono);
  font-size: 0.78rem;
  font-weight: 500;
}
.cb-transfer__size:empty {
  display: none;
}

.cb-transfer__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.cb-transfer__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-panel-3);
  color: var(--cb-text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.cb-transfer__btn:hover {
  background: var(--cb-line);
}
.cb-transfer__btn:focus-visible {
  outline: 2px solid var(--cb-accent);
  outline-offset: 2px;
}
.cb-transfer__btn--primary {
  background: var(--cb-accent);
  color: var(--cb-on-solid);
}
.cb-transfer__btn--primary:hover {
  background: var(--cb-accent-strong);
  color: var(--cb-on-solid);
}
.cb-transfer__btn--wide {
  flex: 1;
  padding: 0.8rem 1.1rem;
  font-size: 0.95rem;
}
.cb-transfer__btn-icon {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2.2;
}

/* Import: one step at a time. */
.cb-transfer__step {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}
.cb-transfer:not([data-step]) [data-cb-transfer-step="pick"],
.cb-transfer[data-step="pick"] [data-cb-transfer-step="pick"],
.cb-transfer[data-step="review"] [data-cb-transfer-step="review"],
.cb-transfer[data-step="run"] [data-cb-transfer-step="run"],
.cb-transfer[data-step="done"] [data-cb-transfer-step="done"],
.cb-transfer[data-step="error"] [data-cb-transfer-step="error"] {
  display: flex;
  animation: cb-transfer-fade 0.2s ease-out;
}
.cb-transfer__step--center {
  align-items: center;
  padding-top: 0.5rem;
  text-align: center;
}
.cb-transfer__step--center .cb-transfer__actions,
.cb-transfer__step--center .cb-transfer__checks {
  align-self: stretch;
}
.cb-transfer__step--center .cb-transfer__checks {
  text-align: start;
}
.cb-transfer__step--center .cb-transfer__actions {
  justify-content: center;
}

/* Dashed only while a file is dragged: the tint already says "drop here". */
.cb-transfer__drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2.25rem 1.25rem 2rem;
  border-radius: var(--cb-radius);
  outline: 2px dashed transparent;
  outline-offset: -2px;
  background: var(--cb-panel-3);
  text-align: center;
  cursor: pointer;
  transition: outline-color 0.15s, background-color 0.15s;
}
.cb-transfer__drop[hidden] {
  display: none;
}
.cb-transfer__drop--compact {
  padding: 1rem;
}
.cb-transfer__drop:hover {
  background: rgba(var(--cb-accent-rgb), 0.06);
}
.cb-transfer__drop.is-over {
  outline-color: var(--cb-accent);
  background: rgba(var(--cb-accent-rgb), 0.08);
}
.cb-transfer__drop:focus-within {
  outline: 2px solid var(--cb-accent);
  outline-offset: 2px;
}
.cb-transfer__file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.cb-transfer__drop-halo {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.5rem;
  border-radius: 50%;
  background: var(--cb-panel);
  color: var(--cb-accent);
}
.cb-transfer__drop-icon {
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.2s;
}
.cb-transfer__drop:hover .cb-transfer__drop-icon,
.cb-transfer__drop.is-over .cb-transfer__drop-icon {
  transform: translateY(-2px);
}
.cb-transfer__drop-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.cb-transfer__drop-hint {
  color: var(--cb-muted);
  font-size: 0.82rem;
}
.cb-transfer__chips {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.cb-transfer__chips span {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--cb-panel);
  color: var(--cb-muted);
  font-family: var(--cb-font-mono);
  font-size: 0.72rem;
}

.cb-transfer__file-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.cb-transfer__file-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--cb-radius-sm);
  background: rgba(var(--cb-accent-rgb), 0.1);
  color: var(--cb-accent);
}
.cb-transfer__file-icon svg {
  width: 1.3rem;
  height: 1.3rem;
}
.cb-transfer__file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 0.98rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-transfer__file-size {
  flex: none;
  color: var(--cb-muted);
  font-family: var(--cb-font-mono);
  font-size: 0.82rem;
}
.cb-transfer__checks {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cb-transfer__checks:empty {
  display: none;
}
.cb-transfer__check {
  position: relative;
  padding-left: 1.75rem;
  color: var(--cb-text-2);
  font-size: 0.88rem;
  line-height: 1.45;
}
.cb-transfer__check::before {
  position: absolute;
  top: 0.05rem;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  color: var(--cb-on-solid);
  font-size: 0.7rem;
  font-weight: 700;
}
.cb-transfer__check--ok::before {
  content: "✓";
  background: var(--cb-success);
}
.cb-transfer__check--info::before {
  content: "↑";
  background: var(--cb-accent);
}
.cb-transfer__check--warn {
  color: var(--cb-text);
}
.cb-transfer__check--warn::before {
  content: "!";
  background: var(--cb-warning);
}
.cb-transfer__warning {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--cb-radius-sm);
  background: color-mix(in srgb, var(--cb-warning) 12%, transparent);
  color: var(--cb-text-2);
  font-size: 0.84rem;
  line-height: 1.45;
}
.cb-transfer__message {
  margin: 0;
  color: var(--cb-muted);
  font-size: 0.85rem;
}
.cb-transfer__message:empty {
  display: none;
}
.cb-transfer__message--error {
  color: var(--cb-danger);
  font-size: 0.92rem;
  font-weight: 500;
}
.cb-transfer__result {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.cb-transfer__spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid rgba(var(--cb-accent-rgb), 0.15);
  border-top-color: var(--cb-accent);
  border-radius: 50%;
  animation: cb-transfer-spin 0.8s linear infinite;
}
@keyframes cb-transfer-spin {
  to { transform: rotate(360deg); }
}
.cb-transfer__progress-label {
  margin: 0;
  color: var(--cb-text-2);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.cb-transfer__progress {
  width: 100%;
  height: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--cb-panel-3);
  overflow: hidden;
  appearance: none;
}
.cb-transfer__progress::-webkit-progress-bar {
  background: var(--cb-panel-3);
}
.cb-transfer__progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--cb-accent);
  transition: width 0.2s;
}
.cb-transfer__progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--cb-accent);
}

.cb-transfer__seal {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  color: var(--cb-on-solid);
  animation: cb-transfer-pop 0.3s ease-out;
}
.cb-transfer__seal svg {
  width: 1.8rem;
  height: 1.8rem;
  stroke-width: 2.6;
}
.cb-transfer__seal--ok {
  background: var(--cb-success);
}
.cb-transfer__seal--ok path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: cb-transfer-draw 0.35s 0.15s ease-out forwards;
}
.cb-transfer__seal--error {
  background: var(--cb-danger);
}
@keyframes cb-transfer-pop {
  from { opacity: 0; transform: scale(0.7); }
}
@keyframes cb-transfer-draw {
  to { stroke-dashoffset: 0; }
}

@media (max-width: 480px) {
  .cb-transfer__hero {
    flex-direction: column;
    align-items: stretch;
  }
  .cb-transfer__archive {
    align-self: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cb-transfer,
  .cb-transfer *,
  .cb-transfer::backdrop {
    animation: none !important;
    transition: none !important;
  }
  .cb-transfer__seal--ok path {
    stroke-dashoffset: 0;
  }
}

.cb-shell__viewport {
  display: inline-flex;
  background: var(--cb-surface);
  border-radius: var(--cb-radius-sm);
  padding: 0.125rem;
}
.cb-shell__viewport-btn {
  background: transparent;
  border: 0;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  color: var(--cb-muted);
  border-radius: var(--cb-radius-xs);
  font-size: 1.1rem;
  line-height: 1;
}
.cb-shell__viewport-btn[hidden] {
  display: none;
}
.cb-shell__viewport-btn--active {
  background: var(--cb-panel);
  color: var(--cb-text);
  box-shadow: var(--cb-shadow-selected);
}
/* Separates looking at the page from committing to it. A pseudo-element, so
   it needs no node; `right` is half the 1rem gutter, to land centred. */
.cb-shell__topbar-right .cb-shell__viewport {
  position: relative;
  margin-right: 0.5rem;
}
.cb-shell__topbar-right .cb-shell__viewport::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.5rem;
  transform: translateY(-50%);
  width: 1px;
  height: 1.25rem;
  background: var(--cb-line);
}

/* The preview renders a narrower viewport: say what a drag does there. */
.cb-shell__viewport-order {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.25rem 0.2rem 0.6rem;
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius-sm);
  background: var(--cb-surface);
  color: var(--cb-muted);
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
}
.cb-shell__viewport-order[hidden] {
  display: none;
}
.cb-shell__viewport-order-reset {
  padding: 0.15rem 0.4rem;
  border: 0;
  border-radius: var(--cb-radius-xs);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.cb-shell__viewport-order-reset:hover,
.cb-shell__viewport-order-reset:focus-visible {
  background: var(--cb-panel);
  color: var(--cb-text);
}
@media (max-width: 1024px) {
  .cb-shell__viewport-order-label {
    display: none;
  }
}

/* ---- Save-failure banner (topbar) ----
   Persistent: it goes only once a later save succeeds. */
.cb-shell__save-error,
.cb-shell__session-expired {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(var(--cb-danger-rgb), 0.4);
  border-radius: var(--cb-radius-sm);
  background: rgba(var(--cb-danger-rgb), 0.08);
  color: var(--cb-danger-strong);
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
}
.cb-shell__save-error[hidden],
.cb-shell__session-expired[hidden] {
  display: none;
}
.cb-shell__session-login {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}
@media (max-width: 768px) {
  /* Keep the chip readable on narrow topbars: icon only. */
  .cb-shell__save-error > span:not(.cb-shell__btn-icon),
  .cb-shell__session-expired > span:not(.cb-shell__btn-icon) {
    display: none;
  }
}

/* ---- Undo snackbar ----
   Inverse, so it reads as transient feedback rather than part of the page. */
.cb-shell__undo {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  border-radius: var(--cb-radius);
  background: var(--cb-text);
  color: var(--cb-on-solid);
  font-size: 0.875rem;
  line-height: 1.2;
  box-shadow: 0 4px 16px rgba(var(--cb-shadow-rgb), 0.25);
  white-space: nowrap;
  max-width: calc(100% - 2rem);
}
.cb-shell__undo[hidden] {
  display: none;
}
.cb-shell__undo-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-shell__undo-link {
  text-decoration: none;
}
.cb-shell__undo-link[hidden] {
  display: none;
}
.cb-shell__undo-btn,
.cb-shell__undo-link {
  background: transparent;
  border: 0;
  padding: 0.25rem 0.5rem;
  border-radius: var(--cb-radius-sm);
  color: var(--cb-accent-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cb-shell__undo-btn:hover,
.cb-shell__undo-link:hover {
  background: rgba(var(--cb-accent-soft-rgb), 0.12);
}

/* ---- Top-right action buttons (Discard / Publish) ---- */

.cb-shell__discard,
.cb-shell__publish {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--cb-radius-sm);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}
.cb-shell__discard {
  background: transparent;
  border: 1px solid transparent;
  color: var(--cb-accent);
}
.cb-shell__discard:hover:not([disabled]) {
  background: rgba(var(--cb-accent-rgb), 0.08);
  border-color: rgba(var(--cb-accent-rgb), 0.25);
}
.cb-shell__discard[hidden] {
  display: none;
}
/* The chrome accent, not the success green: green reports an outcome, it
   does not offer an action. */
.cb-shell__publish {
  background: var(--cb-accent);
  border: 1px solid var(--cb-accent);
  color: var(--cb-on-solid);
}
.cb-shell__publish:hover:not([disabled]) {
  background: var(--cb-accent-strong);
  border-color: var(--cb-accent-strong);
}
.cb-shell__publish[disabled] {
  background: var(--cb-line-strong);
  border-color: var(--cb-line-strong);
  color: var(--cb-on-solid);
  cursor: not-allowed;
}
.cb-shell__btn-icon {
  font-size: 1rem;
  line-height: 1;
}
/* Default state: icon hidden on desktop where the label is shown. */
.cb-shell__discard .cb-shell__btn-icon {
  display: none;
}

/* ---- Mobile tightening ---- */
@media (max-width: 768px) {
  /* The grid forced the right column to a fixed share, so wide buttons
     spilled past the topbar. Flex gives each cluster its natural width. */
  .cb-shell__topbar {
    display: flex;
    justify-content: space-between;
    padding: 0 0.5rem;
    gap: 0.5rem;
  }
  .cb-shell__topbar-left,
  .cb-shell__topbar-right {
    justify-self: auto;
    flex: 0 0 auto;
  }
  /* Right cluster gets crowded here — drop the separator and its gutter and
     let the plain 0.5rem flex gap do the spacing. */
  .cb-shell__topbar-right .cb-shell__viewport {
    margin-right: 0;
  }
  .cb-shell__topbar-right .cb-shell__viewport::after {
    display: none;
  }
  /* Icon-only: the long label wrapped on narrow screens and pushed
     Publish out of the row. */
  .cb-shell__discard {
    padding: 0.375rem 0.5rem;
  }
  .cb-shell__discard .cb-shell__btn-icon {
    display: inline-flex;
    font-size: 1.15rem;
  }
  .cb-shell__discard .cb-shell__btn-label {
    display: none;
  }
  /* The Actions toggle keeps its word — it is the only thing naming what is
     behind it, and the menu rows below it are already labelled. */
  .cb-shell__actions-toggle {
    padding: 0.375rem 0.5rem;
  }
  .cb-shell__actions-list {
    min-width: 200px;
    max-width: calc(100vw - 24px);
  }
  .cb-replace-picker {
    width: calc(100% - 16px);
    max-height: calc(100% - 32px);
  }
  /* Icon-only, like Discard: the word does not fit beside it here. */
  .cb-shell__tree-toggle,
  .cb-shell__public-link {
    padding: 0.375rem 0.5rem;
  }
  .cb-shell__tree-toggle .cb-shell__btn-label,
  .cb-shell__public-link .cb-shell__btn-label {
    display: none;
  }
  /* The sidebar is a bottom sheet here, so the panel takes the full width
     instead of clearing a left column that no longer exists. */
  .cb-tree,
  .cb-shell--sidebar-collapsed .cb-tree {
    left: 8px;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    max-height: calc(100% - 96px);
  }
  .cb-shell__publish {
    padding: 0.375rem 0.65rem;
    font-size: 0.85rem;
  }
  .cb-shell__viewport-btn {
    padding: 0.25rem 0.55rem;
  }
}

/* ---- Main area: 2-column grid ----
   The sidebar claims a column rather than floating over the iframe. */

.cb-shell__main {
  display: grid;
  grid-template-columns: var(--cb-sidebar-width) 1fr;
  overflow: hidden;
  /* Only ever visible in the gutters, when the viewport switcher narrows
     the iframe — where it reads as "the stage, not the page". */
  background:
    radial-gradient(circle at 1px 1px, var(--cb-line-strong) 1px, transparent 0) 0 0 / 24px 24px,
    var(--cb-surface);
  min-height: 0;
}

.cb-shell--sidebar-collapsed .cb-shell__main {
  grid-template-columns: var(--cb-sidebar-collapsed-width) 1fr;
}

.cb-shell__iframe {
  border: 0;
  background: var(--cb-panel);
  width: 100%;
  height: 100%;
  display: block;
  /* Gives the content time to reflow with its media queries, instead of
     flashing a horizontal scrollbar as the size jumps. */
  transition:
    max-width 0.2s ease,
    margin 0.2s ease;
}

.cb-shell__sidebar {
  position: relative;
  background: var(--cb-panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--cb-line);
  /* Accent rule along the sidebar's top edge — the one place the chrome
     accent appears as a surface rather than as text or a control. */
  box-shadow:
    inset 0 3px 0 var(--cb-accent),
    2px 0 12px rgba(var(--cb-shadow-rgb), 0.04);
  min-width: 0;
  /* Without min-height:0 a tall form grows past its track and lower fields
     become unreachable. No overflow:hidden: the toggle overhangs. */
  min-height: 0;
}

/* Collapsed: hide content, resize handle, saved-flash; only the
   toggle chip remains visible to expand back. */
.cb-shell--sidebar-collapsed .cb-shell__sidebar-content,
.cb-shell--sidebar-collapsed .cb-shell__sidebar-resize,
.cb-shell--sidebar-collapsed .cb-shell__sidebar-saved {
  display: none;
}

.cb-shell__sidebar-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: col-resize;
  z-index: 6;
  transition: background-color 0.12s ease-out;
}
.cb-shell__sidebar-resize:hover,
.cb-shell__sidebar-resize:active {
  background-color: rgba(var(--cb-accent-rgb), 0.35);
}

/* Overhangs the gutter by half its width, so it stays clickable and visible
   even when the sidebar is collapsed to its stub. */
.cb-shell__sidebar-toggle {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translate(50%, -50%);
  z-index: 10;
  width: 26px;
  height: 26px;
  background: var(--cb-panel);
  border: 1px solid var(--cb-line-strong);
  border-radius: 50%;
  box-shadow: var(--cb-shadow-control);
  color: var(--cb-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cb-shell__sidebar-toggle:hover {
  background: var(--cb-surface);
  color: var(--cb-text);
}
.cb-shell__sidebar-toggle-icon {
  display: inline-block;
  transition: transform 0.15s ease-out;
}
.cb-shell--sidebar-collapsed .cb-shell__sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* Mobile: the sidebar becomes a bottom sheet collapsing to a 32px strip.
   AFTER the desktop rules: a media query does not bump specificity. */
@media (max-width: 768px) {
  .cb-shell__main {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .cb-shell--sidebar-collapsed .cb-shell__main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .cb-shell__sidebar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60vh;
    border-right: 0;
    border-top: 1px solid var(--cb-line);
    box-shadow: 0 -2px 12px rgba(var(--cb-shadow-rgb), 0.08);
    z-index: 5;
    transition: transform 0.22s ease-out;
  }
  .cb-shell--sidebar-collapsed .cb-shell__sidebar {
    /* A translate, so the layout height stays intact and
       getBoundingClientRect still reports the visual position. */
    transform: translateY(calc(100% - 32px));
  }
  .cb-shell__sidebar-resize {
    display: none;
  }
  /* Overhangs upward so it reads as a grab handle — the same chip as on
     desktop, just moved with the sheet. */
  .cb-shell__sidebar-toggle {
    top: 0;
    right: auto;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  /* A left-arrow at rest, rotated so it reads as down when expanded and
     up when collapsed. */
  .cb-shell__sidebar-toggle-icon {
    transform: rotate(-90deg);
  }
  .cb-shell--sidebar-collapsed .cb-shell__sidebar-toggle-icon {
    transform: rotate(90deg);
  }
}

/* Transient "Saved" pill fired by autosave. role="status" carries the
   screen-reader announcement; this is only the visible half. */
.cb-shell__sidebar-saved {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(var(--cb-success-rgb), 0.12);
  color: var(--cb-success);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
.cb-shell__sidebar-saved.is-visible {
  opacity: 1;
}
.cb-shell__sidebar-saved[hidden] {
  display: none;
}

.cb-shell__sidebar-content {
  flex: 1 1 auto;
  /* Lets the flex child shrink past its content, so overflow-y can
     actually scroll inside the sidebar. */
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
}

/* Keeps the sidebar useful before anything is clicked: a hint plus the
   add-section buttons, mirroring the iframe's own empty tray. */
.cb-sidebar-empty {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.cb-sidebar-empty__hint {
  margin: 0;
  color: var(--cb-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.cb-sidebar-empty__sections {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cb-sidebar-empty__sections-label {
  margin: 0;
  color: var(--cb-text);
  font-size: 0.85rem;
  font-weight: 600;
}
.cb-sidebar-empty__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.cb-sidebar-empty__btn {
  background: var(--cb-panel);
  border: 1px solid var(--cb-line-strong);
  border-radius: var(--cb-radius-sm);
  color: var(--cb-muted);
  cursor: pointer;
  padding: 0.5rem;
  line-height: 0;
  transition:
    border-color 0.12s ease,
    color 0.12s ease,
    background-color 0.12s ease;
}
.cb-sidebar-empty__btn:hover,
.cb-sidebar-empty__btn:focus-visible {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
  background: rgba(var(--cb-accent-rgb), 0.06);
  outline: none;
}

/* (The visually-hidden helper lives in forms.css as .cb-form-sr-only —
   used by the in-form save buttons that the header Save delegates to.) */

/* (Add-section UI now lives inside the iframe — see builder.css's
   .cb-add-section-tray.) */

/* ---- Sidebar panels (`cb_panel`) ----
   Native <details>: a shared `name` keeps one open per group, no JS. */

.cb-panel {
  border-top: 1px solid var(--cb-line);
}
.cb-panel:not(:has(+ .cb-panel)) {
  border-bottom: 1px solid var(--cb-line);
  margin-bottom: var(--cb-form-gap, 0.75rem);
}

.cb-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.65rem 0.125rem;
  list-style: none;
  color: var(--cb-text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.cb-panel__header::-webkit-details-marker {
  display: none;
}

/* The chevron: a bordered corner turned right, then down once open. */
.cb-panel__header::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin: 0 3px 0 2px;
  border-right: 1.5px solid var(--cb-faint);
  border-bottom: 1.5px solid var(--cb-faint);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.cb-panel[open] > .cb-panel__header::before {
  border-color: var(--cb-accent);
  transform: rotate(45deg);
}

.cb-panel__header:hover .cb-panel__title {
  color: var(--cb-accent);
}
.cb-panel__header:focus-visible {
  outline: 2px solid var(--cb-accent-soft);
  outline-offset: 2px;
  border-radius: var(--cb-radius-xs);
}

.cb-panel__title {
  flex: none;
}

/* Filled by cb-tabs from the fields; only shown while the panel is shut. */
.cb-panel__summary {
  flex: 1;
  min-width: 0;
  text-align: right;
  color: var(--cb-faint);
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-panel__summary::before {
  content: attr(data-cb-summary);
}
.cb-panel[open] > .cb-panel__header .cb-panel__summary {
  visibility: hidden;
}

/* A dot for "something is set in here", red for "something is wrong". */
.cb-panel[data-cb-filled] > .cb-panel__header::after,
.cb-panel--has-error > .cb-panel__header::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cb-accent);
}
.cb-panel--has-error > .cb-panel__header::after {
  background: var(--cb-danger);
}

.cb-panel__body {
  padding: 0.25rem 0.125rem 1rem;
}
.cb-panel__body > :last-child {
  margin-bottom: 0;
}

/* ---- Block edit form: heading ----
   Which block is being edited; its SVG sits in a tinted chip. */

.cb-block__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.5rem;
}

.cb-block__heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--cb-accent);
  background: rgba(var(--cb-accent-rgb), 0.1);
}

.cb-block__heading-icon svg {
  width: 16px;
  height: 16px;
}

.cb-block__heading-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cb-text);
  letter-spacing: 0.01em;
}

/* ---- Sidebar tabs (`cb_group`) ----
   Block and section sidebars alike; hidden panels stay in the DOM. */

.cb-sidebar-tabs {
  display: flex;
  flex-direction: column;
}

/* Sticky, so tabs stay reachable on a tall form. The negative top and
   matching padding swallow the container's own, so no field peeks above. */
.cb-sidebar-tabs__list {
  position: sticky;
  top: -1rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 1rem;
  padding-top: 1rem;
  background: var(--cb-panel);
  border-bottom: 1px solid var(--cb-line);
}

/* Folder tabs, not an underlined word: these switch the whole panel, and a
   shape keeps the segmented pill meaning "pick a value" only. */
.cb-sidebar-tabs__tab {
  appearance: none;
  padding: 6px 12px;
  /* Sit on the strip's bottom line so the active tab can cover it. */
  margin-bottom: -1px;
  border: 1px solid var(--cb-line);
  border-top-width: 2px;
  border-radius: var(--cb-radius-sm) var(--cb-radius-sm) 0 0;
  background: var(--cb-panel-2);
  color: var(--cb-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.cb-sidebar-tabs__tab:hover:not(.cb-sidebar-tabs__tab--active) {
  background: var(--cb-panel-2);
  color: var(--cb-text);
}

.cb-sidebar-tabs__tab--active {
  background: var(--cb-panel);
  border-top-color: var(--cb-accent);
  border-bottom-color: var(--cb-panel);
  color: var(--cb-text);
  font-weight: 700;
}

/* Red dot on a tab whose panel holds an invalid field, so an error on a
   hidden tab is still discoverable after a save. */
.cb-sidebar-tabs__tab--has-error::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--cb-danger);
}

.cb-sidebar-tabs__panel[hidden] {
  display: none;
}

/* ---- Help tooltip (`cb_help_tooltip`) ---- */

/* The bubble spans the help line, so it never runs off the sidebar. */
.cb-form-help:has(> .cb-help-tip) {
  position: relative;
}

.cb-help-tip {
  display: inline-flex;
  margin-left: 4px;
  vertical-align: -3px;
}

.cb-help-tip__button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--cb-line-hover);
  border-radius: 50%;
  background: var(--cb-panel);
  color: var(--cb-muted);
  font: italic 600 10px/1 Georgia, "Times New Roman", serif;
  cursor: help;
}
.cb-help-tip__button:hover,
.cb-help-tip__button:focus-visible {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
  outline: 0;
}

.cb-help-tip__bubble {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 20;
  padding: 8px 10px;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-inverse-surface);
  color: var(--cb-on-solid);
  font-size: 0.75rem;
  font-style: normal;
  line-height: 1.45;
  box-shadow: 0 6px 16px rgba(var(--cb-shadow-rgb), 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}
.cb-help-tip:hover .cb-help-tip__bubble,
.cb-help-tip:focus-within .cb-help-tip__bubble {
  opacity: 1;
  visibility: visible;
}

/* ---- Styling: responsive box spacing (padding / margin) ---- */

.cb-form-row__header {
  margin-bottom: 0.375rem;
}

.cb-viewport-tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--cb-panel-2);
  border-radius: var(--cb-radius-sm);
  padding: 2px;
}

.cb-viewport-tabs__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--cb-muted);
  padding: 2px 8px;
  border-radius: var(--cb-radius-xs);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}

.cb-viewport-tabs__btn--active {
  background: var(--cb-panel);
  color: var(--cb-text);
  box-shadow: var(--cb-shadow-selected);
}

.cb-responsive-box-spacing__viewport[hidden] {
  display: none;
}

/* ---- Styling: 4-side box spacing ---- */

.cb-box-spacing {
  border: 1px solid var(--cb-line);
  border-radius: var(--cb-radius-sm);
  padding: 0.5rem;
  background: var(--cb-panel-3);
}

.cb-box-spacing__sides {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 0.375rem;
  align-items: end;
}

.cb-box-spacing__side {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-box-spacing__label {
  font-family: var(--cb-font-mono);
  font-size: var(--cb-caption-size-sm);
  color: var(--cb-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  order: 2;
  margin: 0;
}

.cb-box-spacing__input {
  text-align: center;
  order: 1;
}

.cb-box-spacing__link {
  appearance: none;
  border: 1px solid var(--cb-line-strong);
  background: var(--cb-panel);
  color: var(--cb-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--cb-radius-xs);
  align-self: start;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.cb-box-spacing--linked .cb-box-spacing__link,
.cb-box-spacing__link[aria-pressed="true"] {
  background: var(--cb-accent);
  color: var(--cb-on-solid);
  border-color: var(--cb-accent);
}

/* ---- Styling: length input (value + unit) ---- */

.cb-length {
  max-width: 160px;
}

.cb-length__unit {
  max-width: 72px;
  flex: 0 0 auto;
}

/* ---- Icon choices (`cb_icons`) ----
   An invisible native input covers each option: clicks land on the radio. */

.cb-icon-choice {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  background: var(--cb-panel-2);
  border-radius: var(--cb-radius-sm);
}
.cb-icon-choice--grid {
  display: inline-grid;
  grid-template-columns: repeat(var(--cb-icon-cols, 3), auto);
}
.cb-icon-choice--labelled {
  display: flex;
}
.cb-icon-choice--labelled.cb-icon-choice--grid {
  display: grid;
  grid-template-columns: repeat(var(--cb-icon-cols, 3), minmax(0, 1fr));
}

.cb-icon-choice__option {
  position: relative;
  display: flex;
  margin: 0;
}
.cb-icon-choice--labelled.cb-icon-choice--row .cb-icon-choice__option {
  flex: 1 1 0;
  min-width: 0;
}

.cb-icon-choice__input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cb-icon-choice__input:disabled {
  cursor: not-allowed;
}

.cb-icon-choice__face {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  border-radius: var(--cb-radius-xs);
  color: var(--cb-muted);
  font-size: 0.75rem;
  font-weight: 600;
  transition:
    background-color 0.08s,
    color 0.08s;
}
.cb-icon-choice--grid .cb-icon-choice__face {
  width: 30px;
  height: 30px;
  min-width: 0;
  padding: 0;
}
.cb-icon-choice--labelled.cb-icon-choice--grid .cb-icon-choice__face {
  flex-direction: column;
  width: auto;
  height: auto;
  min-height: 52px;
  padding: 6px 4px;
  gap: 4px;
}

/* No icon to draw: the option reads as text, a whole row in a grid. */
.cb-icon-choice--grid .cb-icon-choice__option--text {
  grid-column: 1 / -1;
}
.cb-icon-choice--grid .cb-icon-choice__option--text .cb-icon-choice__face {
  width: auto;
  padding: 0 8px;
}

.cb-icon-choice__text {
  min-width: 0;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.cb-icon-choice .cb-ui-icon {
  flex: none;
}

.cb-icon-choice__option:hover .cb-icon-choice__input:not(:disabled, :checked) + .cb-icon-choice__face {
  background: rgba(var(--cb-on-solid-rgb), 0.6);
  color: var(--cb-text);
}
.cb-icon-choice__input:checked + .cb-icon-choice__face {
  background: var(--cb-accent);
  color: var(--cb-on-solid);
  box-shadow: var(--cb-shadow-selected);
}
.cb-icon-choice__option:hover .cb-icon-choice__input:checked + .cb-icon-choice__face {
  background: var(--cb-accent-strong);
}
.cb-icon-choice__input:focus-visible + .cb-icon-choice__face {
  outline: 2px solid var(--cb-accent-soft);
  outline-offset: 2px;
}
.cb-icon-choice__input:disabled + .cb-icon-choice__face {
  opacity: 0.35;
}

/* Undo / redo. Same segmented shape as the viewport group, so the topbar
   reads as two groups of controls rather than a row of loose buttons. */
.cb-shell__history {
  display: inline-flex;
  background: var(--cb-surface);
  border-radius: var(--cb-radius-sm);
  padding: 0.125rem;
  margin-left: 0.5rem;
}
.cb-shell__history-btn {
  background: transparent;
  border: 0;
  padding: 0.25rem 0.625rem;
  cursor: pointer;
  color: var(--cb-text);
  border-radius: var(--cb-radius-xs);
  font-size: 1.1rem;
  line-height: 1;
}
.cb-shell__history-btn:hover:not(:disabled) {
  background: var(--cb-panel);
}
/* Greyed rather than hidden: the pair is where the shortcut is discovered,
   so it has to be visible before there is anything to undo. */
.cb-shell__history-btn:disabled {
  color: var(--cb-muted);
  opacity: 0.45;
  cursor: default;
}

/* ---- Elevation ----
   One shadow for fields, three steps for buttons; focus rings stay theirs. */

.cb-shell .cb-form-control:not(:focus),
.cb-shell .cb-form-select:not(:focus),
.cb-shell .cb-form-range-wrap__number:not(:focus),
.cb-shell .cb-form-file:not(:focus-within),
.cb-shell .cb-form-check__input:not(:focus-visible),
.cb-shell .cb-col-widths__input:not(:focus),
.cb-replace-picker__search:not(:focus),
.cb-template-picker__search:not(:focus) {
  box-shadow: var(--cb-shadow-field);
}

.cb-launcher__button:not(:focus-visible),
.cb-shell .cb-form-btn:not(:focus-visible),
.cb-shell .cb-col-widths__preset:not(:focus-visible),
.cb-box-spacing__link:not(:focus-visible),
.cb-sidebar-empty__btn:not(:focus-visible),
.cb-template-picker__item-btn:not(:focus-visible),
.cb-help-tip__button:not(:focus-visible),
.cb-shell__publish:not([disabled], :focus-visible) {
  box-shadow: var(--cb-shadow-control);
}

/* Lifts under the pointer; the text-like topbar buttons only then. */
.cb-launcher__button:hover:not(:focus-visible),
.cb-shell .cb-form-btn:hover:not(:disabled, :focus-visible),
.cb-shell .cb-col-widths__preset:hover:not(:focus-visible),
.cb-box-spacing__link:hover:not(:focus-visible),
.cb-sidebar-empty__btn:hover:not(:focus-visible),
.cb-template-picker__item-btn:hover:not(:focus-visible),
.cb-shell__sidebar-toggle:hover,
.cb-shell__publish:hover:not([disabled], :focus-visible),
.cb-shell__discard:hover:not([disabled]),
.cb-shell__tree-toggle:hover,
.cb-shell__public-link:hover {
  box-shadow: var(--cb-shadow-control-hover);
}

.cb-shell__tree-toggle--open,
.cb-shell .cb-col-widths__preset--active:not(:focus-visible),
.cb-box-spacing--linked .cb-box-spacing__link:not(:focus-visible),
.cb-box-spacing__link[aria-pressed="true"]:not(:focus-visible) {
  box-shadow: var(--cb-shadow-selected);
}
