/* ==========================================================================
   Shared Broto Rich Text Editor Styles (Editor.js)
   Reused across Task Description (ItemDrawer) and modular rich surfaces.
   Zero hex colors · Zero !important · Light + Dark unified via variables.css
   ========================================================================== */

.broto-rich-editor {
  width: 100%;
  font-family: var(--font-family);
  color: var(--foreground);
  position: relative;
}

.broto-rich-editor--task {
  padding: 12px 20px 14px 54px;
  min-height: 148px;
}

.broto-rich-editor .codex-editor {
  font-family: var(--font-family);
}

.broto-rich-editor .codex-editor__redactor {
  margin-right: 0;
}

.broto-rich-editor .ce-block__content,
.broto-rich-editor .ce-toolbar__content {
  max-width: 100%;
  margin: 0;
}

.broto-rich-editor .ce-toolbar__content {
  left: 0;
}

.broto-rich-editor .ce-toolbar__actions {
  left: -44px;
  right: auto;
  padding-right: 4px;
}

.broto-rich-editor .ce-block--selected .ce-block__content {
  background: var(--muted);
  border-radius: var(--radius-sm);
}

/* Editorial Typography */
.broto-rich-editor .ce-header {
  padding: 2px 0;
  margin: 0;
  line-height: 1.3;
  font-weight: 600;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.broto-rich-editor h1.ce-header {
  font-size: 1.375rem;
  margin-top: 16px;
  margin-bottom: 6px;
  letter-spacing: -0.025em;
}

.broto-rich-editor h2.ce-header {
  font-size: 1.125rem;
  margin-top: 14px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--soft-border);
}

.broto-rich-editor h3.ce-header {
  font-size: 0.96875rem;
  margin-top: 12px;
  margin-bottom: 3px;
  letter-spacing: -0.015em;
}

.broto-rich-editor h4.ce-header {
  font-size: 0.875rem;
  margin-top: 10px;
  margin-bottom: 2px;
}

.broto-rich-editor .ce-paragraph {
  line-height: 1.65;
  font-size: var(--font-size-base);
  color: var(--foreground);
  padding: 3px 0;
}

.broto-rich-editor .ce-paragraph a,
.broto-rich-editor .cdx-nested-list__item-content a,
.broto-rich-editor .cdx-checklist__item-text a {
  color: var(--foreground);
  text-decoration: underline;
  text-decoration-color: var(--muted-foreground);
  text-underline-offset: 3px;
}

.broto-rich-editor .ce-paragraph a:hover {
  text-decoration-color: var(--foreground);
}

/* Placeholder */
.broto-rich-editor .ce-paragraph[data-placeholder]::before,
.broto-rich-editor .ce-header[data-placeholder]::before {
  color: var(--muted-foreground);
  opacity: 0.5;
}

/* Inline Tools: Inline Code & Marker */
.broto-rich-editor .inline-code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  margin: 0 1px;
}

.broto-rich-editor .cdx-marker {
  background: var(--editor-marker-bg);
  color: inherit;
  padding: 1px 3px;
  border-radius: 3px;
}

/* Nested Lists */
.broto-rich-editor .cdx-nested-list,
.broto-rich-editor .cdx-list {
  margin: 4px 0 8px 0;
  padding-left: 20px;
  font-size: var(--font-size-base);
  color: var(--foreground);
}

.broto-rich-editor .cdx-nested-list__item,
.broto-rich-editor .cdx-list__item {
  line-height: 1.6;
  padding: 2px 0;
}

.broto-rich-editor .cdx-nested-list__item-content {
  padding: 1px 0;
}

/* Quote Block */
.broto-rich-editor .cdx-quote {
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--soft-bg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-top: 1px solid var(--soft-border);
  border-right: 1px solid var(--soft-border);
  border-bottom: 1px solid var(--soft-border);
}

.broto-rich-editor .cdx-quote__text {
  font-style: italic;
  font-size: var(--font-size-base);
  line-height: 1.55;
  color: var(--foreground);
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
  margin: 0;
  min-height: 22px;
}

.broto-rich-editor .cdx-quote__caption {
  font-size: var(--font-size-xs);
  color: var(--muted-foreground);
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 4px 0 0 0;
  margin: 0;
}

/* Block Action Buttons (+ and Drag/Tune) */
.broto-rich-editor .ce-toolbar__plus,
.broto-rich-editor .ce-toolbar__settings-btn {
  width: 24px;
  height: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--muted-foreground);
  border-radius: var(--radius-sm);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.broto-rich-editor .ce-toolbar__plus:hover,
.broto-rich-editor .ce-toolbar__settings-btn:hover {
  background: var(--muted);
  border-color: var(--input);
  color: var(--foreground);
}

