/* Loaded after Lexxy's own stylesheet so its UI follows the site's dark mode. */
:root {
  /* Same visual tokens as the Tailwind application theme. */
  --lexxy-color-ink: #0f172a;
  --lexxy-color-ink-medium: #475569;
  --lexxy-color-ink-light: #94a3b8;
  --lexxy-color-ink-lighter: rgb(226 232 240 / 0.8);
  --lexxy-color-ink-lightest: #f8fafc;
  --lexxy-color-ink-inverted: #ffffff;

  --lexxy-color-accent-dark: #0d2c99;
  --lexxy-color-accent-medium: #3c55ac;
  --lexxy-color-accent-light: rgb(13 44 153 / 0.12);
  --lexxy-color-accent-lightest: rgb(13 44 153 / 0.07);

  --lexxy-color-canvas: #ffffff;
  --lexxy-color-text: #1e293b;
  --lexxy-color-text-subtle: #64748b;
  --lexxy-color-link: #0d2c99;
  --lexxy-color-selected: rgb(13 44 153 / 0.1);
  --lexxy-color-selected-hover: rgb(13 44 153 / 0.15);
  --lexxy-color-selected-dark: #0d2c99;
  --lexxy-color-code-bg: #f8fafc;

  --lexxy-color-table-header-bg: #f1f5f9;
  --lexxy-color-table-cell-border: rgb(226 232 240 / 0.8);
  --lexxy-color-table-cell-selected: rgb(13 44 153 / 0.12);
  --lexxy-color-table-cell-selected-border: #0d2c99;
  --lexxy-color-table-cell-selected-bg: rgb(13 44 153 / 0.07);
  --lexxy-color-table-cell-add: rgb(13 44 153 / 0.45);
  --lexxy-color-table-cell-toggle: rgb(13 44 153 / 0.1);

  --lexxy-font-base: Poppins, sans-serif;
  --lexxy-radius: 0.5rem;
  --lexxy-shadow: 0 2px 16px rgb(13 44 153 / 0.08);

  /* Lexxy defaults to 2lh; this keeps the toolbar more compact. */
  --lexxy-toolbar-button-size: 1.75lh;
}

/* ==========================================================================
 * Sticky Toolbar (stays below the sticky #main-nav navbar)
 * ========================================================================== */

:where(lexxy-toolbar),
lexxy-editor lexxy-toolbar {
  position: sticky;
  top: 3.5rem;
  z-index: 10;
  background-color: var(--lexxy-color-canvas);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.05);
  flex-wrap: wrap;
  max-width: 100%;
}

/* Only the toolbar with an open dropdown rises above the next editor's toolbar and the site's selects. */
:where(lexxy-toolbar):has([aria-expanded="true"]) {
  z-index: 40;
}

lexxy-editor {
  max-width: 100%;
  min-width: 0;
}

