    /* ── Edit Panel ── */
    /* Theme-driven custom properties (overridden by JS via applyTheme) */
    /* Block containers and their controls are driven by the --e-* tokens,
       which applyEditTokens() sets from the active theme's `edit` set.
       Every literal below is kept as the var fallback, so anything rendered
       outside the themed scope is unaffected. The app shell — sidebar,
       toolbar, file tree, theme panel — is intentionally not themed. */
    #edit-panel {
      --doc-bg: var(--e-surface, var(--ui-surface));
      --title-color: var(--e-doc-title, var(--ui-text));
      --heading-color: var(--e-doc-heading, var(--ui-accent));
      --paragraph-color: var(--e-doc-para, var(--ui-text-3));
      background: var(--e-surface, var(--ui-surface)) !important;
      color: var(--e-text2, var(--ui-text-3));
      border: 1px solid var(--e-line, var(--ui-line));
      box-shadow: var(--ui-shadow-md);
      transition: background-color 0.15s, border-color 0.15s;
      border-radius: 10px;
      padding: 14px 14px 10px;
    }

    #edit-panel .block-row {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      margin-bottom: 6px;
    }

    #edit-panel .block-type {
      flex-shrink: 0;
      align-self: stretch;            /* grow with the block height */
      width: 22px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      color: var(--e-accent, var(--ui-accent));
      background: var(--e-sunken, var(--ui-bg));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      padding: 4px 0 5px;
      cursor: grab;
      user-select: none;
      overflow: hidden;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    #edit-panel .block-type:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      color: var(--e-accent-on, #fff);
    }
    #edit-panel .block-type:active { cursor: grabbing; }

    .drag-grip {
      flex-shrink: 0;
      color: var(--e-muted, var(--ui-muted));
      display: inline-flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }
    #edit-panel .block-type:hover .drag-grip { color: var(--e-accent-2, var(--ui-accent-soft)); }

    .block-type-label {
      flex: 1;
      display: grid;
      place-items: center;
      writing-mode: vertical-rl;
      text-orientation: mixed;
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.12em;
    }

    /* Row drag/drop states */
    #edit-panel .block-row {
      position: relative;
      transition: opacity 0.1s;
    }
    #edit-panel .block-row.is-dragging {
      opacity: 0.4;
    }
    #edit-panel .block-row.drop-above::before,
    #edit-panel .block-row.drop-below::after {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      height: 2px;
      background: var(--e-accent, var(--ui-accent));
      border-radius: 2px;
      box-shadow: 0 0 8px rgba(var(--e-accent-rgb, 79,163,232), 0.5);
      pointer-events: none;
    }
    #edit-panel .block-row.drop-above::before { top: -3px; }
    #edit-panel .block-row.drop-below::after  { bottom: -3px; }

    /* Insert-between-blocks affordance — a thin line with a + that
       reveals on hover of the gap, opening a block-type menu on click. */
    .insert-line {
      position: relative;
      height: 14px;
      margin: -4px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.12s;
    }
    .insert-line:hover,
    .insert-line.menu-open { opacity: 1; }
    .insert-line::before {
      content: '';
      position: absolute;
      left: 8px;
      right: 8px;
      height: 2px;
      background: linear-gradient(90deg, transparent, var(--e-accent-line, var(--ui-line-strong)) 12%, var(--e-accent-line, var(--ui-line-strong)) 88%, transparent);
      border-radius: 2px;
      pointer-events: none;
    }
    .insert-line-btn {
      position: relative;
      z-index: 1;
      width: 22px;
      height: 22px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--e-accent-line, var(--ui-line-strong));
      border-radius: 50%;
      background: var(--e-surface, var(--ui-surface));
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      line-height: 1;
      padding: 0;
      transition: background 0.1s, border-color 0.1s, color 0.1s, transform 0.1s;
    }
    .insert-line-btn:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      color: var(--e-accent-on, #fff);
      transform: scale(1.08);
    }
    .insert-line-btn svg { display: block; flex: none; }
    .insert-menu { max-height: 70vh; overflow-y: auto; min-width: 184px; }
    .insert-menu-head {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--e-dim, var(--ui-dim));
      padding: 4px 10px 6px;
    }

    #edit-panel .block-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      resize: none;
      font-family: inherit;
      background: transparent;
      color: var(--e-text, var(--ui-text));
      line-height: 1.6;
      overflow: hidden;
      min-height: 32px;
      max-width: 100%;
      word-break: break-word;
      overflow-wrap: break-word;
      caret-color: var(--e-accent, var(--ui-accent));
    }
    #edit-panel .block-input::placeholder { color: var(--e-muted, var(--ui-muted)); }

    #edit-panel .block-input.type-title    { font-size: 33.6px; font-weight: 700; color: var(--title-color); text-align: center; }
    #edit-panel .block-input.type-heading  { font-size: 21.6px; font-weight: 600; color: var(--heading-color); }
    #edit-panel .block-input.type-paragraph { font-size: 14px; color: var(--paragraph-color); }

    .para-list-edit { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 8px; }
    .para-list-edit > .block-input { flex: 1; min-width: 0; }
    .para-list-mark {
      flex-shrink: 0;
      color: var(--paragraph-color);
      font-size: 14px;
      line-height: 1.6;
      min-height: 32px;
      display: flex;
      align-items: flex-start;
      user-select: none;
    }
    .para-list-mark.is-number { min-width: 1.6em; justify-content: flex-end; text-align: right; font-variant-numeric: tabular-nums; }

    /* ── Heading style picker (pills to the right of the heading textarea) ── */
    .head-block-edit { flex: 1; min-width: 0; display: flex; flex-direction: row; align-items: flex-start; gap: 10px; }
    .head-block-edit > textarea { flex: 1; min-width: 0; }
    .head-style-bar { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; justify-content: flex-end; padding-top: 2px; }
    .head-style-pill {
      padding: 3px 12px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 999px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-dim-2, var(--ui-dim-2));
      font-family: inherit;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.03em;
      cursor: pointer;
      transition: background 0.12s, color 0.12s, border-color 0.12s;
    }
    .head-style-pill:hover { border-color: var(--e-accent-line, var(--ui-line-strong)); color: var(--e-accent-2, var(--ui-accent-soft)); }
    .head-style-pill.is-active { background: var(--e-accent-soft, #14365e); border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent-3, var(--ui-text-2)); }

    .editor-pill {
      display: inline-flex; align-items: center; justify-content: center; gap: 6px;
      min-height: 28px; max-width: 100%; padding: 5px 11px;
      border: 1px solid var(--e-line, var(--ui-line)); border-radius: 999px;
      background: var(--e-surface, var(--ui-surface)); color: var(--e-text2, var(--ui-text-3));
      font: inherit; font-size: 11px; font-weight: 600; line-height: 1.2; letter-spacing: 0;
      cursor: pointer; transition: background .12s, border-color .12s, color .12s;
    }
    .editor-pill:hover { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .editor-pill[aria-pressed="true"] { background: var(--e-accent-soft, var(--ui-hover)); border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .editor-pill:focus-visible { outline: 2px solid var(--e-accent, var(--ui-accent)); outline-offset: 2px; }
    .editor-pill-indicator { display: inline-flex; width: 12px; height: 12px; flex-shrink: 0; }
    .editor-pill-indicator svg { opacity: 0; }
    .editor-pill[aria-pressed="true"] .editor-pill-indicator svg { opacity: 1; }
    .editor-accordion { border: 1px solid var(--e-line, var(--ui-line)); border-radius: 6px; background: var(--e-surface, var(--ui-surface)); color: var(--e-text, var(--ui-text)); }
    .editor-accordion > summary { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 9px 10px; list-style: none; cursor: pointer; user-select: none; font-size: 12px; font-weight: 600; line-height: 1.3; letter-spacing: 0; color: var(--e-text2, var(--ui-text-3)); border-radius: 5px; }
    .editor-accordion > summary::-webkit-details-marker { display: none; }
    .editor-accordion > summary::marker { content: ''; }
    .editor-accordion > summary:hover { background: var(--e-hover, var(--ui-hover)); color: var(--e-accent, var(--ui-accent)); }
    .editor-accordion > summary:focus-visible { outline: 2px solid var(--e-accent, var(--ui-accent)); outline-offset: -2px; }
    .editor-accordion[open] > summary { color: var(--e-accent, var(--ui-accent)); }
    .editor-accordion-chevron { display: inline-flex; flex-shrink: 0; transition: transform .15s; }
    .editor-accordion[open] > summary .editor-accordion-chevron { transform: rotate(90deg); }
    .editor-accordion-body { padding: 8px 10px 12px; border-top: 1px solid var(--e-line, var(--ui-line)); }

    /* ── Placeholder block ── */
    .ph-block {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;
      border: 1.5px dashed var(--e-line, var(--ui-line));
      border-radius: 8px;
      background: var(--e-sunken-2, var(--ui-sunken));
      position: relative;
      flex: 1;
      transition: border-color .15s, background .15s;
    }
    .ph-block.ph-drag {
      border-color: var(--e-ac-green, var(--ui-ok));
      background: var(--e-ac-green-bg, var(--ui-ok-bg));
    }
    .ph-block.ph-drag .ph-input::placeholder { color: var(--e-ac-green, var(--ui-ok)); }
    .ph-input {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      font-size: 14px;
      font-family: inherit;
      color: var(--e-accent-3, var(--ui-text-2));
      caret-color: var(--e-accent, var(--ui-accent));
      min-width: 0;
    }
    .ph-input::placeholder { color: var(--e-muted, var(--ui-muted)); font-style: italic; }
    .ph-hint {
      font-size: 11px;
      color: var(--e-muted, var(--ui-muted));
      white-space: nowrap;
      font-style: italic;
      flex-shrink: 0;
    }
    /* On narrow screens the hint can't fit beside the input — drop it so the
       placeholder field keeps full width and never overlaps. */
    @media (max-width: 600px) {
      .ph-block { gap: 6px; padding: 8px; }
      .ph-hint { display: none; }
    }
    .ph-autocomplete {
      position: absolute;
      left: 0; right: 0; top: calc(100% + 4px);
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      padding: 6px;
      z-index: 200;
      box-shadow: var(--ui-shadow-lg);
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 4px;
      max-height: 232px;
      overflow-y: auto;
    }
    .ph-ac-item {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      min-width: 0;
      text-align: left;
      padding: 7px 9px;
      font-size: 13px;
      font-family: inherit;
      color: var(--e-accent-3, var(--ui-text-2));
      background: transparent;
      border: none;
      border-radius: 6px;
      cursor: pointer;
    }
    .ph-ac-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ph-ac-item.is-active { background: var(--e-accent-solid, var(--ui-accent-solid)); color: var(--e-accent-on, #fff); }
    .ph-ac-item:hover { background: var(--e-hover, var(--ui-hover)); }
    .ph-ac-item.is-active:hover { background: var(--e-accent-solid, var(--ui-accent-solid)); }
    .ph-ac-key {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .06em;
      color: var(--e-accent, var(--ui-accent));
      background: var(--e-sunken, var(--ui-bg));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      padding: 1px 5px;
      font-family: ui-monospace, monospace;
      flex-shrink: 0;
    }
    .ph-ac-item.is-active .ph-ac-key { color: var(--e-accent-on, var(--e-accent-on, #fff)); border-color: var(--e-accent, var(--ui-accent)); background: var(--e-accent-solid, var(--ui-accent-solid)); }

    #edit-panel .block-gear {
      flex-shrink: 0;
      width: 100%;
      height: 14px;
      border: none;
      background: none;
      color: var(--e-muted, var(--ui-muted));
      cursor: pointer;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 3px;
      transition: color 0.1s, background 0.1s;
    }
    #edit-panel .block-gear:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: rgba(var(--e-accent-rgb, 79,163,232), 0.10); }
    #edit-panel .block-gear svg { width: 12px; height: 12px; display: block; }

    .block-menu {
      position: absolute;
      left: 28px;
      top: 0;
      z-index: 40;
      display: none;
      min-width: 176px;
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      padding: 6px;
      box-shadow: var(--ui-shadow-lg);
    }
    .block-menu.is-open { display: block; }
    .block-menu-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--e-dim-2, var(--ui-dim-2));
      padding: 2px 4px 6px;
    }
    .block-menu-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 4px; }
    .block-menu-sep { height: 1px; background: var(--e-line, var(--ui-line)); margin: 6px 2px; }
    .block-menu-item {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 8px;
      border: none;
      background: none;
      color: var(--e-text2, var(--ui-text-3));
      font: inherit;
      font-size: 13px;
      text-align: left;
      padding: 7px 8px;
      border-radius: 5px;
      cursor: pointer;
      transition: color 0.1s, background 0.1s;
    }
    .block-menu-item:hover { background: var(--e-hover, var(--ui-hover)); color: var(--e-text, var(--ui-text)); }
    .block-menu-del { color: var(--e-ac-red, var(--ui-danger)); }
    .block-menu-del:hover { color: var(--e-ac-red, var(--ui-danger)); background: var(--e-ac-red-bg, var(--ui-danger-bg)); }

    /* ── Type cycle hint ── */
    .type-hint {
      font-size: 11px;
      color: var(--e-muted, var(--ui-muted));
      margin-top: 14px;
    }

    /* ── Signature block (edit panel) ── */
    /* Mirrors the View card: label in the header, document colours throughout. */
    #edit-panel .block-input.type-signature {
      flex: 1;
      min-height: 0;
      font-size: 13.6px;
      font-weight: 600;
      letter-spacing: 0.05em;
      line-height: 1.4;
      color: var(--heading-color, var(--e-accent, var(--ui-accent)));
    }

    .sig-edit-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
    .sig-edit-preview {
      --sig-line: color-mix(in srgb, var(--heading-color, var(--e-line, var(--ui-line))) 20%, transparent);
      margin: 0 0 4px 0;
      padding: 14px 18px 12px;
      border: 1px solid var(--sig-line);
      border-radius: 8px;
      background: var(--doc-bg, transparent);
    }
    .sig-edit-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
      padding-bottom: 7px;
      border-bottom: 1px solid var(--sig-line);
    }
    .sig-edit-action { flex-shrink: 0; display: inline-flex; align-items: center; gap: 9px; }

    .sig-line-row {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 20px;
      margin-bottom: 12px;
    }
    .sig-line-row--bottom { margin-bottom: 8px; }

    .sig-field {
      flex: 1;
      min-width: 0;
    }

    .sig-line {
      height: 24px;
      border-bottom: 1px solid color-mix(in srgb, var(--paragraph-color, var(--e-muted, var(--ui-muted))) 40%, transparent);
      margin-bottom: 4px;
    }

    .sig-field-label {
      font-size: 9px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: color-mix(in srgb, var(--paragraph-color, var(--e-muted, var(--ui-muted))) 60%, transparent);
      font-weight: 600;
    }

    .sig-line { position: relative; }
    .sig-signed-img {
      position: absolute; left: 0; bottom: -13px; z-index: 1;
      max-height: 54px; max-width: 100%; object-fit: contain; object-position: left bottom;
      pointer-events: none;
    }
    .sig-signed-ink {
      display: block; font-size: 12px; line-height: 24px; color: var(--e-text, var(--ui-text));
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .sig-signed-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--e-ac-green, var(--ui-ok)); }
    .sig-sign-btn {
      flex-shrink: 0;
      font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
      padding: 4px 10px; border-radius: 3px;
      border: 1px solid var(--e-muted, var(--ui-muted)); background: transparent; color: var(--e-accent, var(--ui-accent)); cursor: pointer;
      transition: border-color 0.12s, color 0.12s, background 0.12s;
    }
    .sig-sign-btn:hover { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent-on, #fff); background: var(--e-accent-solid, var(--ui-accent-solid)); }
    .sig-witness-section {
      margin-top: 12px;
    }
    .sig-witness-toggle {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 9px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 999px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-dim-2, var(--ui-dim-2));
      cursor: pointer;
      font-family: inherit;
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      transition: border-color 0.12s, color 0.12s;
    }
    .sig-witness-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--e-muted, var(--ui-muted));
      transition: background 0.12s;
    }
    .sig-witness-toggle.is-on { border-color: var(--e-ac-green, var(--ui-ok)); color: var(--e-ac-green, var(--ui-ok)); }
    .sig-witness-toggle.is-on .sig-witness-dot { background: var(--e-ac-green, var(--ui-ok)); }
    .sig-witness-toggle:hover { color: var(--e-text, var(--ui-text)); }
    .sig-witness-preview {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px dashed var(--sig-line, var(--e-line, var(--ui-line)));
    }
    .sig-witness-label {
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: color-mix(in srgb, var(--paragraph-color, var(--e-muted, var(--ui-muted))) 60%, transparent);
      margin-bottom: 10px;
    }

    /* ── Image block (edit panel) ── */
    .img-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }

    .img-dropzone {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 28px 18px;
      border: 1.5px dashed var(--e-muted, var(--ui-muted));
      border-radius: 8px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.4);
      color: var(--e-dim, var(--ui-dim));
      cursor: pointer;
      outline: none;
      transition: border-color 0.15s, background 0.15s, color 0.15s;
    }
    .img-dropzone:hover,
    .img-dropzone:focus {
      border-color: var(--e-accent, var(--ui-accent));
      background: var(--e-accent-soft, var(--ui-accent-tint));
      color: var(--e-accent, var(--ui-accent));
    }
    .img-dropzone.is-drag {
      border-color: var(--e-ac-green, var(--ui-ok));
      background: var(--e-ac-green-bg, var(--ui-ok-bg));
      color: var(--e-ac-green, var(--ui-ok));
    }
    .img-dropzone-title {
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }
    .img-dropzone-sub {
      font-size: 11px;
      color: var(--e-muted, var(--ui-muted));
      letter-spacing: 0.02em;
    }
    .img-dropzone-link {
      color: var(--e-accent, var(--ui-accent));
      text-decoration: underline;
      text-underline-offset: 2px;
    }

    /* WYSIWYG preview — mirrors how the image prints in the document:
       centered on the document background at its chosen width percentage. */
    .img-preview-canvas {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 24px 18px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px 8px 0 0;
      background: var(--doc-bg, var(--e-surface, var(--ui-surface)));
      overflow: hidden;
    }
    .img-preview-img {
      display: block;
      height: auto;
      border-radius: 4px;
      box-shadow: 0 2px 10px rgba(0,0,0,.25);
    }
    .img-toolbar {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      padding: 9px 12px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-top: none;
      border-radius: 0 0 8px 8px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.6);
    }
    .img-size-group {
      display: inline-flex;
      gap: 2px;
      background: var(--e-sunken, var(--ui-bg));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 6px;
      padding: 2px;
    }
    .img-size-btn {
      padding: 4px 10px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.02em;
      border: none;
      background: transparent;
      color: var(--e-dim-2, var(--ui-dim-3));
      cursor: pointer;
      border-radius: 4px;
      font-family: inherit;
      transition: background 0.1s, color 0.1s;
    }
    .img-size-btn:hover { color: var(--e-accent-3, var(--ui-text-2)); }
    .img-size-btn.is-active { background: var(--e-accent-solid, var(--ui-accent-solid)); color: var(--e-accent-on, #fff); }
    .img-toolbar-meta {
      font-size: 10px;
      color: var(--e-dim, var(--ui-dim));
      font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
      letter-spacing: 0.02em;
    }
    .img-toolbar-spacer { flex: 1; }
    .img-replace-btn {
      padding: 5px 12px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .img-replace-btn:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      color: var(--e-accent-on, #fff);
    }

    /* ── Attachment block (edit panel) ── */
    .att-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }

    .att-dropzone {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 28px 18px;
      border: 1.5px dashed var(--e-muted, var(--ui-muted));
      border-radius: 8px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.4);
      color: var(--e-dim, var(--ui-dim));
      cursor: pointer;
      outline: none;
      transition: border-color 0.15s, background 0.15s, color 0.15s;
    }
    .att-dropzone:hover,
    .att-dropzone:focus {
      border-color: var(--e-accent, var(--ui-accent));
      background: var(--e-accent-soft, var(--ui-accent-tint));
      color: var(--e-accent, var(--ui-accent));
    }
    .att-dropzone.is-drag {
      border-color: var(--e-ac-green, var(--ui-ok));
      background: var(--e-ac-green-bg, var(--ui-ok-bg));
      color: var(--e-ac-green, var(--ui-ok));
    }
    .att-dropzone-title {
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }
    .att-dropzone-sub {
      font-size: 11px;
      color: var(--e-muted, var(--ui-muted));
      letter-spacing: 0.02em;
    }
    .att-dropzone-link {
      color: var(--e-accent, var(--ui-accent));
      text-decoration: underline;
      text-underline-offset: 2px;
    }

    .att-card {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 12px 14px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.6);
    }
    .att-embed-bar { margin-top: 12px; }
    .att-icon {
      flex-shrink: 0;
      width: 48px;
      height: 56px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--e-sunken, var(--ui-bg));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.04em;
      color: var(--e-accent, var(--ui-accent));
      position: relative;
    }
    .att-icon::before {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      width: 10px;
      height: 10px;
      background: var(--e-line, var(--ui-line));
      clip-path: polygon(0 0, 100% 100%, 100% 0);
    }
    .att-meta {
      flex: 1;
      min-width: 0;
    }
    .att-filename {
      font-size: 14px;
      font-weight: 600;
      color: var(--e-text, var(--ui-text));
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .att-sub {
      font-size: 12px;
      color: var(--e-dim-2, var(--ui-dim-2));
      font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
      margin-top: 2px;
    }
    .att-replace-btn {
      padding: 6px 12px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      flex-shrink: 0;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .att-replace-btn:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      color: var(--e-accent-on, #fff);
    }

    .sp-coords { display: inline-flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--e-dim-2, var(--ui-dim-2)); }
    .sp-coords code { font-size: 10.5px; }
    .sp-coords a { color: var(--e-accent, var(--ui-accent)); text-decoration: none; border-bottom: 1px solid currentColor; }

    /* ── Map snapshot picker ── */
    /* Tall dialog: cap the height and let the map shrink, so the heading and
       the footer buttons stay reachable on short viewports. */
    .map-dialog { max-width: 660px; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
    .map-dialog .dialog-footer { margin-top: auto; }
    .map-search-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
    .map-search-row .name-input { flex: 1; min-width: 0; margin: 0; }
    .map-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
    .map-layer-btn.is-on { background: var(--ui-accent-tint); border-color: var(--ui-accent); color: var(--ui-accent); }
    .map-bar .map-spacer { flex: 1; }
    .map-zoom { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ui-dim-2); }
    .map-zoom .button { padding: 4px 10px; font-size: 12px; line-height: 1; }
    .map-view {
      /* Square, so the capture takes in as much context as possible. Shrinks
         with the viewport but never stops being 1:1. */
      position: relative;
      width: min(100%, 46vh);
      aspect-ratio: 1 / 1;
      min-height: 150px;
      margin: 0 auto;
      overflow: hidden;
      border: 1px solid var(--ui-line);
      border-radius: 8px;
      background: var(--ui-bg);
      cursor: grab;
      touch-action: none;
      user-select: none;
    }
    .map-view.is-panning { cursor: grabbing; }
    .map-tiles { position: absolute; inset: 0; }
    .map-tiles img { position: absolute; width: 256px; height: 256px; display: block; }
    .map-cross {
      position: absolute; left: 50%; top: 50%;
      width: 18px; height: 18px; margin: -9px 0 0 -9px;
      border: 2px solid rgba(255,255,255,0.85);
      border-radius: 50%;
      box-shadow: 0 0 0 1px rgba(0,0,0,0.45);
      pointer-events: none;
    }
    .map-attrib {
      position: absolute; right: 0; bottom: 0;
      font-size: 10px; padding: 2px 6px;
      background: rgba(0,0,0,0.55); color: #e6f1fb;
      pointer-events: none;
    }
    .map-busy {
      position: absolute; inset: 0; display: none;
      align-items: center; justify-content: center;
      background: rgba(243, 244, 246, 0.78); color: var(--ui-text-3); font-size: 12px;
    }
    .map-busy.is-on { display: flex; }

    /* ── Site Plan block (edit panel) ── */
    .sp-block-edit { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
    .sp-body { display: flex; flex-direction: column; gap: 10px; }
    .sp-canvas {
      position: relative; flex: 1 1 auto; min-width: 0; line-height: 0;
      border: 1px solid var(--e-line, var(--ui-line)); border-radius: 6px; overflow: hidden;
      cursor: crosshair; background: var(--e-sunken, var(--ui-bg));
    }
    .sp-canvas.is-panning { cursor: grabbing; }
    .sp-stage { position: absolute; left: 0; top: 0; width: 100%; transform-origin: 0 0; }
    .sp-zoom { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--e-dim-2, var(--ui-dim-2)); }
    .sp-zoom button {
      background: var(--e-sunken, var(--ui-bg)); color: inherit; border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px; padding: 2px 7px; font-size: 10.5px; line-height: 1.4; cursor: pointer;
    }
    .sp-zoom button:hover { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .sp-zoom-val { min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
    .sp-pills { display: inline-flex; gap: 2px; padding: 2px; background: var(--e-sunken, var(--ui-bg)); border: 1px solid var(--e-line, var(--ui-line)); border-radius: 999px; }
    .sp-pill {
      background: none; border: none; color: var(--e-dim-2, var(--ui-dim-2));
      font-size: 10.5px; line-height: 1.4; padding: 3px 10px; border-radius: 999px; cursor: pointer;
    }
    .sp-pill:hover { color: var(--e-text, var(--ui-text)); }
    .sp-pill.is-on { background: var(--e-accent-solid, var(--ui-accent-solid)); color: var(--e-accent-on, #fff); }
    .tb-col-menu.sp-menu { padding: 4px; min-width: 170px; background: var(--e-surface, var(--ui-surface)); border: 1px solid var(--e-line, var(--ui-line)); box-shadow: var(--ui-shadow-lg); }
    .sp-menu .sp-menu-item {
      display: block; width: 100%; text-align: left; background: none; border: none;
      color: var(--e-text2, var(--ui-text-2)); font-size: 12px; padding: 6px 10px; border-radius: 5px; cursor: pointer;
    }
    .sp-menu .sp-menu-item:hover { background: var(--e-hover, var(--ui-hover)); color: var(--e-text, var(--ui-text)); }
    .sp-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
    .sp-canvas.is-drawing { cursor: crosshair; }
    .sp-zoom button.is-on { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .sp-line-head { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--e-dim-2, var(--ui-dim-2)); margin: 10px 0 4px; }
    .sp-row-cal {
      background: none; border: none; cursor: pointer; padding: 0 3px;
      color: var(--e-dim-2, var(--ui-dim-2)); font-size: 12px; line-height: 1;
    }
    .sp-row-cal:hover { color: var(--e-accent, var(--ui-accent)); }
    .sp-line-len { font-size: 12px; color: var(--e-dim-2, var(--ui-dim-2)); font-variant-numeric: tabular-nums; white-space: nowrap; }
    .sp-img { display: block; width: 100%; height: auto; user-select: none; }
    .sp-pin {
      position: absolute; transform: translate(-50%, -100%); transform-origin: 50% 100%;
      width: 22px; height: 28px; padding: 0; border: none; background: none;
      cursor: grab; line-height: 0;
      filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
    }
    .sp-pin::before {
      content: ''; position: absolute; inset: 0;
      background: var(--sp-pin-color, var(--e-accent, var(--ui-accent)));
      clip-path: path('M11 27C11 27 20 16.5 20 10.2A9 9 0 1 0 2 10.2C2 16.5 11 27 11 27Z');
    }
    .sp-pin.is-active::before, .sp-pin:hover::before { filter: brightness(1.25); }
    .sp-pin.is-dragging { cursor: grabbing; }
    /* Label pins: a pill of text with a small stem, anchored at the same point
       as the numbered teardrop. */
    .sp-pin.is-label {
      width: auto; height: auto; line-height: 1.3;
      padding: 0 0 7px;
    }
    .sp-pin.is-label::before { display: none; }
    .sp-pin.is-label::after {
      content: ''; position: absolute; left: 50%; bottom: 0;
      width: 2px; height: 8px; margin-left: -1px;
      background: var(--sp-pin-color, var(--e-accent, var(--ui-accent)));
    }
    .sp-pin-text {
      display: block; white-space: nowrap;
      background: var(--sp-pin-color, var(--e-accent, var(--ui-accent)));
      color: var(--e-accent-on, #fff); font-size: 10px; font-weight: 700;
      padding: 3px 7px; border-radius: 4px;
      max-width: 180px; overflow: hidden; text-overflow: ellipsis;
    }
    .sp-pin-num {
      position: absolute; top: 3px; left: 0; right: 0; height: 16px;
      display: flex; align-items: center; justify-content: center;
      font-family: inherit; font-size: 10px; font-weight: 700; line-height: 1;
      color: var(--e-accent-on, #fff);
    }
    .sp-legend {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0 10px;
      border: 1px solid var(--e-line, var(--ui-line)); border-radius: 6px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.4);
      padding: 4px 8px 6px;
    }
    .sp-legend-head {
      grid-column: 1 / -1;
      display: flex; align-items: center; justify-content: space-between;
      padding: 4px 0 5px; border-bottom: 1px solid var(--e-line, var(--ui-line));
      font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--e-dim, var(--ui-dim));
    }
    .sp-legend-count { color: var(--e-accent, var(--ui-accent)); }
    .sp-legend-empty { grid-column: 1 / -1; padding: 8px 0; font-size: 12px; line-height: 1.5; color: var(--e-dim, var(--ui-dim)); }
    .sp-row {
      display: flex; align-items: center; gap: 6px; padding: 4px 2px;
      min-width: 0;
      border-bottom: 1px solid var(--e-line, #15304f);
      transition: background 0.15s;
    }
    .sp-row.is-flash { background: color-mix(in srgb, var(--e-accent, var(--ui-accent)) 20%, transparent); }
    .sp-row.is-dragging { opacity: 0.4; }
    .sp-row.drop-above { box-shadow: inset 0 2px 0 0 var(--e-accent, var(--ui-accent)); }
    .sp-row.drop-below { box-shadow: inset 0 -2px 0 0 var(--e-accent, var(--ui-accent)); }
    .sp-row-grip {
      flex-shrink: 0; width: 10px; cursor: grab; user-select: none;
      color: var(--e-muted, var(--ui-muted)); font-size: 9px; letter-spacing: -1px; line-height: 1;
    }
    .sp-row-grip:hover { color: var(--e-accent-2, var(--ui-accent-soft)); }
    .sp-row-grip:active { cursor: grabbing; }
    .sp-row-num {
      flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
      display: inline-flex; align-items: center; justify-content: center;
      background: var(--e-accent, var(--ui-accent)); color: var(--e-accent-on, #fff);
      font-size: 9.5px; font-weight: 700; line-height: 1;
    }
    .sp-row-label {
      flex: 1; min-width: 0; border: none; background: none; outline: none;
      font-family: inherit; font-size: 12px; color: var(--e-text, var(--ui-text)); padding: 2px 0;
    }
    .sp-row-label::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .sp-row-swatch {
      flex-shrink: 0; width: 13px; height: 13px; border-radius: 3px; padding: 0;
      border: 1px solid var(--e-line, var(--ui-line)); cursor: pointer;
    }
    .sp-row-swatch:hover { border-color: var(--e-accent-2, var(--ui-accent-soft)); }
    .sp-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 8px; }
    .sp-swatch-auto {
      background: linear-gradient(135deg, var(--e-accent, var(--ui-accent)) 50%, transparent 50%);
      border: 1px solid var(--e-line, var(--ui-line));
    }
    .sp-row-rm {
      flex-shrink: 0; width: 18px; height: 18px; border: none; background: none;
      color: var(--e-muted, var(--ui-muted)); font-size: 14px; line-height: 1; cursor: pointer; border-radius: 3px;
    }
    .sp-row-rm:hover { color: var(--e-ac-red, var(--ui-danger)); background: var(--e-ac-red-bg, var(--ui-danger-bg)); }
    .sp-toolbar {
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
      font-size: 11px; color: var(--e-dim, var(--ui-dim));
    }
    .sp-toolbar-hint { color: var(--e-muted, var(--ui-muted)); flex: 1 1 100%; white-space: nowrap; }

    /* ── Timeline block (edit panel) ── */
    .tl-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }
    .tl-editor {
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      padding: 16px 18px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.6);
    }
    .tl-editor-header {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      margin-bottom: 14px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--e-line, var(--ui-line));
    }
    .tl-editor-title {
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--heading-color, var(--e-accent, var(--ui-accent)));
    }
    .tl-editor-sub {
      font-size: 11px;
      color: var(--e-dim-2, var(--ui-dim-2));
      font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    }
    .tl-grip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 14px;
      align-self: flex-start;
      margin-top: 5px;
      flex-shrink: 0;
      cursor: grab;
      color: var(--e-dim, var(--ui-dim));
      background: none;
      border: none;
      padding: 2px 0;
      border-radius: 3px;
      font-size: 11px;
      line-height: 1;
      user-select: none;
    }
    .tl-grip:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: color-mix(in srgb, var(--e-accent, var(--ui-accent)) 12%, transparent); }
    .tl-grip:active { cursor: grabbing; }
    .tl-row.tl-dragging { opacity: 0.4; }
    .tl-row.tl-drop-above { box-shadow: inset 0 2px 0 0 var(--e-accent, var(--ui-accent)); }
    .tl-row.tl-drop-below { box-shadow: inset 0 -2px 0 0 var(--e-accent, var(--ui-accent)); }
    .tl-empty {
      font-size: 12px;
      color: var(--e-muted, var(--ui-muted));
      font-style: italic;
      padding: 6px 0 10px;
    }
    .tl-row {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 8px 0;
      border-bottom: 1px dashed var(--e-line, var(--ui-line));
    }
    .tl-row:last-of-type {
      border-bottom: none;
    }
    /* Status colours follow the document's heading colour, as in View. */
    .tl-dot {
      flex-shrink: 0;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      border: 2px solid var(--heading-color, var(--e-accent, var(--ui-accent)));
      background: var(--e-sunken, var(--ui-bg));
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--heading-color, var(--e-accent, var(--ui-accent)));
      font-size: 12px;
      font-weight: 700;
      font-family: inherit;
      padding: 0;
      margin-top: 4px;
      transition: background 0.1s, border-color 0.1s, color 0.1s, transform 0.05s;
    }
    .tl-dot:hover { transform: scale(1.08); }
    .tl-dot.tl-dot-done {
      background: var(--heading-color, var(--e-accent, var(--ui-accent)));
      color: var(--doc-bg, var(--e-sunken, var(--ui-bg)));
    }
    .tl-dot.tl-dot-active {
      background: var(--doc-bg, var(--e-sunken, var(--ui-bg)));
      border-color: var(--heading-color, var(--e-accent, var(--ui-accent)));
    }
    .tl-dot.tl-dot-active .tl-dot-inner {
      display: inline-block;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--heading-color, var(--e-accent, var(--ui-accent)));
    }
    .tl-dot.tl-dot-upcoming {
      background: var(--e-sunken, var(--ui-bg));
      border-style: dashed;
      border-color: var(--e-muted, var(--ui-muted));
      color: transparent;
    }
    .tl-fields {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .tl-top-row {
      display: flex;
      gap: 10px;
    }
    .tl-date,
    .tl-title,
    .tl-body {
      border: none;
      outline: none;
      background: transparent;
      color: var(--e-text, var(--ui-text));
      font-family: inherit;
      padding: 4px 0;
      resize: none;
      line-height: 1.5;
    }
    .tl-date {
      flex: 0 0 130px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: var(--paragraph-color, var(--e-text2, var(--ui-text-3)));
    }
    .tl-row.is-done .tl-date,
    .tl-row.is-active .tl-date { color: var(--heading-color, var(--e-accent, var(--ui-accent))); }
    .tl-title {
      flex: 1;
      min-width: 0;
      font-size: 14px;
      font-weight: 600;
      color: var(--title-color, var(--e-text, var(--ui-text)));
    }
    .tl-body {
      width: 100%;
      font-size: 12px;
      color: var(--paragraph-color, var(--e-text2, var(--ui-text-3)));
      overflow: hidden;
      min-height: 22px;
    }
    .tl-date::placeholder,
    .tl-title::placeholder,
    .tl-body::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .tl-remove {
      flex-shrink: 0;
      width: 20px;
      height: 20px;
      border: none;
      background: none;
      color: var(--e-muted, var(--ui-muted));
      cursor: pointer;
      font-size: 16px;
      line-height: 1;
      border-radius: 3px;
      margin-top: 5px;
      transition: color 0.1s, background 0.1s;
    }
    .tl-remove:hover { color: var(--e-ac-red, var(--ui-danger)); background: var(--e-ac-red-bg, var(--ui-danger-bg)); }
    .tl-add {
      margin-top: 12px;
      padding: 6px 12px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      border: 1px dashed var(--e-muted, var(--ui-muted));
      border-radius: 5px;
      background: transparent;
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .tl-add:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      border-style: solid;
      color: var(--e-accent-on, #fff);
    }

    /* ── Checklist block (edit panel) ── */
    .cl-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }
    .cl-editor {
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      padding: 16px 18px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.6);
    }
    .cl-editor-header {
      display: flex;
      align-items: baseline;
      gap: 12px;
      margin-bottom: 12px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--e-line, var(--ui-line));
    }
    .cl-title-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--heading-color, var(--e-accent, var(--ui-accent)));
      font-family: inherit;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      padding: 2px 0;
    }
    .cl-title-input::placeholder {
      color: var(--e-muted, var(--ui-muted));
      letter-spacing: 0;
      font-weight: 600;
    }
    .cl-editor-count {
      flex-shrink: 0;
      font-size: 12px;
      color: var(--e-dim-2, var(--ui-dim-2));
      font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    }
    .cl-empty {
      font-size: 12px;
      color: var(--e-muted, var(--ui-muted));
      font-style: italic;
      padding: 6px 0 10px;
    }
    .cl-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 4px 0;
    }
    .cl-box {
      flex-shrink: 0;
      width: 20px;
      height: 20px;
      border-radius: 4px;
      border: 1.5px solid var(--e-muted, var(--ui-muted));
      background: transparent;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--e-sunken, var(--ui-bg));
      font-size: 12px;
      font-weight: 700;
      font-family: inherit;
      padding: 0;
      line-height: 1;
      transition: background 0.1s, border-color 0.1s, transform 0.05s;
    }
    .cl-box:hover { border-color: var(--e-accent, var(--ui-accent)); }
    .cl-box.is-done {
      background: var(--e-accent, var(--ui-accent));
      border-color: var(--e-accent, var(--ui-accent));
    }
    .cl-text {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--e-text, var(--ui-text));
      font-family: inherit;
      font-size: 14px;
      padding: 4px 0;
      line-height: 1.5;
    }
    .cl-text::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .cl-text.is-done {
      color: var(--e-dim-2, var(--ui-dim-2));
      text-decoration: line-through;
    }
    .cl-remove {
      flex-shrink: 0;
      width: 20px;
      height: 20px;
      border: none;
      background: none;
      color: var(--e-muted, var(--ui-muted));
      cursor: pointer;
      font-size: 16px;
      line-height: 1;
      border-radius: 3px;
      transition: color 0.1s, background 0.1s;
    }
    .cl-remove:hover { color: var(--e-ac-red, var(--ui-danger)); background: var(--e-ac-red-bg, var(--ui-danger-bg)); }
    .cl-add {
      margin-top: 12px;
      padding: 6px 12px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      border: 1px dashed var(--e-muted, var(--ui-muted));
      border-radius: 5px;
      background: transparent;
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .cl-add:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      border-style: solid;
      color: var(--e-accent-on, #fff);
    }

    /* ── Table block (edit panel) ── */
    .tb-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }
    .chart-block-edit { flex: 1; min-width: 0; }
    .chart-editor .tb-editor-header { flex-wrap: wrap; }
    .chart-editor .tb-title-input { letter-spacing: 0; }
    .chart-editor .chart-summary { width: 100%; font-size: 12px; font-weight: 400; color: var(--e-text2, var(--ui-text-3)); }
    .chart-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
    .chart-tools input[type="color"] { width: 22px; height: 22px; padding: 0; border: 1px solid var(--e-line, var(--ui-line)); background: transparent; cursor: pointer; }
    .chart-swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
    .chart-swatches button { width: 14px; height: 14px; border: 1px solid transparent; border-radius: 2px; cursor: pointer; padding: 0; }
    .chart-swatches button[aria-pressed="true"] { outline: 2px solid var(--e-text, var(--ui-text)); outline-offset: 1px; }
    .chart-editor .tb-grid { table-layout: fixed; }
    .chart-editor .tb-th { vertical-align: top; }
    .chart-editor .tb-col-name { flex: 1; min-width: 0; width: 100%; letter-spacing: 0; }
    .chart-editor .tb-cell[aria-invalid="true"] { outline: 1px solid var(--ui-danger, #c2413f); }
    .chart-error { color: var(--ui-danger, #c2413f); font-size: 12px; margin-top: 6px; overflow-wrap: anywhere; }
    .chart-error:empty { display: none; }
    .chart-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .chart-actions .tb-add { display: inline-flex; align-items: center; gap: 6px; letter-spacing: 0; }
    .chart-actions .tb-add:disabled { opacity: .45; cursor: default; }
    .chart-preview.pd-doc { padding: 0; margin: 0 0 12px; border-radius: 0; box-shadow: none; max-width: none; }
    .chart-preview .pd-chart { margin-top: 8px; }
    .chart-quick-settings { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 0; border-top: 1px solid var(--e-line, var(--ui-line)); }
    .chart-inline-settings { margin: 0 0 12px; }
    .chart-inline-settings .chart-settings { width: 100%; box-sizing: border-box; max-height: none; padding: 8px 10px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 0 18px; }
    .chart-inline-settings .chart-settings > details, .chart-inline-settings .chart-error { grid-column: 1 / -1; }
    .chart-settings { width: 225px; max-height: 55vh; overflow-y: auto; padding: 4px 8px; font-size: 12px; color: var(--e-text, var(--ui-text)); }
    .chart-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; }
    .chart-option span { min-width: 0; overflow-wrap: anywhere; }
    .chart-option input:not([type="checkbox"]), .chart-option select { width: 110px; min-width: 0; border: 1px solid var(--e-line, var(--ui-line)); border-radius: 3px; background: var(--e-sunken, var(--ui-bg)); color: var(--e-text, var(--ui-text)); font: inherit; padding: 4px; }
    .chart-option input[type="checkbox"] { accent-color: var(--e-accent, var(--ui-accent)); }
    .chart-type-switch { display: inline-flex; gap: 4px; padding-right: 10px; margin-right: 4px; border-right: 1px solid var(--e-line, var(--ui-line)); }
    .chart-series-pick { margin-left: auto; padding: 0; gap: 8px; font-size: 12px; color: var(--e-dim-2, var(--ui-dim-2)); }
    .chart-series-pick select { width: auto; max-width: 180px; }
    .chart-editor.is-donut .chart-tools { display: none; }
    .chart-editor .tb-td.has-row-color { position: relative; }
    .chart-editor .has-row-color .tb-cell { padding-left: 24px; }
    .chart-row-color {
      position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
      width: 13px; height: 13px; padding: 0; border: none; border-radius: 3px; cursor: pointer;
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
    }
    .chart-row-color.is-empty { background: transparent; box-shadow: inset 0 0 0 1px var(--e-muted, var(--ui-muted)); }
    .chart-row-color:hover { transform: translateY(-50%) scale(1.15); }
    .chart-paste { z-index: 999; }
    .chart-paste .dialog { width: 560px; max-width: calc(100vw - 32px); }
    .chart-paste textarea { width: 100%; height: 210px; resize: vertical; background: var(--ui-bg); color: var(--ui-text); border: 1px solid var(--ui-line); border-radius: 4px; padding: 8px; font-family: monospace; }
    .chart-paste label { display: flex; gap: 8px; align-items: center; padding: 8px 0; font-size: 12px; }

    .tb-editor {
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      padding: 14px 16px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.6);
    }
    .tb-editor-header {
      display: flex;
      align-items: baseline;
      gap: 12px;
      margin-bottom: 10px;
      padding-bottom: 8px;
      border-bottom: 1px solid var(--e-line, var(--ui-line));
    }
    .tb-title-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--heading-color, var(--e-accent, var(--ui-accent)));
      font-family: inherit;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      padding: 2px 0;
    }
    .tb-title-input::placeholder { color: var(--e-muted, var(--ui-muted)); letter-spacing: 0; font-weight: 600; }
    .tb-editor-meta {
      flex-shrink: 0;
      font-size: 12px;
      color: var(--e-dim-2, var(--ui-dim-2));
      font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    }
    .tb-empty,
    .tb-empty-row {
      font-size: 12px;
      color: var(--e-muted, var(--ui-muted));
      font-style: italic;
      padding: 8px 4px;
      text-align: center;
    }
    .tb-grid {
      width: 100%;
      border-collapse: collapse;
      font-family: inherit;
      font-size: 12px;
      table-layout: auto;
    }
    .tb-scroller {
      overflow-x: auto;
      margin: 0 -4px;
      padding: 0 4px 4px;
      scrollbar-width: thin;
      scrollbar-color: var(--e-line, var(--ui-line)) transparent;
    }
    .tb-scroller::-webkit-scrollbar { height: 8px; }
    .tb-scroller::-webkit-scrollbar-track { background: transparent; }
    .tb-scroller::-webkit-scrollbar-thumb {
      background: var(--e-line, var(--ui-line));
      border-radius: 4px;
    }
    .tb-scroller::-webkit-scrollbar-thumb:hover { background: var(--e-muted, var(--ui-muted)); }
    /* Inside the scroller, the table fills the available width and lets
       cells shrink as small as needed. Fixed layout gives each column an
       equal share rather than letting one greedy column dominate. */
    .tb-scroller .tb-grid {
      width: 100%;
      table-layout: fixed;
    }
    .tb-scroller .tb-th,
    .tb-scroller .tb-td { min-width: 0; overflow: hidden; }
    .tb-scroller .tb-cell,
    .tb-scroller .tb-col-name {
      min-width: 0;
      width: 100%;
    }
    .tb-scroller .tb-th-add,
    .tb-scroller .tb-td-rm { width: 32px; min-width: 32px; }
    .tb-scroller .tb-th-grip,
    .tb-scroller .tb-td-grip { width: 24px; min-width: 24px; }
    .tb-th {
      text-align: left;
      padding: 0;
      border-bottom: 1px solid var(--e-line, var(--ui-line));
      vertical-align: middle;
      background: transparent;
    }
    .tb-th.is-decimal { text-align: right; }
    .tb-th-inner {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 6px 4px;
    }
    .tb-th.is-decimal .tb-th-inner { justify-content: flex-end; }
    .tb-col-name {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--e-accent-2, var(--ui-accent-soft));
      font-family: inherit;
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      padding: 2px 0;
    }
    .tb-th.is-decimal .tb-col-name { text-align: right; }
    .tb-col-name::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .tb-col-gear {
      flex-shrink: 0;
      border: none;
      background: none;
      color: var(--e-muted, var(--ui-muted));
      cursor: pointer;
      font-size: 12px;
      padding: 2px 4px;
      line-height: 1;
      border-radius: 3px;
      transition: color 0.1s, background 0.1s;
    }
    .tb-col-gear:hover { color: var(--e-accent, var(--ui-accent)); background: rgba(var(--e-accent-rgb, 79,163,232), 0.12); }
    .tb-sum-badge {
      flex-shrink: 0;
      font-size: 10px;
      font-weight: 700;
      color: var(--e-accent, var(--ui-accent));
      margin-left: 2px;
    }
    .tb-th-add {
      width: 32px;
      text-align: center;
      border-bottom: 1px solid var(--e-line, var(--ui-line));
    }
    .tb-col-add {
      width: 22px;
      height: 22px;
      border: 1px dashed var(--e-muted, var(--ui-muted));
      border-radius: 4px;
      background: transparent;
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      font-family: inherit;
      padding: 0;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .tb-col-add:hover { background: var(--e-accent-solid, var(--ui-accent-solid)); border-color: var(--e-accent, var(--ui-accent)); border-style: solid; color: var(--e-accent-on, var(--e-accent-on, #fff)); }
    .tb-td {
      padding: 0;
      border-bottom: 1px dashed var(--e-line, var(--ui-line));
      vertical-align: middle;
    }
    .tb-td.is-decimal { text-align: right; }
    .tb-cell {
      width: 100%;
      border: none;
      outline: none;
      background: transparent;
      color: var(--e-text, var(--ui-text));
      font-family: inherit;
      font-size: 12px;
      padding: 6px 4px;
      box-sizing: border-box;
      line-height: 1.5;
      min-width: 0;
    }
    .tb-td.is-decimal .tb-cell {
      text-align: right;
      font-variant-numeric: tabular-nums;
    }
    /* Text-column cell: wraps to multiple lines and auto-grows in height. */
    .tb-cell-text {
      resize: none;
      overflow: hidden;
      white-space: pre-wrap;
      overflow-wrap: break-word;
      word-break: break-word;
      line-height: 1.5;
    }
    .tb-scroller .tb-cell-text { width: 100%; }
    /* Line-number column — auto-counted, read-only, minimal width. */
    .tb-th.is-lineno .tb-th-inner { justify-content: flex-end; }
    .tb-th.is-lineno .tb-col-name { text-align: right; }
    .tb-td.is-lineno { text-align: right; }
    .tb-tf.is-lineno { text-align: right; }
    .tb-lineno {
      display: inline-block;
      padding: 6px 6px;
      font-size: 12px;
      color: var(--e-dim, var(--ui-dim));
      font-variant-numeric: tabular-nums;
    }
    .tb-cell:focus {
      background: rgba(var(--e-accent-rgb, 79,163,232), 0.08);
    }
    .tb-td-rm {
      width: 28px;
      text-align: center;
      border-bottom: 1px dashed var(--e-line, var(--ui-line));
    }
    .tb-row-rm {
      width: 22px;
      height: 22px;
      border: none;
      background: none;
      color: var(--e-muted, var(--ui-muted));
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      border-radius: 3px;
      padding: 0;
      transition: color 0.1s, background 0.1s;
    }
    .tb-row-rm:hover { color: var(--e-ac-red, var(--ui-danger)); background: var(--e-ac-red-bg, var(--ui-danger-bg)); }
    .tb-tf {
      padding: 6px 8px;
      border-top: 2px solid var(--e-line, var(--ui-line));
      color: var(--e-text, var(--ui-text));
      font-weight: 600;
      font-variant-numeric: tabular-nums;
    }
    /* A computed cell: same metrics as .tb-cell so rows stay aligned, but
       visibly inert — no field, dimmer ink, tabular figures. */
    .tb-cell-computed {
      display: block;
      width: 100%;
      padding: 5px 4px;
      font-family: inherit;
      font-size: 12px;
      text-align: right;
      font-variant-numeric: tabular-nums;
      color: var(--e-dim-2, var(--ui-dim-2));
      min-height: 1.4em;
      cursor: default;
    }
    .tb-fx-row {
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 2px 0 4px;
    }
    .tb-fx-row .tb-fx-col { flex: 1; min-width: 0; }
    .tb-fx-row .tb-fx-op { flex: 0 0 46px; text-align: center; }
    .tb-fx-note {
      font-size: 10px;
      color: var(--e-dim, var(--ui-dim));
      padding-bottom: 2px;
    }
    .tb-th-fx {
      flex-shrink: 0;
      font-size: 10px;
      color: var(--e-dim-2, var(--ui-dim-2));
      letter-spacing: 0.04em;
    }
    .tb-tf.is-decimal { text-align: right; }
    .tb-tf-label {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--e-dim-2, var(--ui-dim-2));
      font-weight: 700;
    }

    /* Row reordering — drag handle + drop indicators */
    .tb-th-grip {
      border-bottom: 1px solid var(--e-line, var(--ui-line));
      background: transparent;
    }
    .tb-td-grip {
      border-bottom: 1px dashed var(--e-line, var(--ui-line));
      text-align: center;
      vertical-align: middle;
    }
    .tb-row-grip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 18px;
      height: 22px;
      color: var(--e-muted, var(--ui-muted));
      font-size: 10px;
      letter-spacing: -1px;
      line-height: 1;
      cursor: grab;
      border-radius: 3px;
      transition: color 0.1s, background 0.1s;
      user-select: none;
    }
    .tb-row-grip:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: rgba(var(--e-accent-rgb, 79,163,232), 0.12); }
    .tb-row-grip:active { cursor: grabbing; }
    .tb-grid tr.tb-row-dragging { opacity: 0.4; }
    .tb-grid tr.tb-drop-above > td { box-shadow: inset 0 2px 0 0 var(--e-accent, var(--ui-accent)); }
    .tb-grid tr.tb-drop-below > td { box-shadow: inset 0 -2px 0 0 var(--e-accent, var(--ui-accent)); }

    /* Column reordering — drag handle + drop indicators */
    .tb-col-grip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      width: 14px;
      height: 20px;
      color: var(--e-muted, var(--ui-muted));
      font-size: 10px;
      letter-spacing: -1px;
      line-height: 1;
      cursor: grab;
      border-radius: 3px;
      transition: color 0.1s, background 0.1s;
      user-select: none;
    }
    .tb-col-grip:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: rgba(var(--e-accent-rgb, 79,163,232), 0.12); }
    .tb-col-grip:active { cursor: grabbing; }
    .tb-grid .tb-col-dragging { opacity: 0.4; }
    .tb-grid th.tb-drop-left, .tb-grid td.tb-drop-left { box-shadow: inset 2px 0 0 0 var(--e-accent, var(--ui-accent)); }
    .tb-grid th.tb-drop-right, .tb-grid td.tb-drop-right { box-shadow: inset -2px 0 0 0 var(--e-accent, var(--ui-accent)); }

    /* Column options popover */
    .tb-col-menu {
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 6px;
      padding: 8px 10px;
      box-shadow: var(--ui-shadow-lg);
      z-index: 1500;
      min-width: 200px;
      max-width: 260px;
      max-height: 70vh;
      overflow-y: auto;
      font-family: inherit;
    }
    /* Option-list editor inside the column menu */
    .tb-opt-head {
      font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
      color: var(--e-dim-2, var(--ui-dim-2)); margin: 2px 0 6px;
    }
    .tb-opt-row {
      display: grid;
      grid-template-columns: 1fr auto;
      align-items: center;
      gap: 6px;
      margin-bottom: 8px;
    }
    .tb-opt-label {
      background: var(--e-surface, var(--ui-surface)); border: 1px solid var(--e-line, var(--ui-line)); border-radius: 4px;
      color: var(--e-accent-3, var(--ui-text-2)); font-family: inherit; font-size: 12px; padding: 5px 8px; outline: none; min-width: 0;
    }
    .tb-opt-label:focus { border-color: var(--e-accent, var(--ui-accent)); }
    .tb-opt-rm {
      border: none; background: none; color: var(--e-dim-2, var(--ui-dim-2)); font-size: 17px; line-height: 1;
      cursor: pointer; padding: 0 4px; border-radius: 4px;
    }
    .tb-opt-rm:hover { color: var(--e-ac-red, var(--ui-danger)); }
    .tb-opt-swatches {
      grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 0 0;
    }
    .tb-opt-swatch {
      width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
      cursor: pointer; padding: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
    }
    .tb-opt-swatch.is-sel { border-color: var(--e-text, var(--ui-text)); box-shadow: 0 0 0 1px var(--e-surface, var(--ui-surface)); }
    .tb-opt-add {
      width: 100%; border: 1px dashed var(--e-line, var(--ui-line)); background: none; color: var(--e-accent, var(--ui-accent));
      cursor: pointer; font-size: 11px; font-weight: 600; padding: 6px; border-radius: 4px; margin-top: 2px;
    }
    .tb-opt-add:hover { border-color: var(--e-accent, var(--ui-accent)); background: rgba(var(--e-accent-rgb, 79,163,232), 0.08); }
    /* Option-list cell in the edit grid */
    .tb-cell-select {
      border: 1px solid var(--e-muted, var(--ui-muted)); border-radius: 999px;
      background: transparent; color: var(--e-accent-3, var(--ui-text-2));
      font-family: inherit; font-size: 12px; font-weight: 600;
      padding: 4px 22px 4px 11px; cursor: pointer; outline: none; max-width: 100%;
    }
    .tb-cell-select option { background: var(--e-sunken, var(--ui-bg)); color: var(--e-accent-3, var(--ui-text-2)); }
    .tb-col-menu-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 4px 0;
    }
    .tb-uniq { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
    .tb-col-menu-note {
      font-size: 10.5px;
      line-height: 1.5;
      color: var(--e-dim, var(--ui-dim-2));
      padding: 0 0 4px;
      max-width: 210px;
    }
    .tb-col-menu-label {
      font-size: 11px;
      color: var(--e-accent-2, var(--ui-accent-soft));
      font-weight: 600;
    }
    .tb-col-menu-select {
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      color: var(--e-accent, var(--ui-accent));
      font-family: inherit;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 20px 3px 6px;
      border-radius: 3px;
      cursor: pointer;
    }
    .tb-col-menu-check {
      width: 16px;
      height: 16px;
      accent-color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
    }
    .tb-col-menu-num {
      width: 72px;
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      color: var(--e-accent-3, var(--ui-text-2));
      font-family: inherit;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 6px;
      border-radius: 3px;
      outline: none;
      text-align: right;
    }
    .tb-col-menu-num:focus { border-color: var(--e-accent, var(--ui-accent)); }
    .tb-col-menu-divider {
      height: 1px;
      background: var(--e-line, var(--ui-line));
      margin: 6px 0;
    }
    .tb-col-menu-del {
      width: 100%;
      border: none;
      background: none;
      color: var(--e-ac-red, var(--ui-danger));
      cursor: pointer;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.03em;
      padding: 4px 0;
      text-align: left;
      font-family: inherit;
    }
    .tb-col-menu-del:hover { background: var(--e-ac-red-bg, var(--ui-danger-bg)); border-radius: 3px; }

    .tb-add {
      margin-top: 10px;
      padding: 6px 12px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      border: 1px dashed var(--e-muted, var(--ui-muted));
      border-radius: 5px;
      background: transparent;
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .tb-add:hover {
      background: var(--e-accent-solid, var(--ui-accent-solid));
      border-color: var(--e-accent, var(--ui-accent));
      border-style: solid;
      color: var(--e-accent-on, #fff);
    }

    /* ── Callout block (edit panel) ── */
    .co-block-edit {
      flex: 1;
      min-width: 0;
      margin-top: 2px;
    }
    .co-editor {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      border: 1px solid transparent;
      border-radius: 3px;
      padding: 10px 13px;
      min-height: 0;
      transition: background 0.15s, border-color 0.15s;
    }
    .co-editor > .co-body { flex: 1; min-width: 0; }
    .co-variant-pill {
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 9px;
      border: 1px solid;
      border-radius: 5px;
      font-family: inherit;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      cursor: pointer;
      transition: filter 0.1s;
    }
    .co-variant-pill:hover { filter: brightness(1.15); }
    .co-variant-caret { font-size: 8px; opacity: 0.7; }
    .co-editor-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 8px;
    }
    .co-variant-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border: 1px solid;
      border-radius: 999px;
      font-family: inherit;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      cursor: pointer;
      transition: filter 0.1s;
    }
    .co-variant-pill:hover { filter: brightness(1.15); }
    .co-icon {
      font-size: 13px;
      line-height: 1;
    }
    .co-variant-caret { font-size: 9px; opacity: 0.7; }
    .co-title-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--e-text, var(--ui-text));
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      padding: 2px 0;
    }
    .co-title-input::placeholder { color: var(--e-dim-2, var(--ui-dim-2)); }
    .co-body {
      width: 100%;
      border: none;
      outline: none;
      resize: none;
      background: transparent;
      color: var(--e-text2, var(--ui-text-3));
      font-family: inherit;
      font-size: 14px;
      line-height: 1.6;
      padding: 0;
      overflow: hidden;
      min-height: 24px;
    }
    .co-body::placeholder { color: var(--e-muted, var(--ui-muted)); }

    .co-variant-menu {
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 6px;
      padding: 5px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      box-shadow: var(--ui-shadow-lg);
      z-index: 1500;
      min-width: 130px;
      font-family: inherit;
    }
    .co-variant-opt {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      padding: 6px 10px;
      border: 1px solid;
      border-radius: 5px;
      font-family: inherit;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      text-align: left;
      cursor: pointer;
      transition: filter 0.1s;
    }
    .co-variant-opt:hover { filter: brightness(1.2); }
    .co-variant-opt.is-selected { box-shadow: 0 0 0 2px currentColor inset; }


    /* ── Form field editor (edit panel) ── */
    /* Mirrors the View output: tinted label band over a plain value, in the
       document's own heading / grid colours rather than the editor accent. */
    .fld-editor {
      --fld-grid: color-mix(in srgb, var(--paragraph-color, var(--e-text2, var(--ui-text-3))) 17%, transparent);
      --fld-tint: color-mix(in srgb, var(--heading-color, var(--e-accent, var(--ui-accent))) 6%, transparent);
      display: flex;
      flex-direction: column;
      border: 1px solid var(--fld-grid);
      border-radius: 3px;
      background: var(--doc-bg, transparent);
      padding: 0;
      gap: 0;
      overflow: hidden;
    }
    .fld-top-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 5px 8px;
      background: var(--fld-tint);
      border-bottom: 1px solid var(--fld-grid);
    }
    .fld-editor > .fld-value-preview { flex: 1; padding: 6px 8px; }
    .fld-editor > .fld-value-preview:focus-within { background: var(--e-hover, var(--ui-hover)); }
    .fld-editor.is-table-row { flex-direction: row; align-items: stretch; }
    .fld-editor.is-table-row > .fld-top-row {
      flex: 0 0 42%;
      min-width: 0;
      padding: 6px 9px;
      border-bottom: none;
      border-right: 1px solid var(--fld-grid);
    }
    .fld-editor.is-table-row > .fld-value-preview { min-width: 0; padding: 6px 9px; display: flex; align-items: center; }
    .fld-label-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--heading-color, var(--e-text, var(--ui-text)));
      font-family: inherit;
      font-size: 12px;
      font-weight: 700;
      padding: 0;
      line-height: 1.4;
    }
    .fld-label-input::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .fld-value-preview {
      min-width: 0;
      display: flex;
      align-items: center;
    }
    .fld-value-input {
      flex: 1;
      min-width: 0;
      border: none;
      outline: none;
      background: transparent;
      color: var(--title-color, var(--e-text2, var(--ui-text-3)));
      font-family: inherit;
      font-size: 12px;
      padding: 2px 0;
    }
    .fld-value-input::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .fld-opt-select {
      flex: 0 0 auto;
      max-width: 100%;
      cursor: pointer;
      padding: 3px 4px;
    }
    .fld-opt-select option { background: var(--e-sunken, var(--ui-bg)); color: var(--e-accent-3, var(--ui-text-2)); }
    .fld-value-multiline {
      min-height: 44px;
      resize: none;
      padding: 2px 0 !important;
      border: none !important;
      border-radius: 0;
      overflow: hidden;
    }

    /* ── Universal tri-state toggle (editor chrome) ── */
    .tri-toggle {
      position: relative;
      display: inline-flex;
      align-items: center;
      width: 66px;
      height: 24px;
      padding: 2px;
      border-radius: 999px;
      background: rgba(127, 145, 170, 0.16);
      border: 1px solid rgba(127, 145, 170, 0.42);
      box-sizing: border-box;
      cursor: pointer;
      user-select: none;
      flex-shrink: 0;
      outline: none;
      transition: border-color 0.15s, background 0.15s;
    }
    .tri-toggle:hover { border-color: rgba(127, 145, 170, 0.7); }
    .tri-toggle:focus-visible { border-color: var(--e-accent, var(--ui-accent)); box-shadow: 0 0 0 2px rgba(var(--e-accent-rgb, 79,163,232), 0.3); }
    .tri-toggle-seg {
      flex: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      line-height: 1;
      color: rgba(127, 145, 170, 0.6);
      pointer-events: none;
    }
    .tri-toggle-knob {
      position: absolute;
      top: 4px;
      left: 4px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #94a3b8;
      color: #fff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 800;
      line-height: 1;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
      pointer-events: none;
      transition: transform 0.18s cubic-bezier(.4, 0, .2, 1), background 0.15s;
    }
    .tri-toggle[data-state="false"] .tri-toggle-knob { transform: translateX(0);    background: #e0734f; }
    .tri-toggle[data-state="null"]  .tri-toggle-knob { transform: translateX(20px); background: #94a3b8; }
    .tri-toggle[data-state="true"]  .tri-toggle-knob { transform: translateX(40px); background: #2fa86e; }

    .fld-type-icon {
      display: inline-flex; align-items: center; justify-content: center;
      font-size: 11px;
      font-weight: 800;
    }

    .fld-type-menu {
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 6px;
      padding: 4px;
      box-shadow: var(--ui-shadow-lg);
      z-index: 1500;
      min-width: 140px;
      font-family: inherit;
    }
    .fld-type-opt {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 6px 10px;
      background: transparent;
      border: none;
      color: var(--e-accent-3, var(--ui-text-2));
      font-family: inherit;
      font-size: 12px;
      font-weight: 500;
      text-align: left;
      cursor: pointer;
      border-radius: 4px;
    }
    .fld-type-opt:hover { background: var(--e-hover, var(--ui-hover)); color: var(--e-text, var(--ui-text)); }
    .fld-type-opt.is-selected { background: rgba(var(--e-accent-rgb, 79,163,232), 0.15); color: var(--e-accent, var(--ui-accent)); }
    .fld-type-opt .fld-type-icon { width: 16px; text-align: center; color: var(--e-accent-2, var(--ui-accent-soft)); }

    /* ── Form block (edit panel) ── */
    .fm-block-edit { flex: 1; min-width: 0; margin-top: 2px; }
    .fm-editor { display: flex; flex-direction: column; gap: 12px; }
    .fm-editor-header { display: flex; align-items: center; gap: 10px; }
    .fm-title-input {
      flex: 1; min-width: 0; border: none; outline: none; background: transparent;
      color: var(--heading-color, var(--e-text, var(--ui-text))); font-family: inherit; font-size: 12px; font-weight: 600;
      border-bottom: 1px solid var(--e-line, var(--ui-line)); padding: 4px 2px;
    }
    .fm-title-input::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .fm-title-input:focus { border-bottom-color: var(--e-accent, var(--ui-accent)); }
    .fm-cols-seg {
      display: inline-flex; flex-shrink: 0;
      border: 1px solid var(--e-line, var(--ui-line)); border-radius: 6px; overflow: hidden;
    }
    .fm-cols-opt {
      border: none; background: none; cursor: pointer;
      font-family: inherit; font-size: 11px; font-weight: 600;
      padding: 3px 8px; color: var(--e-dim, var(--ui-dim));
    }
    .fm-cols-opt + .fm-cols-opt { border-left: 1px solid var(--e-line, var(--ui-line)); }
    .fm-cols-opt:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: color-mix(in srgb, var(--e-accent, var(--ui-accent)) 10%, transparent); }
    .fm-cols-opt.is-on { background: var(--e-accent-solid, var(--ui-accent-solid)); color: var(--e-accent-on, #fff); }
    .fm-editor-meta { flex-shrink: 0; font-size: 10px; color: var(--e-dim, var(--ui-dim)); font-weight: 600; }
    /* Drop-into affordance for whole-form targets (empty form / grid slack). */
    .fm-drop-into { outline: 2px dashed var(--ui-accent); outline-offset: 2px; border-radius: 8px; }
    .fm-empty { font-size: 12px; color: var(--e-dim, var(--ui-dim)); font-style: italic; padding: 8px 2px; }
    /* Builder grid mirrors the rendered form: exactly two columns, collapsing
       to one on a narrow editor. (Edit-only UI — never exported, so a class +
       media query is fine here; the View output uses self-contained inline CSS.) */
    .fm-edit-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      align-items: start;
    }
    @media (max-width: 640px) { .fm-edit-grid { grid-template-columns: 1fr; } }
    .fm-field-cell {
      position: relative;
      display: flex;
      flex-direction: row;
      align-items: stretch;
      gap: 8px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.4);
      padding: 5px;
      min-width: 0;
    }
    .fm-field-cell.is-fill { grid-column: 1 / -1; }
    .fm-field-cell.fm-cell-dragging { opacity: 0.4; }
    .fm-field-cell.fm-drop-left   { box-shadow: inset 2px 0 0 0 var(--e-accent, var(--ui-accent)); }
    .fm-field-cell.fm-drop-right  { box-shadow: inset -2px 0 0 0 var(--e-accent, var(--ui-accent)); }
    .fm-field-cell.fm-drop-top    { box-shadow: inset 0 2px 0 0 var(--e-accent, var(--ui-accent)); }
    .fm-field-cell.fm-drop-bottom { box-shadow: inset 0 -2px 0 0 var(--e-accent, var(--ui-accent)); }
    /* Left rail — same vocabulary as a block row's gutter: gear on top,
       drag grip below, stretching the full height of the cell. */
    .fm-cell-bar {
      flex-shrink: 0;
      align-self: stretch;
      width: 22px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      color: var(--e-accent, var(--ui-accent));
      background: var(--e-sunken, var(--ui-bg));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      padding: 4px 0 5px;
      user-select: none;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .fm-cell-bar:hover { border-color: var(--e-accent, var(--ui-accent)); }
    .fm-cell-grip {
      flex: 1;
      display: flex; align-items: flex-start; justify-content: center;
      width: 100%; min-height: 14px;
      color: var(--e-muted, var(--ui-muted)); font-size: 10px; letter-spacing: -1px; line-height: 1;
      cursor: grab; border-radius: 3px;
      transition: color 0.1s, background 0.1s;
    }
    .fm-cell-grip:hover { color: var(--e-accent-2, var(--ui-accent-soft)); }
    .fm-cell-grip:active { cursor: grabbing; }
    .fm-cell-gear {
      flex-shrink: 0;
      width: 100%; height: 14px;
      border: none; background: none; padding: 0;
      color: var(--e-muted, var(--ui-muted)); cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      border-radius: 3px; font-size: 11px; line-height: 1;
      transition: color 0.1s, background 0.1s;
    }
    .fm-cell-gear:hover { color: var(--e-accent-2, var(--ui-accent-soft)); background: color-mix(in srgb, var(--e-accent, var(--ui-accent)) 10%, transparent); }
    .fld-opt-danger { color: var(--e-ac-red, var(--ui-danger)); }
    .fld-opt-danger:hover { background: var(--e-ac-red-bg, var(--ui-danger-bg)); color: var(--e-ac-red, var(--ui-danger)); }
    .fld-menu-label {
      font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--e-dim, var(--ui-dim)); padding: 6px 8px 3px;
    }
    .fm-field-editor { flex: 1; min-width: 0; }
    .fm-add {
      align-self: flex-start;
      border: 1px dashed var(--e-muted, var(--ui-muted)); border-radius: 6px; background: transparent;
      color: var(--e-accent, var(--ui-accent)); font-family: inherit; font-size: 12px; font-weight: 600;
      padding: 7px 14px; cursor: pointer;
      transition: background 0.1s, border-color 0.1s, color 0.1s;
    }
    .fm-add:hover { background: var(--e-accent-solid, var(--ui-accent-solid)); border-color: var(--e-accent, var(--ui-accent)); border-style: solid; color: var(--e-accent-on, var(--e-accent-on, #fff)); }

    /* ── Theme Panel ── */
    #theme-panel {
      padding: 8px 0 40px;
    }
    .theme-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 14px;
      margin-bottom: 28px;
    }
    /* Scale control — zooms the whole document in View / Print */
    .theme-section {
      max-width: 520px;
      padding-top: 4px;
      border-top: 1px solid var(--ui-line);
    }
    .theme-section-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      margin: 18px 0 4px;
    }
    .theme-section-title {
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--ui-text);
    }
    .theme-scale-val {
      font-size: 13px;
      font-weight: 700;
      color: var(--ui-accent);
      font-variant-numeric: tabular-nums;
    }
    .theme-section-desc {
      font-size: 12px;
      color: var(--ui-dim-2);
      margin-bottom: 12px;
    }
    .theme-scale-range {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 4px;
      border-radius: 999px;
      background: var(--ui-line);
      outline: none;
      cursor: pointer;
    }
    .theme-scale-range::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--ui-accent);
      border: 2px solid var(--ui-surface);
      box-shadow: var(--ui-shadow-sm);
      cursor: pointer;
    }
    .theme-scale-range::-moz-range-thumb {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--ui-accent);
      border: 2px solid var(--ui-surface);
      cursor: pointer;
    }

    /* ── Logo upload (used by Title block letterhead) ── */
    .ti-block-edit {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
    }
    .ti-letterhead {
      margin-top: 6px;
    }
    .ti-title-row {
      display: flex;
      align-items: flex-start;
      gap: 12px;
    }
    .ti-title-row > textarea,
    .ti-title-row > .block-input { flex: 1; min-width: 0; }
    .ti-toggle-bar {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      flex: 0 0 auto;
      justify-content: flex-end;
      padding-top: 4px;
    }
    .ti-toggle {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 3px 9px;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 999px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-dim-2, var(--ui-dim-2));
      cursor: pointer;
      font-family: inherit;
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      transition: border-color 0.12s, color 0.12s;
    }
    .ti-toggle-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--e-muted, var(--ui-muted));
      transition: background 0.12s;
    }
    .ti-toggle.is-on { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .ti-toggle.is-on .ti-toggle-dot { background: var(--e-accent, var(--ui-accent)); }
    .ti-toggle:hover { color: var(--e-text, var(--ui-text)); }
    .ti-letterhead-body:not(:empty) {
      margin-top: 10px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .ti-sub-field {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .ti-sub-label {
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.07em;
      text-transform: uppercase;
      color: var(--e-muted, var(--ui-muted));
    }
    .ti-sub-input {
      border: none;
      outline: none;
      border-bottom: 1px solid var(--e-muted, var(--ui-muted));
      background: transparent;
      color: var(--e-text2, var(--ui-text-3));
      font-family: inherit;
      font-size: 13px;
      line-height: 1.55;
      resize: none;
      overflow: hidden;
      padding: 3px 0;
      width: 100%;
    }
    .ti-sub-input::placeholder { color: var(--e-muted, var(--ui-muted)); }
    .ti-cols {
      display: flex;
      gap: 14px;
    }
    .ti-cols .ti-sub-field { flex: 1; min-width: 0; }
    .ti-logo-row {
      display: flex;
      flex-direction: column;
      gap: 4px;
      align-self: flex-end;
      align-items: flex-end;
      max-width: 240px;
    }
    .ti-logo-row .ti-sub-label { text-align: right; }
    .ti-logo-inner {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }
    .ti-logo-inner .dh-logo-dropzone { max-width: 160px; }

    /* ── Logo upload shared bits ── */
    .dh-logo-dropzone {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      padding: 14px 8px;
      border: 1.5px dashed var(--e-muted, var(--ui-muted));
      border-radius: 5px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.4);
      color: var(--e-dim, var(--ui-dim));
      cursor: pointer;
      font-size: 10px;
      font-family: inherit;
      width: 100%;
      box-sizing: border-box;
      text-align: center;
      transition: border-color 0.15s, color 0.15s;
    }
    .dh-logo-dropzone:hover,
    .dh-logo-dropzone.is-drag { border-color: var(--e-accent, var(--ui-accent)); color: var(--e-accent, var(--ui-accent)); }
    .dh-logo-preview {
      max-width: 100%;
      max-height: 64px;
      object-fit: contain;
      border-radius: 3px;
    }
    .dh-logo-btn {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 4px;
      background: var(--e-sunken, var(--ui-bg));
      color: var(--e-accent, var(--ui-accent));
      cursor: pointer;
      font-family: inherit;
      padding: 3px 8px;
      transition: background 0.1s, color 0.1s;
    }
    .dh-logo-btn:hover { background: var(--e-accent-solid, var(--ui-accent-solid)); color: var(--e-accent-on, #fff); }
    .dh-logo-btn--remove { color: var(--e-ac-red, var(--ui-danger)); border-color: transparent; background: transparent; }
    .dh-logo-btn--remove:hover { background: var(--e-ac-red-bg, var(--ui-danger-bg)); color: var(--e-ac-red, var(--ui-danger)); }
    .theme-card {
      background: var(--ui-surface);
      border: 1px solid var(--ui-line);
      border-radius: 10px;
      padding: 18px 18px 16px;
      cursor: pointer;
      text-align: left;
      font-family: inherit;
      color: inherit;
      box-shadow: var(--ui-shadow-sm);
      transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.05s;
    }
    .theme-card:hover { border-color: var(--ui-line-strong); box-shadow: var(--ui-shadow-md); }
    .theme-card.selected {
      border-color: var(--ui-accent);
      box-shadow: 0 0 0 1px var(--ui-accent) inset, var(--ui-shadow-md);
    }
    .theme-card-name {
      font-size: 13px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--ui-accent);
      margin-bottom: 4px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .theme-card-name .selected-mark {
      display: inline-flex; align-items: center; gap: 4px;
      font-size: 11px;
      color: var(--ui-ok);
      opacity: 0;
    }
    .theme-card.selected .selected-mark { opacity: 1; }
    .pal {
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid var(--ui-line);
      display: flex;
      flex-direction: column;
      gap: 6px;
      text-align: left;
    }
    .pal-group-label {
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--ui-dim);
    }
    .pal-row {
      display: flex;
      flex-wrap: wrap;
      gap: 4px 6px;
      margin-bottom: 2px;
    }
    .pal-chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 2px 7px 2px 3px;
      border: 1px solid var(--ui-line);
      border-radius: 999px;
      background: var(--ui-sunken);
    }
    .pal-dot {
      width: 11px;
      height: 11px;
      border-radius: 50%;
      /* Outline keeps white and near-black chips visible on the card. */
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
      flex-shrink: 0;
    }
    .pal-name {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.02em;
      color: var(--ui-dim-3);
      white-space: nowrap;
    }
    /* Accent chip swatch: derived background + border, foreground bar inside. */
    .pal-tri {
      width: 15px;
      height: 11px;
      border-radius: 3px;
      border: 1px solid transparent;
      display: inline-flex;
      align-items: center;
      padding-left: 1px;
      flex-shrink: 0;
    }
    .pal-tri > span {
      width: 3px;
      height: 7px;
      border-radius: 1px;
      display: block;
    }
    .pal-fold { margin-top: 2px; }
    .pal-summary {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      list-style: none;
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--ui-dim);
      padding: 2px 0;
    }
    .pal-summary::-webkit-details-marker { display: none; }
    .pal-summary::before {
      content: '\25B8';
      font-size: 9px;
      transition: transform 0.12s;
    }
    .pal-fold[open] > .pal-summary::before { transform: rotate(90deg); }
    .pal-summary:hover { color: var(--ui-dim-2); }
    .pal-count {
      font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
      font-size: 9.5px;
      letter-spacing: 0;
      color: var(--ui-dim-3);
      background: var(--ui-hover);
      border-radius: 999px;
      padding: 1px 6px;
      margin-left: 2px;
    }
    .pal-row-fold { margin-top: 6px; }
    .pal-sub { margin-top: 8px; opacity: 0.75; }
    /* Derived chips read as computed, not authored. */
    .pal-sub + .pal-row .pal-chip { border-style: dashed; }
    .theme-card-desc {
      font-size: 11px;
      color: var(--ui-dim-2);
      margin-bottom: 12px;
      font-style: italic;
    }
    .theme-swatch {
      border-radius: 6px;
      padding: 12px 14px;
      border: 1px solid var(--ui-line);
    }
    .theme-swatch .sw-title    { font-size: 14px; font-weight: 700; text-align: center; margin-bottom: 6px; }
    .theme-swatch .sw-heading  { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
    .theme-swatch .sw-paragraph{ font-size: 11px; line-height: 1.5; }

    /* ── Separator block ── */
    #edit-panel .block-input.type-separator {
      border: none;
      border-top: 2px solid var(--e-line, var(--ui-line));
      height: 2px;
      min-height: 2px;
      padding: 0;
      margin: 10px 0;
      background: transparent;
      cursor: default;
      pointer-events: none;
      resize: none;
    }

    /* ── Page Break block ── */
    #edit-panel .block-input.type-pagebreak {
      border: none;
      border-top: 2px dashed var(--e-muted, var(--ui-muted));
      height: 2px;
      min-height: 2px;
      padding: 0;
      margin: 10px 0;
      background: transparent;
      cursor: default;
      pointer-events: none;
      resize: none;
    }

    /* ── Flow block (workflow editor, edit mode) ───────────────── */
    .fl-block-edit { flex: 1; min-width: 0; }
    /* Flow as a table: stages are rows, branch sub-rows sit under their stage. */
    .fb-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 6px; }
    .fb-th {
      text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
      font-weight: 600; color: var(--fb-text4); padding: 4px 8px 5px;
      border-bottom: 1px solid var(--fb-border); white-space: nowrap;
    }
    .fb-td { padding: 5px 8px; vertical-align: top; color: var(--fb-text); font-size: 12px; }
    .fb-tbody { border-bottom: 1px solid var(--fb-border); }
    .fb-trow:hover > .fb-td, .fb-brow:hover > .fb-td { background-color: rgba(var(--e-accent-rgb, 79,163,232), 0.07); }
    .fb-trow.fb-dragging > .fb-td { opacity: 0.4; }
    .fb-trow.fb-drop-above > .fb-td { box-shadow: inset 0 2px 0 -1px var(--fb-accent); }
    .fb-trow.fb-drop-below > .fb-td { box-shadow: inset 0 -2px 0 -1px var(--fb-accent); }
    .fb-td.fb-c-idx { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--fb-accent); padding-top: 8px; }
    .fb-c-idx { width: 38px; }
    .fb-c-name { width: 30%; }
    .fb-c-goesto { width: 20%; }
    .fb-c-comment { width: 50%; }
    .fb-trow.fb-t-start .fb-c-idx { color: var(--fb-green); }
    .fb-trow.fb-t-end .fb-c-idx { color: var(--fb-rose); }
    .fb-c-name { box-shadow: inset 2px 0 0 -1px transparent; }
    .fb-trow.fb-t-start .fb-c-name { box-shadow: inset 3px 0 0 -1px var(--fb-green); }
    .fb-trow.fb-t-end .fb-c-name { box-shadow: inset 3px 0 0 -1px var(--fb-rose); }
    .fb-trow.fb-t-decision .fb-c-name,
    .fb-trow.fb-t-step .fb-c-name { box-shadow: inset 3px 0 0 -1px var(--fb-border); }
    .fb-tname { font-size: 12px; font-weight: 550; color: var(--fb-text); overflow-wrap: break-word; }
    .fb-brow > .fb-td { padding-top: 2px; padding-bottom: 2px; }
    .fb-brow > .fb-c-name, .fb-brow > .fb-c-goesto, .fb-brow > .fb-c-comment {
      border-top: 1px dashed var(--fb-border);
    }
    .fb-brow > .fb-c-name { padding-left: 28px; }
    .fb-brow:last-child > .fb-td { padding-bottom: 6px; }
    .fb-sublabel {
      display: inline-block; padding-left: 20px; position: relative;
      font-size: 12px; color: var(--fb-text2); overflow-wrap: break-word;
    }
    .fb-sublabel::before {
      content: '\21B3'; position: absolute; left: 4px; top: 0; color: var(--fb-text4); font-size: 12px;
    }
    .fb-brow.is-auto .fb-sublabel { color: var(--fb-text4); font-style: italic; }
    .fb-dest { font-size: 12px; color: var(--fb-text2); overflow-wrap: break-word; white-space: nowrap; }
    .fb-dest.is-flow { color: var(--fb-accent); font-weight: 600; }
    .fb-dest.is-end { color: var(--fb-text4); font-style: italic; }
    .fb-addrow td { padding: 6px 8px 0; }
    .fb-addbtn {
      background: none; border: 1px dashed var(--fb-border); color: var(--fb-text4);
      font: inherit; font-size: 10px; padding: 3px 10px; border-radius: 6px; cursor: pointer;
    }
    .fb-addbtn:hover { border-color: var(--fb-accent); color: var(--fb-accent); }
    .flow-block {
      --fb-accent: var(--e-accent, var(--ui-accent));
      --fb-accent2: var(--e-accent-solid, var(--ui-accent-solid));
      --fb-text: var(--e-text, var(--ui-text));
      --fb-text2: var(--e-text2, var(--ui-text-3));
      --fb-text3: var(--e-dim-2, var(--ui-dim-3));
      --fb-text4: var(--e-dim, var(--ui-dim));
      --fb-border: var(--e-line, var(--ui-line));
      --fb-border2: var(--e-accent-line, var(--ui-line-strong));
      --fb-node: var(--e-sunken-2, var(--ui-sunken));
      --fb-node-hi: var(--e-hover, var(--ui-hover));
      --fb-green: var(--e-ac-green, var(--ui-ok));
      --fb-rose: var(--e-ac-red, #f0667d);
      --fb-amber: var(--e-ac-amber, var(--ui-warn));
      border: 1px solid var(--fb-border);
      border-radius: 8px;
      padding: 12px 14px 10px;
      background: rgba(var(--e-surface-rgb, 15,37,64), 0.5);
    }
    .fb-wf { margin-bottom: 18px; border-radius: 4px; }
    .fb-wf:last-of-type { margin-bottom: 4px; }
    .fb-wf.fb-dep { border-left: 2px solid var(--fb-border2); padding-left: 12px; margin-left: 1px; }
    .fb-wf-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
    .fb-drag { cursor: grab; color: var(--fb-text4); display: inline-flex; padding: 2px; flex-shrink: 0; }
    .fb-drag:hover { color: var(--fb-accent); }
    .fb-drag:active { cursor: grabbing; }
    .fb-bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--fb-accent); flex-shrink: 0; box-shadow: 0 0 0 4px rgba(var(--e-accent-rgb, 79,163,232), 0.12); }
    .fb-wf-name { flex: 1; min-width: 60px; background: none; border: none; border-bottom: 1px solid transparent; outline: none; color: var(--fb-text); font-family: inherit; font-size: 14px; font-weight: 600; padding: 2px 0; }
    .fb-wf-name:hover { border-bottom-color: var(--fb-border2); }
    .fb-wf-name:focus { border-bottom-color: var(--fb-accent); }
    .fb-wf-name::placeholder { color: var(--fb-text4); }
    .fb-wf-count { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fb-text4); white-space: nowrap; flex-shrink: 0; }
    .fb-wf-del { background: none; border: none; color: var(--fb-text4); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; flex-shrink: 0; border-radius: 4px; }
    .fb-wf-del:hover { color: var(--e-accent-on, #fff); background: rgba(200,64,64,0.28); }
    .fb-wf.fb-dragging { opacity: 0.4; }
    .fb-wf.fb-drop-before { box-shadow: 0 -3px 0 -1px var(--fb-accent); }
    .fb-wf.fb-drop-after { box-shadow: 0 3px 0 -1px var(--fb-accent); }
    .fb-ribbon { display: flex; flex-wrap: wrap; gap: 5px; margin: -2px 0 8px; }
    .fb-ribbon-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--fb-border2); color: var(--fb-text3); background: var(--fb-node); cursor: pointer; }
    .fb-ribbon-badge:hover { border-color: var(--fb-accent); color: var(--fb-accent); }
    .fb-ribbon-badge .fb-rb-branch { color: var(--fb-text2); font-weight: 600; }
    .fb-ribbon-badge .fb-rb-icon { color: var(--fb-accent); font-weight: 700; font-size: 12px; line-height: 1; }
    .fb-ribbon-badge .fb-rb-into { color: var(--fb-text4); }
    .fb-comment { box-sizing: border-box; display: block; font-size: 12px; line-height: 1.45; color: var(--fb-text2); background: transparent; border: none; padding: 3px 4px; width: 100%; min-width: 0; min-height: 22px; resize: none; outline: none; overflow: hidden; font-family: inherit; }
    .fb-comment::placeholder { color: var(--fb-text4); font-style: italic; }
    .fb-flash { animation: fbflash .7s ease 2; }
    @keyframes fbflash { 0%,100% { box-shadow: 0 0 0 2px rgba(var(--e-accent-rgb, 79,163,232), 0.25); } 40% { box-shadow: 0 0 0 5px rgba(var(--e-accent-rgb, 79,163,232), 0.4); } }

    /* ── Inline stage editing (name + meta) ── */
    .fb-name-row { display: flex; align-items: center; gap: 6px; }
    .fb-tname-input {
      width: 100%; box-sizing: border-box;
      font-family: inherit; font-size: 12px; font-weight: 550; line-height: 1.3;
      color: var(--fb-text);
      background: none; border: 1px solid transparent; border-radius: 3px;
      padding: 2px 6px; margin: -2px 0 0 -6px; outline: none;
    }
    .fb-tname-input:hover { border-color: var(--fb-border); }
    .fb-tname-input:focus { border-color: var(--fb-accent); background: var(--fb-node); }
    .fb-tname-input::placeholder { color: var(--fb-text4); font-style: italic; }
    .fb-del-stage {
      flex-shrink: 0; font: inherit; font-size: 15px; line-height: 1;
      background: none; border: none; color: var(--fb-text4);
      cursor: pointer; padding: 2px 6px; border-radius: 3px;
      opacity: 0; transition: opacity .12s, color .12s, background .12s;
    }
    .fb-trow:hover .fb-del-stage, .fb-del-stage:focus { opacity: 0.7; }
    .fb-del-stage:hover { color: var(--e-accent-on, #fff); background: rgba(200,64,64,0.28); opacity: 1; }
    /* Branch sub-row inline controls — themed pill wraps the arrow + label */
    .fb-blabel-wrap {
      display: flex; align-items: center; gap: 4px;
      padding: 1px 10px 1px 8px;
      border: 1px solid var(--fb-border);
      border-radius: 999px;
      background: transparent;
      color: var(--fb-text4);
      min-width: 0;
      transition: border-color .12s, background .12s, color .12s;
    }
    .fb-blabel-arrow {
      color: inherit; font-size: 12px; line-height: 1;
      flex-shrink: 0; padding: 0 2px;
      background: none; border: none; border-radius: 3px;
      cursor: pointer; font-family: inherit; font-weight: 700;
      transition: transform .1s;
    }
    .fb-blabel-arrow:hover { transform: scale(1.2); }
    .fb-blabel-arrow:focus { outline: none; }

    /* Floating accent picker (7 swatches: default + 6 named accents) */
    .fb-accent-picker {
      position: absolute; z-index: 1300;
      display: flex; align-items: center; gap: 6px;
      padding: 7px 9px;
      background: var(--e-surface, var(--ui-surface));
      border: 1px solid var(--e-line, var(--ui-line));
      border-radius: 8px;
      box-shadow: var(--ui-shadow-lg);
    }
    .fb-accent-swatch {
      width: 18px; height: 18px; border-radius: 50%;
      border: 2px solid transparent; padding: 0;
      cursor: pointer;
      transition: transform .1s, border-color .1s;
    }
    .fb-accent-swatch:hover { transform: scale(1.18); }
    .fb-accent-swatch.is-selected { border-color: var(--e-text, var(--ui-text)); }
    .fb-accent-none {
      background: transparent !important;
      border: 2px dashed var(--e-dim-2, var(--ui-dim-3));
    }
    .fb-accent-none.is-selected { border-color: var(--e-text, var(--ui-text)); border-style: dashed; }
    .fb-blabel-input {
      flex: 1 1 auto; min-width: 0; width: auto;
      font-family: inherit; font-size: 12px; font-weight: 500;
      color: inherit;
      background: transparent; border: none; border-radius: 3px;
      padding: 1px 2px; outline: none;
    }
    .fb-blabel-input::placeholder { color: currentColor; opacity: .55; font-style: italic; }
    .fb-dest-wrap { display: flex; align-items: center; gap: 4px; }
    .fb-dest-select {
      flex: 1 1 auto; min-width: 0; width: auto;
      font-family: inherit; font-size: 12px; color: var(--fb-text);
      background: var(--fb-node); border: 1px solid var(--fb-border);
      border-radius: 3px; padding: 1px 5px; outline: none; cursor: pointer;
    }
    .fb-dest-select:hover, .fb-dest-select:focus { border-color: var(--fb-accent); }
    .fb-rm-branch {
      flex-shrink: 0; font: inherit; font-size: 13px; line-height: 1;
      background: none; border: none; color: var(--fb-text4);
      cursor: pointer; padding: 1px 5px; border-radius: 3px;
      opacity: 0; transition: opacity .12s, color .12s, background .12s;
    }
    .fb-brow:hover .fb-rm-branch, .fb-rm-branch:focus { opacity: 0.7; }
    .fb-rm-branch:hover { color: var(--e-accent-on, #fff); background: rgba(200,64,64,0.28); opacity: 1; }
    /* + Add branch row (shown under every stage) */
    .fb-add-branch-row > .fb-td { padding-top: 2px; padding-bottom: 5px; }
    .fb-add-branch-btn {
      background: none; border: 1px dashed var(--fb-border); color: var(--fb-text4);
      font: inherit; font-size: 10px; padding: 2px 10px; border-radius: 4px;
      cursor: pointer; margin-left: 20px;
    }
    .fb-add-branch-btn:hover { border-color: var(--fb-accent); color: var(--fb-accent); }
    /* Stage row: only the index column is the drag handle. */
    .fb-trow > .fb-c-idx { cursor: grab; }
    .fb-trow.fb-dragging > .fb-c-idx { cursor: grabbing; }

