/* The formatted-text editor (COMMAND-920, public/rich-edit): a toolbar and a contenteditable box that looks like the
   card page's description (the box carries .rt, app.css's rich text). Loaded by index.html after app.css. No inline
   style attributes (the CSP blocks them): a measured value is a custom property set with style.setProperty. No design
   yet: the toolbar row carries the POC marker (poc-ui). */

.rich-edit { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* The toolbar: sticky at the top of the field on a computer, at the bottom of the window's body on a phone (below). */
.rich-edit-bar {
  position: sticky; top: 0; z-index: 2; order: 0;
  display: flex; flex-wrap: wrap; gap: 2px; padding: 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.rich-edit-btn {
  min-width: 36px; height: 36px; padding: 0 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.rich-edit-btn { display: inline-flex; align-items: center; justify-content: center; }
.rich-edit-btn svg { width: 18px; height: 18px; }
.rich-edit-btn:hover, .rich-edit-btn:focus-visible { background: var(--surface-2); }

/* The link row under the toolbar; an address it refused is marked. */
.rich-edit-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rich-edit-link-label { flex-basis: 100%; }
.rich-edit-link-input { flex: 1; min-width: 12em; }
.rich-edit-link-input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 1px; }
.rich-edit-status { margin: 0; }
.rich-edit-link[hidden], .rich-edit-status[hidden], .rich-edit-file[hidden], .rich-edit-hidden { display: none; }

/* The box: the rest of the window's height; on a computer at least about half the screen. */
.rich-edit-box {
  order: 1; min-height: 50vh; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
  outline: none; overflow-wrap: anywhere; cursor: text;
}
.rich-edit-box:focus { border-color: var(--accent); }
.rich-edit-box img { max-width: 100%; height: auto; border-radius: 8px; vertical-align: middle; }

/* A record tag or a file tag in a sentence: an atomic chip. */
.rich-edit-chip { display: inline-block; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--accent); font-size: 0.92em; }

/* A picture of ours: an atomic box with its × (the × drawn here, so a copy of the text never carries it). */
.rich-edit-pic { position: relative; display: inline-block; max-width: 100%; }
.rich-edit-pic-x {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: rgb(0 0 0 / 60%); color: #fff; cursor: pointer;
}
.rich-edit-pic-x::before { content: '×'; font-size: 1.1rem; line-height: 28px; }

/* A block the editor keeps as it is (a table, a code block, a file on its own line): shown as on the page, with a
   faint dashed edge. */
.rich-edit-locked { position: relative; margin: 0 0 10px; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 8px; cursor: default; }
.rich-edit-locked > :last-child { margin-bottom: 0; }

/* A phone: the toolbar at the bottom of the window's body; while the editor has the focus the window that carries
   rich-edit-fit takes the visible height (--rich-vv-h, set from visualViewport), so the toolbar stays right above the
   keyboard (iOS does not shrink the page for it). */
@media (max-width: 899px) {
  .rich-edit-box { min-height: 40vh; }
  .rich-edit-bar { order: 2; top: auto; bottom: 0; }
  .rich-edit-focus .rich-edit-fit { height: var(--rich-vv-h, 100dvh); max-height: var(--rich-vv-h, 100dvh); }
}
