/* Standalone Evo visual BBCode editor. Theme colours are inherited. */
.evo-editor {
  --editor-border: rgba(127, 127, 127, 0.35);
  --editor-surface: rgba(127, 127, 127, 0.06);
  margin: 12px 0;
  color: inherit;
}
.evo-editor [hidden] {
  display: none !important;
}
.evo-editor-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}
.evo-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--editor-border);
  border-radius: 6px 6px 0 0;
  background: var(--editor-surface);
}
.evo-editor-button {
  padding: 6px 10px;
  border: 1px solid var(--editor-border);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.evo-editor-button:hover,
.evo-editor-button[aria-pressed="true"] {
  background: rgba(127, 127, 127, 0.18);
}
.evo-editor-button:disabled {
  opacity: 0.45;
  cursor: default;
}
.evo-editor-button:focus-visible,
.evo-editor-visual:focus-visible,
.evo-editor-source:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.evo-editor-visual,
.evo-editor-source {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--evo-editor-height, 260px);
  padding: 14px;
  border: 1px solid var(--editor-border);
  border-radius: 0 0 6px 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.evo-editor-source {
  resize: vertical;
  font-family: monospace;
}
.evo-editor-visual blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid currentColor;
  background: var(--editor-surface);
}
.evo-editor-visual pre {
  padding: 12px;
  background: var(--editor-surface);
  white-space: pre-wrap;
}
.evo-editor-visual img {
  max-width: 100%;
  height: auto;
}