body:not(:has(#main-nav)) :where(lexxy-toolbar),
body:not(:has(#main-nav)) lexxy-editor lexxy-toolbar {
  top: 0;
}

.lexxy-editor__html-source {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--lexxy-editor-rows);
  resize: vertical;
  border: 1px solid var(--lexxy-color-ink-lighter);
  border-radius: var(--lexxy-radius);
  background: var(--lexxy-color-code-bg);
  color: var(--lexxy-color-text);
  font-family: var(--lexxy-font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.875rem;
}

/* The application's generic table styles are intentionally very minimal.
 * Make Lexxy tables visible even before they contain text, both while editing
 * and once Action Text renders the saved content. */
:is(.lexxy-editor__content, .lexxy-content) .lexxy-content__table-wrapper {
  margin: 1rem 0;
  padding: 0.25rem;
  overflow-x: auto;
  border: 1px solid var(--lexxy-color-table-cell-border);
  border-radius: var(--lexxy-radius);
  background: var(--lexxy-color-canvas);
}

:is(.lexxy-editor__content, .lexxy-content) table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  table-layout: auto;
}

:is(.lexxy-editor__content, .lexxy-content) :is(th, td) {
  height: 2.75rem;
  padding: 0.625rem 0.75rem;
  vertical-align: top;
  border: 1px solid var(--lexxy-color-table-cell-border);
  background: var(--lexxy-color-canvas);
}

:is(.lexxy-editor__content, .lexxy-content) th,
:is(.lexxy-editor__content, .lexxy-content) .lexxy-content__table-cell--header {
  background: var(--lexxy-color-table-header-bg);
  font-weight: 700;
}

.lexxy-editor__content :is(th, td) {
  min-width: 8rem;
}

/* Legacy `align` attributes lose to the gem's `text-align: start` on cells. */
.lexxy-content :is(td, th)[align="center"] {
  text-align: center;
}

.lexxy-content :is(td, th)[align="right"] {
  text-align: right;
}

/* Lexical marks the cell currently under edit with this class. */
.lexxy-editor__content .lexxy-content__table-cell--focus {
  outline: 2px solid var(--lexxy-color-table-cell-selected-border);
  outline-offset: -2px;
}

/* `.grid-layout` removes list markers for the site's layout lists. Lexxy
 * editors are often rendered inside that layout, so restore their semantics
 * explicitly (and retain nested-list indentation). */
:is(.lexxy-editor__content, .lexxy-content) ul:not(.list-none) {
  margin: 0 0 1rem 1.5rem;
  padding-left: 1.25rem !important;
  list-style-type: disc !important;
}

:is(.lexxy-editor__content, .lexxy-content) ol:not(.list-none) {
  margin: 0 0 1rem 1.5rem;
  padding-left: 1.25rem !important;
  list-style-type: decimal !important;
}

:is(.lexxy-editor__content, .lexxy-content) :is(ul, ol) :is(ul, ol) {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

:is(.lexxy-editor__content, .lexxy-content) ul ul {
  list-style-type: circle !important;
}

:is(.lexxy-editor__content, .lexxy-content) ul ul ul {
  list-style-type: square !important;
}

/* Lexxy wraps box content in blocks; their outer margins unbalance the box padding. */
:is(boxinfo, boxsuccess, boxwarn, boxwarning, boxalert) > :first-child {
  margin-top: 0;
}

:is(boxinfo, boxsuccess, boxwarn, boxwarning, boxalert) > :last-child {
  margin-bottom: 0;
}

/* Keep quotations distinct from ordinary paragraphs in the editor as well as
 * in rendered Action Text content. */
:is(.lexxy-editor__content, .lexxy-content) blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--lexxy-color-accent-dark);
  border-radius: 0 var(--lexxy-radius) var(--lexxy-radius) 0;
  background: var(--lexxy-color-accent-lightest);
  color: var(--lexxy-color-text-subtle);
  font-style: italic;
}

:is(.lexxy-editor__content, .lexxy-content) blockquote > :last-child {
  margin-bottom: 0;
}

:is(.lexxy-editor__content, .lexxy-content) figure.attachment--preview {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}

/* Image controls are shown on click. Left/right images let following text
 * wrap naturally; centered images retain the regular document flow. */
:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview[data-lexxy-alignment="left"], action-text-attachment[data-lexxy-alignment="left"] figure) {
  float: left;
  z-index: 1;
  margin: 0.25rem 1.25rem 0.75rem 0;
}

:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview[data-lexxy-alignment="right"], action-text-attachment[data-lexxy-alignment="right"] figure) {
  float: right;
  z-index: 1;
  margin: 0.25rem 0 0.75rem 1.25rem;
}

:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview[data-lexxy-alignment="center"], action-text-attachment[data-lexxy-alignment="center"] figure) {
  clear: both;
  margin: 1rem auto;
}

:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview[data-lexxy-alignment="inline"], action-text-attachment[data-lexxy-alignment="inline"] figure) {
  display: inline-flex !important;
  vertical-align: middle;
  align-items: center;
  float: none !important;
  clear: none !important;
  margin: 0 0.5rem 0 0 !important;
  min-inline-size: 0 !important;
  min-width: 0 !important;
}

/* Inline image attachments inside headings (H1-H6) */
:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6):has(action-text-attachment, figure.attachment) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6):is([data-lexxy-text-align="center"], [style*="text-align: center"], [data-lexical-text-align="center"]):has(action-text-attachment, figure.attachment) {
  justify-content: center;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6):is([data-lexxy-text-align="right"], [style*="text-align: right"], [data-lexical-text-align="right"]):has(action-text-attachment, figure.attachment) {
  justify-content: flex-end;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) action-text-attachment {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0;
  padding: 0;
  line-height: 1;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) :is(figure.attachment, action-text-attachment figure) {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  float: none !important;
  clear: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-inline-size: 0 !important;
  min-width: 0 !important;
  line-height: 1;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) :is(figure.attachment, action-text-attachment figure) .attachment__container {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) :is(figure.attachment, action-text-attachment figure) img {
  display: inline-block !important;
  vertical-align: middle;
  margin: 0 !important;
  max-width: none;
  object-fit: contain;
}

:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) figcaption[data-placeholder],
:is(.lexxy-editor__content, .lexxy-content) :is(h1, h2, h3, h4, h5, h6) figcaption:empty {
  display: none !important;
}

/* Prevent default 10ch min-width and padding from enlarging small icons with authored dimensions */
:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment, action-text-attachment figure)[style*="width"],
:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment, action-text-attachment figure)[style*="max-width"] {
  min-inline-size: 0 !important;
  min-width: 0 !important;
}

:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview, action-text-attachment figure) img[style*="width"] {
  max-width: none;
}

:is(.lexxy-editor__content, .lexxy-content) figure.attachment--preview .attachment__caption {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-all;
  text-align: center;
}

:is(.lexxy-editor__content, .lexxy-content) :is(figure.attachment--preview[data-lexxy-alignment], action-text-attachment[data-lexxy-alignment] figure) img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--lexxy-radius);
}

/* Suppress redundant full-width Lexxy selection outline and default attachment toolbar */
.lexxy-editor__content figure.attachment--preview.node--selected,
.lexxy-editor__content figure.attachment--preview:focus {
  outline: none !important;
}

/* Hide Lexxy's built-in attachment toolbar (alt and delete buttons): our image tools provide their
   own controls. It is a direct child of lexxy-editor, not of the content. The caption editor stays. */
lexxy-editor lexxy-attachment-toolbar {
  display: none !important;
}

.ivao-image-tools {
  position: absolute;
  z-index: 5;
  top: 0.5rem;
  left: 50%;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.25rem;
  border: 1px solid var(--lexxy-color-ink-lighter);
  border-radius: var(--lexxy-radius);
  background: var(--lexxy-color-canvas);
  box-shadow: var(--lexxy-shadow);
  transform: translateX(-50%);
}

.ivao-image-tools button {
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.375rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--lexxy-color-text);
  font: 600 0.6875rem var(--lexxy-font-base);
  cursor: pointer;
}

.ivao-image-tools button:hover,
.ivao-image-tools button:focus-visible {
  background: var(--lexxy-color-accent-light);
  color: var(--lexxy-color-accent-dark);
  outline: none;
}

.ivao-image-tools__separator {
  width: 1px;
  height: 1.25rem;
  background: var(--lexxy-color-ink-lighter);
}

.ivao-image-tools .ivao-image-tools__delete:hover,
.ivao-image-tools .ivao-image-tools__delete:focus-visible {
  background: rgb(239 68 68 / 0.15);
  color: #dc2626;
}

.lexxy-editor__content figure.attachment--preview .attachment__container {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

.ivao-image-resizer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 2px solid var(--lexxy-color-accent-dark);
  border-radius: var(--lexxy-radius);
  box-sizing: border-box;
  z-index: 4;
}

.ivao-image-handle {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  background: var(--lexxy-color-canvas);
  border: 2px solid var(--lexxy-color-accent-dark);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  z-index: 6;
  touch-action: none;
  transition: transform 0.1s ease, background-color 0.1s ease;
}

.ivao-image-handle::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.ivao-image-handle:hover,
.ivao-image-handle.is-active {
  background: var(--lexxy-color-accent-dark);
  transform: scale(1.2);
}

.ivao-image-handle--nw { top: -5px; left: -5px; cursor: nwse-resize; }
.ivao-image-handle--ne { top: -5px; right: -5px; cursor: nesw-resize; }
.ivao-image-handle--se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.ivao-image-handle--sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.ivao-image-handle--n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.ivao-image-handle--s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.ivao-image-handle--w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }
.ivao-image-handle--e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }

.ivao-image-size-badge {
  display: none;
  position: absolute;
  bottom: -1.75rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  font-family: var(--lexxy-font-mono, monospace);
  color: #ffffff;
  background: rgb(15 23 42 / 0.85);
  backdrop-filter: blur(4px);
  border-radius: 0.25rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

.lexxy-editor__content figure.attachment--preview.is-resizing .ivao-image-tools {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}


/* ==========================================================================
 * Text Alignment Extension & Content Rendering
 * ========================================================================== */

/* Inline toolbar container so buttons remain aligned horizontally with standard controls */
.ivao-text-alignments {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}

.ivao-text-alignments .lexxy-editor__toolbar-separator {
  width: 1px;
  height: 1.25rem;
  background-color: var(--lexxy-color-ink-lighter);
  margin: 0 0.25rem;
}

.ivao-text-alignments .lexxy-editor__toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--lexxy-toolbar-button-size);
  height: var(--lexxy-toolbar-button-size);
  padding: 0;
  border: 0;
  border-radius: var(--lexxy-radius);
  background: transparent;
  color: var(--lexxy-color-ink-medium);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ivao-text-alignments .lexxy-editor__toolbar-button:hover,
.ivao-text-alignments .lexxy-editor__toolbar-button:focus-visible {
  background-color: var(--lexxy-color-selected-hover);
  color: var(--lexxy-color-accent-dark);
  outline: none;
}

.ivao-text-alignments .lexxy-editor__toolbar-button.lexxy-editor__toolbar-button--active {
  background-color: var(--lexxy-color-selected);
  color: var(--lexxy-color-accent-dark);
}

/* Text alignment in the editor and in the rendered Action Text view.
 * Based on the data attribute (survives sanitization), with the inline
 * style kept as a fallback for legacy content. */
:is(.lexxy-editor__content, .lexxy-content) [data-lexxy-text-align="left"],
:is(.lexxy-editor__content, .lexxy-content) [style*="text-align: left"],
:is(.lexxy-editor__content, .lexxy-content) [data-lexical-text-align="left"] {
  text-align: left;
}

:is(.lexxy-editor__content, .lexxy-content) [data-lexxy-text-align="center"],
:is(.lexxy-editor__content, .lexxy-content) [style*="text-align: center"],
:is(.lexxy-editor__content, .lexxy-content) [data-lexical-text-align="center"] {
  text-align: center;
}

:is(.lexxy-editor__content, .lexxy-content) [data-lexxy-text-align="right"],
:is(.lexxy-editor__content, .lexxy-content) [style*="text-align: right"],
:is(.lexxy-editor__content, .lexxy-content) [data-lexical-text-align="right"] {
  text-align: right;
}

:is(.lexxy-editor__content, .lexxy-content) [data-lexxy-text-align="justify"],
:is(.lexxy-editor__content, .lexxy-content) [style*="text-align: justify"],
:is(.lexxy-editor__content, .lexxy-content) [data-lexical-text-align="justify"] {
  text-align: justify;
}

/* ==========================================================================
 * Dark Theme Overrides
 * ========================================================================== */

.dark {
  --lexxy-color-ink: #f1f5f9;
  --lexxy-color-ink-medium: #cbd5e1;
  --lexxy-color-ink-light: #94a3b8;
  --lexxy-color-ink-lighter: rgba(255, 255, 255, 0.1);
  --lexxy-color-ink-lightest: #0f1320;
  --lexxy-color-ink-inverted: #161b2e;

  --lexxy-color-accent-dark: #7ea2d6;
  --lexxy-color-accent-medium: #9bb8e3;
  --lexxy-color-accent-light: rgba(126, 162, 214, 0.2);
  --lexxy-color-accent-lightest: rgba(126, 162, 214, 0.12);

  --lexxy-color-canvas: #161b2e;
  --lexxy-color-text: #e2e8f0;
  --lexxy-color-text-subtle: #94a3b8;
  --lexxy-color-link: #7ea2d6;
  --lexxy-color-selected: rgba(126, 162, 214, 0.2);
  --lexxy-color-selected-hover: rgba(126, 162, 214, 0.3);
  --lexxy-color-selected-dark: #7ea2d6;
  --lexxy-color-code-bg: #0f1320;

  --lexxy-color-table-header-bg: #121626;
  --lexxy-color-table-cell-border: rgba(255, 255, 255, 0.12);
  --lexxy-color-table-cell-selected: rgba(126, 162, 214, 0.25);
  --lexxy-color-table-cell-selected-border: #7ea2d6;
  --lexxy-color-table-cell-selected-bg: rgba(126, 162, 214, 0.15);
  --lexxy-color-table-cell-add: rgba(126, 162, 214, 0.45);
  --lexxy-color-table-cell-toggle: rgba(126, 162, 214, 0.15);

  --lexxy-color-code-token-att: #fda4af;
  --lexxy-color-code-token-comment: #94a3b8;
  --lexxy-color-code-token-function: #c4b5fd;
  --lexxy-color-code-token-operator: #fda4af;
  --lexxy-color-code-token-property: #93c5fd;
  --lexxy-color-code-token-punctuation: #cbd5e1;
  --lexxy-color-code-token-selector: #86efac;
  --lexxy-color-code-token-variable: #fdba74;

  --lexxy-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
 * Format & Styles Dropdown (Left of Toolbar)
 * ========================================================================== */

.lexxy-format-dropdown {
  display: inline-flex;
  align-items: center;
}

.lexxy-format-dropdown.lexxy-editor__toolbar-group-end {
  margin-inline-end: 0.5rem;
  padding-inline-end: 0.5rem;
  position: relative;
}

.lexxy-format-dropdown.lexxy-editor__toolbar-group-end:after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 1.25rem;
  background-color: var(--lexxy-color-ink-lighter);
}

