.cabinet .nb-editor { min-width: 0; width: 100%; }
.nb-editor *, .nb-editor *::before, .nb-editor *::after { box-sizing: border-box; }
.nb-editor svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nb-editor button { font: inherit; cursor: pointer; }
.nb-editor button:disabled { cursor: default; opacity: .4; }
.nb-editor :is(button,input,[contenteditable]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.nb-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 0 20px; border-bottom: 1px solid var(--line); }
.nb-toolbar-primary, .nb-toolbar-secondary { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nb-toolbar .btn { gap: 8px; }
.nb-count { color: var(--ink-muted); font-size: 12px; }
.nb-history { display: flex; gap: 4px; }
.nb-history button, .nb-card-actions button, .nb-step-head > button { display: grid; place-items: center; min-width: 40px; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface); color: var(--ink-muted); }
.nb-editor :is(.nb-history,.nb-card-actions,.nb-step-head) button:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); border-color: var(--line-strong); }
.nb-card-actions button[data-action="remove"]:hover, .nb-step-head button[data-action="remove-step"]:hover { color: #b4233b; }
.nb-format-bar { position: sticky; top: 8px; z-index: 8; background: var(--surface); border-radius: var(--radius-sm); }
.nb-format-bar:has(.tox:not([style*="display: none"])) { margin-top: 12px; }
.nb-formats .tox .tox-toolbar, .nb-formats .tox .tox-toolbar__primary { background: var(--surface-2) !important; border: 1px solid var(--line) !important; border-radius: var(--radius-sm); }
.nb-formats .tox .tox-editor-header { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 0 !important; }
.nb-formats .tox .tox-toolbar-overlord { background: transparent !important; }
.nb-formats .tox .tox-tbtn { color: var(--ink) !important; background: transparent !important; border-radius: var(--radius-xs); }
.nb-formats .tox .tox-tbtn svg { fill: var(--ink) !important; stroke: none; }
.nb-formats .tox .tox-tbtn:hover, .nb-formats .tox .tox-tbtn--enabled { background: var(--accent-soft) !important; color: var(--accent) !important; }
.nb-formats .tox .tox-tbtn__select-label { color: var(--ink) !important; font-family: var(--font); font-size: 13px; }
.nb-formats .tox .tox-toolbar__overflow { background: var(--surface) !important; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.nb-chip-colors, .nb-colors { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nb-chip-colors { padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; }
.nb-chip-colors > span { margin-right: 8px; color: var(--ink-muted); }
.nb-editor [hidden] { display: none !important; }
.nb-colors { margin-bottom: 12px; }
.nb-editor :is(.nb-colors,.nb-chip-colors) button { display: grid; place-items: center; width: 40px; height: 40px; padding: 4px; border: 1px solid transparent; border-radius: var(--radius-xs); background: transparent; }
.nb-editor :is(.nb-colors,.nb-chip-colors) button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.nb-color { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgb(0 0 0 / .12); display: block; }
.nb-color.is-accent { background: #3974e9; }.nb-color.is-success { background: #32a180; }.nb-color.is-warn { background: #e9b443; }.nb-color.is-danger { background: #d46579; }.nb-color.is-neutral { background: #8b97a9; }
.nb-upload-status { margin: 12px 0; padding: 12px 16px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-xs); font-size: 14px; }
.nb-blocks { max-width: 900px; margin: 24px auto 0; min-width: 0; }
.nb-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-nested); background: var(--surface); overflow: clip; }
.nb-card:focus-within { border-color: var(--line-strong); }
.nb-card.has-error { border-color: #c94b61; }
.nb-card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.nb-card-head > div { display: flex; align-items: center; gap: 10px; }
.nb-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.nb-card-index { color: var(--ink-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.nb-card-actions { gap: 4px !important; }
.nb-card-body { padding: 20px; }
.nb-rich { min-height: 100px; padding: 4px; border-radius: var(--radius-xs); outline: none; font: inherit; font-size: 16px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.nb-rich p { margin: 0 0 12px; }
.nb-rich > :last-child { margin-bottom: 0; }
.nb-rich:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.nb-rich.mce-edit-focus { outline: none !important; }
.nb-rich :is(ul,ol) { padding-left: 24px; }
.nb-between { display: flex; justify-content: center; position: relative; padding: 12px 0; }
.nb-between::before { content: ""; position: absolute; height: 1px; background: var(--line); left: 0; right: 0; top: 50%; }
.nb-between button { display: inline-flex; align-items: center; gap: 6px; position: relative; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-xs); color: var(--ink-muted); background: var(--surface); font-size: 12px; }
.nb-between button:hover { color: var(--accent); border-color: var(--accent); }
.nb-between svg { width: 16px; height: 16px; }
.nb-note { border-radius: var(--radius-sm); padding: 16px; border-left: 3px solid currentColor; }
.nb-note.instruction-note-accent { color: #2458df; background: #eaf1ff; }.nb-note.instruction-note-success { color: #16765b; background: #e9f6f1; }.nb-note.instruction-note-warn { color: #99640f; background: #fff5d9; }.nb-note.instruction-note-danger { color: #a52e49; background: #fcebf0; }.nb-note.instruction-note-neutral { color: #526176; background: #f0f3f7; }
.nb-note .nb-rich { color: inherit; }
html[data-theme="dark"] .nb-note.instruction-note-accent { color: #b5cdff; background: #203555; }html[data-theme="dark"] .nb-note.instruction-note-success { color: #9fdbbf; background: #1b3c34; }html[data-theme="dark"] .nb-note.instruction-note-warn { color: #f6d994; background: #3d3422; }html[data-theme="dark"] .nb-note.instruction-note-danger { color: #f5b4c6; background: #462b39; }html[data-theme="dark"] .nb-note.instruction-note-neutral { color: #c7d1e1; background: #26354a; }
.nb-step { --ink: var(--instruction-step-ink); --ink-muted: var(--instruction-step-muted); border: 1px solid var(--instruction-step-border); background: var(--instruction-step-bg); color: var(--ink); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.nb-step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.nb-step-number { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; background: var(--instruction-step-number); color: #fff; font-size: 14px; font-weight: 600; }
.nb-step-title { flex: 1; min-width: 0; }
.nb-step-title input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 8px 10px; background: var(--surface); font: inherit; font-size: 14px; font-weight: 600; }
.nb-next-step { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-xs); background: var(--surface); color: var(--accent); font-size: 13px !important; }
.nb-field { display: grid; gap: 8px; min-width: 0; margin-top: 16px; }
.nb-field:first-child { margin-top: 0; }
.nb-field > span { color: var(--ink); font-size: 13px; font-weight: 500; }
.nb-field input { padding: 10px 12px; border: 1px solid var(--line-strong); width: 100%; min-width: 0; }
.nb-help { font-size: 13px; color: var(--ink-muted); line-height: 1.5; margin: 10px 0 0; }
.nb-block-error { margin: 12px 0 0; color: #b4233b; font-size: 13px; line-height: 1.5; }
html[data-theme="dark"] .nb-block-error { color: #f7a9bc; }
.nb-image-drop { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.nb-image-drop img { max-width: 100%; max-height: 380px; object-fit: contain; border-radius: var(--radius-xs); }
.nb-image-drop p { margin: 0; font-size: 14px; font-weight: 500; }.nb-image-drop > span { color: var(--ink-muted); font-size: 12px; }
.nb-empty { text-align: center; padding: 40px 20px; }.nb-empty h3 { margin: 0 0 8px; font-size: 20px; }.nb-empty p { margin: 0 auto 24px; color: var(--ink-muted); max-width: 45ch; line-height: 1.6; }
.nb-editor dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); font-family: var(--font); }
.nb-editor dialog::backdrop { background: var(--scrim); }
.nb-add-dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.nb-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }.nb-dialog-head h3 { font-size: 20px; margin: 0; }.nb-dialog-lead { color: var(--ink-muted); font-size: 14px; line-height: 1.5; margin: 8px 0 20px; }
.nb-add-options { display: grid; gap: 8px; }
.nb-add-options button { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.nb-add-options button:hover { border-color: var(--accent); background: var(--accent-soft); }.nb-add-options svg { width: 24px; height: 24px; color: var(--accent); }.nb-add-options span { display: grid; gap: 4px; }.nb-add-options strong { font-size: 14px; font-weight: 600; }.nb-add-options small { font-size: 12px; color: var(--ink-muted); line-height: 1.4; }
.nb-editor .nb-preview-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
.nb-preview-dialog[open] { display: flex; flex-direction: column; }
.nb-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-shrink: 0; min-height: 80px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.nb-preview-head h3 { margin: 0; font-size: 20px; font-weight: 600; }.nb-preview-head p { color: var(--ink-muted); margin: 4px 0 0; font-size: 12px; }
.nb-devices { display: flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }.nb-devices button { min-height: 40px; padding: 8px 16px; border: 0; border-radius: var(--radius-xs); color: var(--ink-muted); background: transparent; font-size: 13px; }.nb-devices button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgb(0 0 0 / .06); }
.nb-preview-stage { flex: 1; min-height: 0; padding: 16px; overflow: hidden; display: flex; justify-content: center; align-items: flex-start; background: var(--surface-2); }
.nb-preview-holder { position: relative; flex-shrink: 0; box-shadow: 0 4px 24px rgb(0 0 0 / .08); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.nb-preview-frame { position: absolute; top: 0; left: 0; border: 0; transform-origin: top left; background: var(--surface); }
@media (max-width: 600px) {
    .nb-toolbar { flex-wrap: wrap; gap: 12px; padding-bottom: 16px; }.nb-toolbar-primary { flex: 1 1 100%; justify-content: space-between; }.nb-toolbar-secondary { flex: 1; justify-content: space-between; }
    .nb-toolbar .btn, .nb-history button, .nb-card-actions button, .nb-step-head > button { min-height: 44px; height: 44px; }.nb-history button, .nb-card-actions button, .nb-step-head > button { min-width: 44px; width: 44px; }
    .nb-blocks { margin-top: 16px; }.nb-card-head { padding: 10px 12px; gap: 8px; }.nb-card-head > div { gap: 6px; }.nb-card-head h3 { font-size: 13px; }.nb-card-body { padding: 12px; }.nb-rich { min-height: 100px; font-size: 16px; }
    .nb-between { padding: 10px 0; }.nb-between button { min-height: 44px; }.nb-step { padding: 10px; }.nb-step-head { gap: 8px; }.nb-step-number { width: 24px; height: 24px; }.nb-step-title input { font-size: 13px; padding: 8px; }
    .nb-image-drop { padding: 16px 10px; }.nb-next-step { min-height: 44px; }.nb-editor :is(.nb-colors,.nb-chip-colors) button { width: 44px; height: 44px; }
    .nb-formats .tox .tox-tbtn { min-width: 40px; height: 40px; }.nb-editor dialog { padding: 20px; }.nb-preview-head { padding: 12px; gap: 12px; flex-wrap: wrap; }.nb-preview-head > div:first-child { flex: 1; }.nb-preview-head .nb-devices { order: 3; flex: 1 1 100%; justify-content: center; }.nb-devices button { flex: 1; min-height: 44px; }.nb-preview-stage { padding: 12px; }.nb-editor .nb-preview-dialog { padding: 0; }
}

.nb-rich { position: relative; }
.nb-rich[data-empty="true"]::before { content: attr(data-placeholder); position: absolute; top: 4px; left: 4px; color: var(--ink-muted); font-size: 14px; pointer-events: none; font-weight: 400; }
@media (max-width: 600px) { .cabinet .nb-toolbar-secondary .btn { padding-inline: 10px; gap: 6px; font-size: 13px; } }
@media (max-width: 360px) { .nb-card-head { flex-wrap: wrap; }.nb-card-actions { margin-left: auto; } }

.nb-step .nb-rich { min-height: 72px; }
.cabinet .workspace-loading-tools { display: flex; justify-content: space-between; gap: 16px; }
.cabinet .workspace-loading-blocks { width: 100%; max-width: 900px; margin: 8px auto 0; display: grid; gap: 24px; }
.cabinet .workspace-loading-blocks .workspace-loading-paper { min-height: 180px; }

/* Document actions share one persistent footer with saving. */
.cabinet .nb-editor > .nb-count { margin: 0 0 16px; }
.cabinet .nb-bottom-bar { position: sticky; bottom: 0; z-index: 12; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin: 20px -24px -24px; padding: 12px 24px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .03); }
.cabinet .nb-bottom-bar .nb-toolbar { border: 0; padding: 0; flex-wrap: nowrap; gap: 12px; }
.cabinet .nb-bottom-bar .nb-toolbar-primary, .cabinet .nb-bottom-bar .nb-toolbar-secondary { flex: none; gap: 8px; }
.cabinet .nb-save-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.cabinet .nb-save-actions .editor-save-state { font-size: 12px; }
@media (max-width: 600px) {
  .cabinet .instructions-editor-panel .nb-bottom-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); margin: 16px -20px -20px; }
  .cabinet .nb-bottom-bar :is(.nb-toolbar,.nb-toolbar-primary,.nb-toolbar-secondary,.nb-save-actions) { display: contents; }
  .cabinet .nb-bottom-bar [data-action="add"] { order: 0; }
  .cabinet .nb-bottom-bar [data-action="preview"] { order: 1; }
  .cabinet .nb-bottom-bar .nb-history { order: 2; }
  .cabinet .nb-bottom-bar .nb-save-actions > .btn { order: 3; }
  .cabinet .nb-bottom-bar .editor-save-state { order: 4; grid-column: 1 / -1; text-align: center; min-height: 16px; }
  .cabinet .instructions-editor-panel .nb-bottom-bar .btn { width: 100%; min-width: 0; padding-inline: 8px; font-size: 13px; white-space: nowrap; }
  .cabinet .nb-bottom-bar .nb-history button { flex: 1; }
  .cabinet .nb-bottom-bar .nb-history { width: 100%; }
  .cabinet .nb-bottom-bar .btn svg { width: 18px; height: 18px; }
}

/* Symmetric preview controls; the mobile canvas has a fixed viewport. */
.nb-preview-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.nb-preview-head > .icon-btn { justify-self: end; }
.nb-preview-head .nb-devices { justify-self: center; }
.nb-devices button { display: grid; place-items: center; width: 44px; min-height: 44px; padding: 10px; cursor: pointer; }
.nb-devices svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nb-preview-stage { align-items: center; }
.nb-preview-holder[data-device="mobile"] { border-radius: 24px; outline: 1px solid var(--line-strong); }
@media (max-width: 600px) {
 .nb-preview-head { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
 .nb-preview-head > div:first-child { grid-column: 1; }
 .nb-preview-head > .icon-btn { grid-column: 2; grid-row: 1; }
 .nb-preview-head .nb-devices { grid-column: 1 / -1; grid-row: 2; order: initial; }
 .nb-devices button { flex: none; }
}