.broto-rich-editor .ce-toolbar__plus svg,
.broto-rich-editor .ce-toolbar__settings-btn svg {
  color: currentColor;
  stroke: currentColor;
}

/* Popovers, Slash Menu & Block Tunes (elevated above fullscreen drawers) */
.broto-rich-editor .ce-popover,
.broto-rich-editor .ce-popover__container {
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--foreground);
  box-shadow: var(--popover-shadow);
  font-family: var(--font-family);
  z-index: 15060;
}

.broto-rich-editor .ce-popover__container {
  padding: 4px;
}

.broto-rich-editor .ce-popover__search,
.broto-rich-editor .cdx-search-field {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 2px 2px 6px 2px;
  padding: 4px 8px;
}

.broto-rich-editor .ce-popover__search-input,
.broto-rich-editor .cdx-search-field__input {
  color: var(--foreground);
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  height: 24px;
  padding: 0;
  width: 100%;
}

.broto-rich-editor .ce-popover__search-icon svg,
.broto-rich-editor .cdx-search-field__icon svg {
  color: var(--muted-foreground);
  stroke: var(--muted-foreground);
}

.broto-rich-editor .ce-popover__items {
  gap: 2px;
}

.broto-rich-editor .ce-popover-item,
.broto-rich-editor .ce-popover__item {
  color: var(--foreground);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  min-height: 30px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.broto-rich-editor .ce-popover-item:hover,
.broto-rich-editor .ce-popover__item:hover,
.broto-rich-editor .ce-popover-item--focused,
.broto-rich-editor .ce-popover__item--focused {
  background: var(--muted);
  color: var(--foreground);
}

.broto-rich-editor .ce-popover-item--active,
.broto-rich-editor .ce-popover__item--active {
  background: var(--secondary);
  color: var(--foreground);
  font-weight: 600;
}

.broto-rich-editor .ce-popover-item--confirmation,
.broto-rich-editor .ce-popover-item--confirmation:hover {
  background: var(--semantic-danger-bg);
  color: var(--semantic-danger-fg);
}

.broto-rich-editor .ce-popover-item__icon,
.broto-rich-editor .ce-popover__item-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--soft-bg);
  border: 1px solid var(--border);
  color: var(--foreground);
  box-shadow: none;
}

.broto-rich-editor .ce-popover-item__icon svg,
.broto-rich-editor .ce-popover__item-icon svg {
  color: currentColor;
  stroke: currentColor;
  fill: none;
}

.broto-rich-editor .ce-popover-item__secondary-title {
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--font-size-tiny);
}

.broto-rich-editor .ce-popover-item-separator__line {
  background: var(--border);
}

.broto-rich-editor .ce-popover__nothing-found-message {
  color: var(--muted-foreground);
  font-size: var(--font-size-xs);
  padding: 10px 8px;
}

/* Inline Formatting Toolbar & Conversion Menu */
.broto-rich-editor .ce-inline-toolbar,
.broto-rich-editor .ce-conversion-toolbar {
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--popover-shadow);
  color: var(--foreground);
  z-index: 15070;
}

