/* ACIPE custom rich-text editor (no external editor libraries) */
.rte {
  --rte-line: #d7dee6;
  --rte-bg: #fff;
  --rte-navy: #2F4B69;
  --rte-teal: #2C726F;
  border: 1px solid var(--rte-line);
  border-radius: 8px;
  background: var(--rte-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Menu bar */
.rte-menubar { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--rte-line); background: #f4f7fa; border-radius: 8px 8px 0 0; position: relative; }
.rte-menu { position: relative; }
.rte-menu > button { background: none; border: 0; padding: 6px 12px; font-size: 14px; cursor: pointer; border-radius: 5px; color: var(--rte-navy); font-weight: 600; }
.rte-menu > button:hover, .rte-menu.open > button { background: #e3eaf1; }
.rte-dropdown { position: absolute; top: 100%; left: 0; min-width: 210px; background: #fff; border: 1px solid var(--rte-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 50; display: none; }
.rte-menu.open > .rte-dropdown { display: block; }
.rte-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; width: 100%; background: none; border: 0; text-align: left; padding: 7px 10px; font-size: 13px; cursor: pointer; border-radius: 5px; color: #1e2a38; }
.rte-item:hover { background: #eef3f8; }
.rte-item .sub { color: #9aa6b2; }
.rte-sep { height: 1px; background: var(--rte-line); margin: 5px 4px; }
.rte-sublabel { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: #9aa6b2; padding: 6px 10px 2px; }
/* fly-out submenu */
.rte-has-sub { position: relative; }
.rte-has-sub > .rte-dropdown { top: -6px; left: 100%; display: none; }
.rte-has-sub.open > .rte-dropdown { display: block; }

/* Toolbars (compact) */
.rte-toolbars { background: #fbfcfd; }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px 8px; }
.rte-toolbar + .rte-toolbar { border-top: 1px solid #eef2f6; }
.rte-tname { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: #aeb8c2; min-width: 46px; flex: none; }
.rte-toolbar button { display: inline-flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #e3e8ee; border-radius: 4px; min-width: 24px; height: 24px; padding: 0 6px; font-size: 12px; line-height: 1; cursor: pointer; color: #3a4654; }
.rte-toolbar button:hover { background: #eef3f8; border-color: #c4cfda; color: var(--rte-navy); }
.rte-toolbar select { height: 24px; border: 1px solid #e3e8ee; border-radius: 4px; font-size: 12px; background: #fff; padding: 0 3px; color: #3a4654; max-width: 116px; }
.rte-toolbar .ic-b { font-weight: 700; } .rte-toolbar .ic-i { font-style: italic; }
.rte-toolbar .ic-u { text-decoration: underline; } .rte-toolbar .ic-s { text-decoration: line-through; }
.rte-toolbar .ic-color { border-bottom: 3px solid #2C726F; height: 24px; }

/* Editable area */
.rte-content {
  min-height: 320px; padding: 22px 26px; outline: none; overflow-y: auto;
  font-size: 16px; line-height: 1.7; color: #1e2a38; background: #fff; border-radius: 0 0 8px 8px;
}
.rte-content:focus { outline: none; }
.rte-content p { margin: 0 0 1em; }
.rte-content h1,.rte-content h2,.rte-content h3,.rte-content h4,.rte-content h5,.rte-content h6 { color: var(--rte-navy); margin: 1.1em 0 .5em; line-height: 1.25; }
.rte-content a { color: var(--rte-teal); }
.rte-content img { max-width: 100%; height: auto; }
.rte-content blockquote { border-left: 4px solid var(--rte-teal); margin: 1em 0; padding: 6px 16px; color: #4b5563; background: #f5f8f9; }
.rte-content pre { background: #1c2e42; color: #e7eef6; padding: 14px 16px; border-radius: 8px; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.rte-content code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.rte-content pre code { background: none; padding: 0; }
.rte-content table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.rte-content table td, .rte-content table th { border: 1px solid #c9d3de; padding: 7px 10px; }
.rte-content hr { border: 0; border-top: 2px solid #d7dee6; margin: 1.4em 0; }
.rte-content .rte-pagebreak { border-top: 2px dashed #b9c4d0; margin: 1.4em 0; position: relative; }
.rte-content .rte-pagebreak::after { content: "Page break"; position: absolute; right: 0; top: -9px; font-size: 10px; color: #9aa6b2; background: #fff; padding: 0 6px; }
.rte-content .rte-media { position: relative; padding-bottom: 56.25%; height: 0; margin: 1em 0; }
.rte-content .rte-media iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.rte-content ul.rte-multilevel { list-style: none; counter-reset: l1; }
.rte-content ul.rte-multilevel li { counter-increment: l1; }
.rte-content ul.rte-multilevel li::before { content: counters(l1, ".") ". "; font-weight: 600; }

/* Dialogs & palettes */
.rte-pop { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--rte-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px; }
.rte-grid { display: grid; gap: 3px; }
.rte-grid .cell { width: 18px; height: 18px; border: 1px solid #d7dee6; cursor: pointer; background: #fff; }
.rte-grid .cell.on { background: #cfe6df; border-color: var(--rte-teal); }
.rte-grid-label { text-align: center; font-size: 12px; color: #6b7682; margin-top: 6px; }
.rte-swatches { display: grid; grid-template-columns: repeat(8, 18px); gap: 4px; }
.rte-swatches button { width: 18px; height: 18px; border: 1px solid rgba(0,0,0,.15); border-radius: 3px; padding: 0; cursor: pointer; }
.rte-dialog-backdrop { position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 70; display: flex; align-items: center; justify-content: center; }
.rte-dialog { background: #fff; border-radius: 10px; padding: 20px; width: 420px; max-width: 92vw; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.rte-dialog h4 { margin: 0 0 12px; color: var(--rte-navy); }
.rte-dialog label { display: block; font-size: 12px; font-weight: 600; color: #4b5563; margin: 10px 0 4px; }
.rte-dialog input[type=text], .rte-dialog input[type=url] { width: 100%; padding: 8px 10px; border: 1px solid var(--rte-line); border-radius: 6px; font: inherit; }
.rte-dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.rte-dialog button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--rte-line); background: #fff; cursor: pointer; font-weight: 600; }
.rte-dialog button.primary { background: var(--rte-teal); color: #fff; border-color: var(--rte-teal); }

/* Fullscreen */
.rte.rte-fullscreen { position: fixed; inset: 0; z-index: 9999; border-radius: 0; }
.rte.rte-fullscreen .rte-content { flex: 1; border-radius: 0; }

@media print {
  .rte-pagebreak { page-break-before: always; border: 0; }
  .rte-pagebreak::after { display: none; }
}