/* Trigger button: modern select pill */
.lexxy-editor__toolbar-button.lexxy-format-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  width: auto;
  min-width: 6.25rem;
  height: var(--lexxy-toolbar-button-size);
  padding: 0 0.55rem;
  border-radius: var(--lexxy-radius);
  border: 1px solid var(--lexxy-color-ink-lighter);
  background-color: var(--lexxy-color-canvas);
  color: var(--lexxy-color-ink);
  font-family: var(--lexxy-font-base);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.lexxy-editor__toolbar-button.lexxy-format-trigger-btn:hover,
.lexxy-editor__toolbar-button.lexxy-format-trigger-btn:focus-visible {
  border-color: var(--lexxy-color-accent-medium);
  background-color: var(--lexxy-color-selected-hover);
  color: var(--lexxy-color-accent-dark);
  outline: none;
}

.lexxy-editor__toolbar-button.lexxy-format-trigger-btn[aria-expanded="true"] {
  border-color: var(--lexxy-color-accent-dark);
  background-color: var(--lexxy-color-selected);
  color: var(--lexxy-color-accent-dark);
  box-shadow: 0 0 0 2px var(--lexxy-color-accent-light);
}

.lexxy-editor__toolbar-button.lexxy-format-trigger-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  flex-shrink: 0;
}

.lexxy-toolbar-format-name {
  flex-grow: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.75rem;
  font-weight: 600;
  color: inherit;
}

@media (max-width: 640px) {
  .lexxy-editor__toolbar-button.lexxy-format-trigger-btn {
    min-width: var(--lexxy-toolbar-button-size);
    padding: 0;
    justify-content: center;
  }
  .lexxy-toolbar-format-name {
    display: none;
  }
}

/* ==========================================================================
 * Dropdown Menu Panel & Section Headers
 * ========================================================================== */

.lexxy-format-dropdown-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  box-sizing: border-box;
  min-width: 17.5rem;
  max-width: 22rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.35rem;
  border: 1px solid var(--lexxy-color-ink-lighter);
  border-radius: var(--lexxy-radius);
  background: var(--lexxy-color-canvas);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  z-index: 50;
}

.lexxy-format-dropdown-panel.is-above {
  top: auto;
  bottom: calc(100% + 0.35rem);
}

.lexxy-dropdown-header {
  padding: 0.4rem 0.5rem 0.2rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lexxy-color-text-subtle);
  user-select: none;
}

.lexxy-format-dropdown-panel .lexxy-editor__toolbar-separator {
  height: 1px;
  background-color: var(--lexxy-color-ink-lighter);
  margin: 0.3rem 0.25rem;
}