.broto-rich-editor .ce-inline-toolbar__dropdown,
.broto-rich-editor .ce-inline-tool,
.broto-rich-editor .ce-conversion-tool {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.broto-rich-editor .ce-inline-toolbar__dropdown:hover,
.broto-rich-editor .ce-inline-tool:hover,
.broto-rich-editor .ce-conversion-tool:hover,
.broto-rich-editor .ce-conversion-tool--focused {
  background: var(--muted);
  color: var(--foreground);
}

.broto-rich-editor .ce-inline-tool--active {
  background: var(--secondary);
  color: var(--foreground);
}

.broto-rich-editor .ce-inline-tool svg,
.broto-rich-editor .ce-inline-toolbar__dropdown svg,
.broto-rich-editor .ce-conversion-tool__icon svg {
  color: currentColor;
  stroke: currentColor;
}

.broto-rich-editor .ce-conversion-tool__icon {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  box-shadow: none;
  border-radius: var(--radius-sm);
}

.broto-rich-editor .ce-inline-tool-input {
  background: var(--background);
  color: var(--foreground);
  border-top: 1px solid var(--border);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  padding: 8px 10px;
}

.broto-rich-editor .ce-inline-tool-input::placeholder {
  color: var(--muted-foreground);
}

/* Global Editor.js Tooltip layering above ItemDrawer (15000) */
.ct {
  z-index: 16000;
  font-family: var(--font-family);
  font-size: var(--font-size-label);
}

.ct__content {
  border-radius: var(--radius-sm);
}

/* Code Highlight Block */
.broto-rich-editor .editorjs-code-block {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin: 12px 0;
  overflow: visible;
  background: var(--card);
  background-clip: padding-box;
}

.broto-rich-editor .editorjs-code-block .control-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  min-height: 36px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select {
  position: relative;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-selected {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 22px 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: var(--font-size-label);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-selected:hover,
.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-selected.select-arrow-active {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-selected .arrow-icon {
  width: 9px;
  height: 9px;
  right: 7px;
  top: 50%;
  margin-top: -4.5px;
  fill: currentColor;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 210px;
  padding: 4px;
  margin-top: 0;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--popover-shadow);
  z-index: 15065;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items .search-input {
  width: 100%;
  height: var(--control-height-sm);
  margin: 0 0 4px 0;
  padding: 0 8px;
  background: var(--card);
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items .items-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items .items-list div {
  background: transparent;
  color: var(--foreground);
  padding: 5px 8px;
  margin: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  cursor: pointer;
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items .items-list div:hover {
  background: var(--muted);
}

.broto-rich-editor .editorjs-code-block .control-container .editorjs-code-language-select .select-items .items-list .same-as-selected {
  background: var(--secondary);
  font-weight: 600;
}

.broto-rich-editor .editorjs-code-block .control-container .btn-div {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.broto-rich-editor .editorjs-code-block .control-container .btn-div .control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-label);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.broto-rich-editor .editorjs-code-block .control-container .btn-div .control-btn:hover {
  background: var(--muted);
  border-color: var(--input);
  color: var(--foreground);
}

.broto-rich-editor .editorjs-code-block .control-container .btn-div .copy-btn .copy-icon {
  width: 11px;
  height: 11px;
  fill: currentColor;
  pointer-events: none;
  flex-shrink: 0;
}

.broto-rich-editor .editorjs-code-block .content-container {
  position: relative;
  background: var(--editor-code-bg-dark);
  min-height: 49px;
  padding: 0;
  border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
  overflow: hidden;
}

.broto-rich-editor[data-code-theme-mode="light"] .editorjs-code-block .content-container {
  background: var(--editor-code-bg-light);
}

.broto-rich-editor .editorjs-code-block:has(.caption-input) .content-container {
  border-radius: 0;
}

.broto-rich-editor .editorjs-code-block .input-layer,
.broto-rich-editor .editorjs-code-block .rendered-layer,
.broto-rich-editor .editorjs-code-block .rendered-layer pre,
.broto-rich-editor .editorjs-code-block .rendered-layer code,
.broto-rich-editor .editorjs-code-block .rendered-layer span {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 21px;
  tab-size: 2;
  padding: 0;
  margin: 0;
  border: none;
  box-sizing: border-box;
  letter-spacing: normal;
}

.broto-rich-editor .editorjs-code-block .input-layer {
  display: block;
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 49px;
  color: transparent;
  caret-color: var(--editor-code-caret-dark);
  background: transparent;
  resize: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 14px 16px;
  overflow: hidden;
  outline: none;
  box-shadow: none;
}

.broto-rich-editor[data-code-theme-mode="light"] .editorjs-code-block .input-layer {
  caret-color: var(--editor-code-caret-light);
}

.broto-rich-editor .editorjs-code-block .input-layer::selection {
  background-color: color-mix(in srgb, var(--muted-foreground) 32%, transparent);
}

.broto-rich-editor .editorjs-code-block .rendered-layer {
  position: absolute;
  inset: 0;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: transparent;
}

.broto-rich-editor .editorjs-code-block .rendered-layer pre,
.broto-rich-editor .editorjs-code-block .rendered-layer code {
  display: block;
  height: 100%;
  min-height: 100%;
  background: transparent;
}

.broto-rich-editor .editorjs-code-block .rendered-layer code {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 14px 16px;
  border-radius: 0;
}

.broto-rich-editor .editorjs-code-block .caption-input {
  width: 100%;
  min-height: 32px;
  height: auto;
  margin: 0;
  padding: 7px 14px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--soft-bg);
  color: var(--muted-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  resize: none;
  outline: none;
  box-shadow: none;
}

/* Table Block */
.broto-rich-editor .tc-wrap {
  --color-border: var(--border);
  --color-background: var(--soft-bg);
  margin: 10px 0;
}

.broto-rich-editor .tc-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.broto-rich-editor .tc-row {
  border-bottom-color: var(--border);
}

.broto-rich-editor .tc-row::after {
  border-bottom: 1px solid var(--border);
}

.broto-rich-editor .tc-table--heading .tc-row:first-child {
  background: var(--soft-bg);
  font-weight: 600;
}

.broto-rich-editor .tc-cell {
  border-right: 1px solid var(--border);
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  color: var(--foreground);
  line-height: 1.45;
}

.broto-rich-editor .tc-cell--selected,
.broto-rich-editor .tc-row--selected {
  background: var(--muted);
}

.broto-rich-editor .tc-add-row,
.broto-rich-editor .tc-add-column {
  color: var(--muted-foreground);
  background: transparent;
}

.broto-rich-editor .tc-add-row:hover,
.broto-rich-editor .tc-add-column:hover,
.broto-rich-editor .tc-add-row:hover::before {
  background: var(--soft-bg);
  color: var(--foreground);
}

.broto-rich-editor .tc-toolbox__toggler {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  border-radius: var(--radius-sm);
}

.broto-rich-editor .tc-popover {
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--popover-shadow);
  padding: 4px;
  z-index: 15065;
}

.broto-rich-editor .tc-popover__item {
  color: var(--foreground);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  padding: 5px 8px;
}

.broto-rich-editor .tc-popover__item:hover {
  background: var(--muted);
}

.broto-rich-editor .tc-popover__item--confirm {
  background: var(--semantic-danger-bg);
  color: var(--semantic-danger-fg);
}

.broto-rich-editor .tc-popover__item-icon {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  color: var(--foreground);
}

/* Flow Embed Block inside shared Rich Text Editor */
.broto-rich-editor .memo-flow-embed {
  margin: 12px 0;
  font-family: var(--font-family);
}

.broto-rich-editor .memo-flow-card,
.broto-rich-editor .memo-flow-picker {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.broto-rich-editor .memo-flow-header,
.broto-rich-editor .memo-flow-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  min-height: 36px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--border);
}

.broto-rich-editor .memo-flow-header-left,
.broto-rich-editor .memo-flow-picker-title-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.broto-rich-editor .memo-flow-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.broto-rich-editor .memo-flow-icon svg {
  width: 14px;
  height: 14px;
}

.broto-rich-editor .memo-flow-title,
.broto-rich-editor .memo-flow-picker-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.broto-rich-editor .memo-flow-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--semantic-success-bg);
  border: 1px solid var(--semantic-success-border);
  color: var(--semantic-success-fg);
  font-size: var(--font-size-tiny);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.broto-rich-editor .memo-flow-live-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--semantic-success-fg);
}

.broto-rich-editor .memo-flow-stats {
  font-size: var(--font-size-tiny);
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.broto-rich-editor .memo-flow-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.broto-rich-editor .memo-flow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 24px;
  min-width: 24px;
  padding: 0 7px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-label);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.broto-rich-editor .memo-flow-btn:hover {
  background: var(--muted);
  border-color: var(--input);
  color: var(--foreground);
}

.broto-rich-editor .memo-flow-picker-search {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid var(--soft-border);
  background: var(--card);
}

.broto-rich-editor .memo-flow-picker-search-icon {
  position: absolute;
  left: 19px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  display: inline-flex;
  pointer-events: none;
}

.broto-rich-editor .memo-flow-picker-input {
  width: 100%;
  height: var(--control-height-sm);
  padding: 0 10px 0 30px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  box-sizing: border-box;
}

.broto-rich-editor .memo-flow-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  max-height: 220px;
  overflow-y: auto;
  contain: content;
}