/* Labels are generated by CSS, so they never become part of submitted BBCode. */
.evo-editor-visual [data-caption]::before {
  content: attr(data-caption);
  display: block;
  margin-bottom: 6px;
  font-size: 0.8em;
  font-weight: 600;
  opacity: 0.75;
}
.evo-editor-visual :is([data-bb-tag="hide"], [data-bb-tag="spoil"]) {
  display: block;
  padding: 10px 14px;
  margin: 10px 0;
  border: 1px dashed var(--editor-border);
  background: var(--editor-surface);
}
.evo-editor-visual pre[data-bb-tag="php"]::before {
  content: "PHP";
  display: block;
  margin-bottom: 6px;
  font: 600 0.8em sans-serif;
  opacity: 0.75;
}
.evo-editor-visual .evo-editor-video {
  display: inline-block;
  box-sizing: border-box;
  max-width: 100%;
  padding: 14px 18px;
  margin: 6px 0;
  border: 1px solid var(--editor-border);
  border-radius: 6px;
  background: var(--editor-surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  vertical-align: middle;
}
.evo-editor-visual hr {
  border: 0;
  border-top: 1px solid currentColor;
  margin: 14px 0;
  opacity: 0.5;
}
.evo-editor-visual :is(ul, ol) {
  margin: 12px 0;
  padding-left: 28px;
  white-space: normal;
}
.evo-editor-visual li {
  white-space: pre-wrap;
}

/* Compact icon toolbar with one expandable category row at a time. */
.evo-editor-toolbar {
  display: block;
  padding: 0;
  overflow: visible;
}
.evo-editor-toolbar-main,
.evo-editor-toolbar-extra {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 0;
  padding: 6px;
}
.evo-editor-toolbar-extra {
  border-top: 1px solid var(--editor-border);
  background: var(--editor-surface);
}
.evo-editor-toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid var(--editor-border);
}
.evo-editor-toolbar-group:last-child {
  border-right: 0;
}
.evo-editor-toolbar-history {
  margin-left: auto;
}
.evo-editor .evo-editor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  line-height: 1;
  cursor: pointer;
}
.evo-editor .evo-editor-button svg {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}
.evo-editor .evo-editor-button:hover,
.evo-editor .evo-editor-button[aria-expanded="true"],
.evo-editor .evo-editor-button[aria-pressed="true"] {
  background: rgba(127, 127, 127, 0.18);
}
.evo-editor .evo-editor-button:disabled {
  opacity: 0.4;
  cursor: default;
}
.evo-editor .evo-editor-format-select {
  box-sizing: border-box;
  width: 138px;
  height: 34px;
  min-height: 0;
  margin: 0 2px;
  padding: 4px 6px !important;
  border: 1px solid var(--editor-border);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
/* .evo-editor .evo-editor-format-select[data-format-select="size"] {
  width: 98px;
} */
.evo-editor-format-select option {
  background: Canvas;
  color: CanvasText;
}
.evo-editor-format-select:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
@media (max-width: 480px) {
  .evo-editor-toolbar-main,
  .evo-editor-toolbar-extra {
    padding: 5px 2px;
    row-gap: 6px;
  }
  .evo-editor-toolbar-group {
    padding: 0 3px;
  }
  .evo-editor .evo-editor-button {
    width: 32px;
    height: 34px;
    padding: 7px 6px;
  }
}

/* Literal code snippets that remain within the surrounding sentence. */
.evo-editor-visual code[data-bb-tag="icode"] {
  padding: 0.12em 0.35em;
  border: 1px solid var(--editor-border);
  border-radius: 4px;
  background: var(--editor-inline-code-background, rgba(127, 127, 127, 0.16));
  color: var(--editor-inline-code-color, inherit);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.evo-editor-visual pre[data-bb-tag="code"] {
  margin: 18px 0;
}
/* Paragraph preview follows autop(): blank lines separate paragraphs. */
.evo-editor-visual {
  white-space: normal;
}
.evo-editor-visual [data-evo-paragraph] {
  margin: 0 0 1em;
  white-space: pre-wrap;
}
.evo-editor-visual [data-evo-paragraph]:last-child {
  margin-bottom: 0;
}
.evo-editor-visual [data-bb-tag="noparse"],
.evo-editor-visual li,
.evo-editor-visual [data-evo-reply] {
  white-space: pre-wrap;
}

/* Searchable emoji popover; variables allow light or dark theme overrides. */
.evo-editor .evo-emoji-picker {
  position: fixed;
  inset: auto;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  width: 500px;
  max-width: calc(100vw - 16px);
  height: 400px;
  max-height: calc(100dvh - 16px);
  margin: 0;
  padding: 16px;
  box-sizing: border-box;
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  background: var(--editor-picker-background, #fff);
  color: var(--editor-picker-color, #19344c);
  box-shadow: 0 8px 30px #0003;
  font: 14px/1.4 Arial, sans-serif;
  text-align: left;
  white-space: normal;
}
.evo-emoji-picker *, .evo-emoji-picker *::before, .evo-emoji-picker *::after { box-sizing: border-box; }
.evo-emoji-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.evo-emoji-header h2 { margin: 0; padding: 0; color: inherit; font: 400 20px/1.3 Arial, sans-serif; }
.evo-emoji-picker button { cursor: pointer; font: inherit; text-transform: none; letter-spacing: normal; box-shadow: none; }
.evo-emoji-picker .evo-emoji-dismiss { border: 0; padding: 0 5px; background: transparent; color: inherit; font-size: 26px; line-height: 1; }
.evo-emoji-body { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; flex: 1; min-height: 0; }
.evo-emoji-categories { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; align-items: stretch; }
.evo-emoji-picker .evo-emoji-category { display: block; width: 100%; border: 0; border-radius: 3px; padding: 5px 0; background: transparent; color: inherit; font-size: 13px; text-align: left; }
.evo-emoji-picker .evo-emoji-category[aria-pressed="true"] { color: var(--editor-picker-accent, #006fe6); text-decoration: underline; text-underline-offset: 4px; }
.evo-emoji-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.evo-emoji-search-label { display: block; font-size: 13px; }
.evo-editor .evo-emoji-search { width: 100%; min-width: 0; min-height: 35px; margin: 0; padding: 6px 9px; border: 1px solid #8796a5; border-radius: 5px; background: var(--editor-picker-input-background, #fff); color: inherit; font: inherit; }
.evo-emoji-status { min-height: 20px; padding: 3px 0; font-size: 11px; opacity: .8; }
.evo-emoji-results { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.evo-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); align-content: start; }
.evo-emoji-picker .evo-emoji-item { display: grid; place-items: center; width: 100%; height: 32px; min-width: 0; margin: 0; padding: 3px; border: 0; border-radius: 4px; background: transparent; color: inherit; font: 21px/1 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.evo-emoji-picker .evo-emoji-item:hover, .evo-emoji-picker .evo-emoji-category:hover { background: var(--editor-picker-hover, #eaf2ff); }
.evo-emoji-picker :is(button, input):focus-visible { outline: 2px solid var(--editor-picker-accent, #006fe6); outline-offset: -2px; }
.evo-emoji-picker .evo-emoji-more { width: 100%; margin: 8px 0; padding: 5px; border: 1px solid #9eabb8; border-radius: 4px; background: transparent; color: inherit; }
.evo-emoji-footer { display: flex; justify-content: flex-end; padding-top: 14px; }
.evo-emoji-picker .evo-emoji-close { padding: 7px 16px; border: 0; border-radius: 5px; background: var(--editor-picker-accent, #006fe6); color: #fff; }
@media (max-width: 420px) {
  .evo-editor .evo-emoji-picker { padding: 12px; }
  .evo-emoji-body { grid-template-columns: 105px minmax(0, 1fr); gap: 8px; }
  .evo-emoji-picker .evo-emoji-category { font-size: 12px; }
}

/* Image collage previews use the same two/three-column BBCode layouts. */
.evo-editor-visual .evo-editor-image-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  min-width: 0;
  white-space: normal;
}
.evo-editor-image-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.evo-editor-image-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.evo-editor-visual .evo-editor-image-grid > * { min-width: 0; max-width: 100%; }
.evo-editor-visual .evo-editor-image-grid img { display: block; width: 100%; height: auto; object-fit: contain; }