/* Base style for all items in the format panel */
.lexxy-format-dropdown-panel button.lexxy-dropdown-item,
.lexxy-format-dropdown-panel button[name="paragraph"],
.lexxy-format-dropdown-panel button.lexxy-heading-button,
.lexxy-format-dropdown-panel button[name="clear-formatting"] {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.45rem 0.625rem;
  margin: 0.05rem 0;
  border: 1px solid transparent;
  border-radius: calc(var(--lexxy-radius) - 2px);
  background: transparent;
  color: var(--lexxy-color-text);
  font-family: var(--lexxy-font-base);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lexxy-format-dropdown-panel button:hover,
.lexxy-format-dropdown-panel button:focus-visible {
  background-color: var(--lexxy-color-selected-hover);
  color: var(--lexxy-color-accent-dark);
  outline: none;
}

.lexxy-format-dropdown-panel button[aria-pressed="true"] {
  background-color: var(--lexxy-color-selected);
  color: var(--lexxy-color-accent-dark);
  border-color: var(--lexxy-color-accent-light);
  font-weight: 600;
}

/* Typography hierarchy inside the menu */
.lexxy-format-dropdown-panel button[name="paragraph"] span {
  font-size: 0.8125rem;
  font-weight: 500;
}

.lexxy-format-dropdown-panel button[data-heading="h1"] span {
  font-size: 0.9375rem;
  font-weight: 700;
}

.lexxy-format-dropdown-panel button[data-heading="h2"] span {
  font-size: 0.875rem;
  font-weight: 600;
}

.lexxy-format-dropdown-panel button[data-heading="h3"] span {
  font-size: 0.8125rem;
  font-weight: 600;
}

.lexxy-format-dropdown-panel button[name="clear-formatting"] {
  color: var(--lexxy-color-text-subtle);
  font-size: 0.75rem;
}

.lexxy-format-dropdown-panel button[name="clear-formatting"]:hover {
  color: #dc2626;
  background-color: rgb(239 68 68 / 0.1);
}

/* ==========================================================================
 * Box Callout Options in Dropdown (Enclosed alert box style)
 * ========================================================================== */

.ivao-boxes-toolbar-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.15rem 0;
}

.lexxy-format-dropdown-panel .ivao-box-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--lexxy-radius) - 1px);
  border: 1px solid transparent;
  font-family: var(--lexxy-font-base);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.lexxy-format-dropdown-panel .ivao-box-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
}

/* Info Variant (Information) */
.ivao-box-option.ivaobox-info {
  background-color: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}
.ivao-box-option.ivaobox-info:hover,
.ivao-box-option.ivaobox-info:focus-visible {
  background-color: #e0f2fe;
  border-color: #7dd3fc;
  outline: none;
}
.ivao-box-option.ivaobox-info.is-active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px #0284c7;
}

/* Success Variant (Succès) */
.ivao-box-option.ivaobox-success {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}
.ivao-box-option.ivaobox-success:hover,
.ivao-box-option.ivaobox-success:focus-visible {
  background-color: #dcfce7;
  border-color: #86efac;
  outline: none;
}
.ivao-box-option.ivaobox-success.is-active {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px #16a34a;
}

/* Warning Variant (Attention) */
.ivao-box-option.ivaobox-warning {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.ivao-box-option.ivaobox-warning:hover,
.ivao-box-option.ivaobox-warning:focus-visible {
  background-color: #fef3c7;
  border-color: #fcd34d;
  outline: none;
}
.ivao-box-option.ivaobox-warning.is-active {
  border-color: #d97706;
  box-shadow: 0 0 0 2px #d97706;
}

/* Alert Variant (Important) */
.ivao-box-option.ivaobox-alert {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.ivao-box-option.ivaobox-alert:hover,
.ivao-box-option.ivaobox-alert:focus-visible {
  background-color: #fee2e2;
  border-color: #fca5a5;
  outline: none;
}
.ivao-box-option.ivaobox-alert.is-active {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px #dc2626;
}

/* Dark Mode Overrides */
.dark .ivao-box-option.ivaobox-info {
  background-color: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}
.dark .ivao-box-option.ivaobox-info:hover {
  background-color: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
}

.dark .ivao-box-option.ivaobox-success {
  background-color: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.25);
  color: #4ade80;
}
.dark .ivao-box-option.ivaobox-success:hover {
  background-color: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.4);
}

.dark .ivao-box-option.ivaobox-warning {
  background-color: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
  color: #fbbf24;
}
.dark .ivao-box-option.ivaobox-warning:hover {
  background-color: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.4);
}

.dark .ivao-box-option.ivaobox-alert {
  background-color: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
  color: #f87171;
}
.dark .ivao-box-option.ivaobox-alert:hover {
  background-color: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.4);
}