.broto-rich-editor .memo-flow-picker-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.broto-rich-editor .memo-flow-picker-item:hover {
  background: var(--muted);
}

.broto-rich-editor .memo-flow-picker-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.broto-rich-editor .memo-flow-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 14px;
  background-color: var(--card);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 16px 16px;
  overflow: hidden;
}

.broto-rich-editor .broto-flow-embed-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  font-family: var(--font-family);
}

.broto-rich-editor .memo-flow-caption {
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 12px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--soft-bg);
  color: var(--muted-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  box-sizing: border-box;
  outline: none;
}

.broto-rich-editor .memo-flow-skeleton-row {
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--muted);
  opacity: 0.65;
}

.broto-rich-editor .memo-flow-stage-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: var(--font-size-xs);
  text-align: center;
}

/* Flow Lightbox above ItemDrawer (works even when memo.css is not loaded) */
.memo-flow-lightbox {
  position: fixed;
  inset: 0;
  z-index: 16100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.memo-flow-lightbox-panel {
  width: min(1160px, 94vw);
  height: min(820px, 88vh);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--popover-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memo-flow-lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--border);
}

.memo-flow-lightbox-header .memo-flow-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.memo-flow-lightbox-header .memo-flow-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.memo-flow-lightbox-header .memo-flow-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memo-flow-lightbox-header .memo-flow-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.memo-flow-lightbox .memo-flow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-label);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.memo-flow-lightbox .memo-flow-btn:hover {
  background: var(--muted);
  border-color: var(--input);
  color: var(--foreground);
}

.memo-flow-lightbox-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  background-color: var(--card);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 20px 20px;
}

.memo-flow-lightbox .broto-flow-embed-svg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  font-family: var(--font-family);
}

@media (max-width: 960px) {
  .broto-rich-editor--task {
    padding: 10px 14px 14px 14px;
  }

  .broto-rich-editor .ce-toolbar__actions {
    left: auto;
    right: 0;
  }
}
