/* @corestone/editor: toolbar from docs/design/Corestone editor toolbar demo.html, and the text area. */
/* The --cs-* colours are the editor's theme; a host page may set them (the Corestone app maps its light/dark tokens). */
.cs-editor { --cs-border: #d0d7de; --cs-hover: #eef1f5; --cs-pressed: #dde6f3; --cs-muted: #57606a; --cs-text: #1f2328; --cs-panel: #fff;
  --cs-disabled: #a5acb4; --cs-focus: rgba(21,101,192,.25); --cs-link: #1565c0; --cs-error: #c62828;
  --cs-stripe: color-mix(in srgb, var(--cs-hover) 60%, transparent); --cs-guide: color-mix(in srgb, var(--cs-border) 70%, transparent);
  /* the blocks of @corestone/ui (ui.css: menus, dialog heads) in the editor's colours */
  --ui-panel: var(--cs-panel); --ui-text: var(--cs-text); --ui-border: var(--cs-border); --ui-hover: var(--cs-hover); --ui-muted: var(--cs-muted);
  --ui-accent: var(--cs-link); --ui-error: var(--cs-error);
  position: relative;
  max-width: 640px; color: var(--cs-text); font: 14px/1.5 Inter, Arial, sans-serif; }
.cs-editor *, .cs-editor *::before, .cs-editor *::after { box-sizing: border-box; }

.cs-tb { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; background: var(--cs-panel); border: 1px solid var(--cs-border);
  border-radius: 10px 10px 0 0; padding: 6px 8px; position: sticky; top: 0; z-index: 5; }
.cs-tb .b { height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent;
  border-radius: 6px; color: var(--cs-text); font: inherit; padding: 0 6px; cursor: pointer; }
.cs-tb .b:hover, .cs-tb .b:focus-visible { background: var(--cs-hover); outline: none; }
.cs-tb .b[aria-pressed="true"] { background: var(--cs-pressed); }
.cs-tb .b[aria-disabled="true"] { color: var(--cs-disabled); cursor: not-allowed; background: transparent; }
/* icons with their own colors (e.g. entry type icons) are greyed too */
.cs-tb .b[aria-disabled="true"] > :not(svg) { opacity: .4; filter: grayscale(1); }
.cs-tb .c { height: 32px; width: 12px; border: 0; background: transparent; border-left: 1px solid var(--cs-border); color: var(--cs-muted); padding: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 0 6px 6px 0; }
.cs-tb .c:hover, .cs-tb .c[aria-expanded="true"] { background: var(--cs-pressed); }
.cs-tb .sp { position: relative; display: inline-flex; align-items: center; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--cs-border); }
.cs-tb .sp > .b { border-radius: 6px 0 0 6px; }
.cs-tb .sp.gap { margin-left: 10px; }
.cs-tb .sep { width: 1px; height: 22px; background: var(--cs-border); margin: 0 3px; }
.cs-tb .cw { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.cs-tb .cw i { display: block; width: 16px; height: 3px; border-radius: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.cs-tb .sz { width: 36px; height: 26px; border: 1px solid var(--cs-border); border-radius: 5px; text-align: center; font: inherit; margin: 0 2px; padding: 0; }
.cs-tb .sz.bad { border-color: var(--cs-error); color: var(--cs-error); }
.cs-tb .fontsel { justify-content: flex-start; padding: 0 4px; width: 84px; }
.cs-tb .fn { display: block; width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.cs-tb .pop { position: absolute; top: 36px; left: 0; background: var(--cs-panel); border: 1px solid var(--cs-border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1); padding: 6px; display: none; gap: 2px; z-index: 10; white-space: nowrap; }
.cs-tb .pop.open { display: flex; }
.cs-tb .pop.cgrid.open { display: grid; grid-template-columns: repeat(9, auto); gap: 4px; align-items: center; }
.cs-tb .pop.col { flex-direction: column; min-width: 160px; }
.cs-tb .f { border: 0; background: transparent; text-align: left; padding: 6px 10px; border-radius: 6px; font-size: 15px; color: var(--cs-text); cursor: pointer; }
.cs-tb .f:hover { background: var(--cs-hover); }
.cs-tb .sw { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--cs-border); cursor: pointer; padding: 0; }
.cs-tb .sw:hover { outline: 2px solid #1565c0; outline-offset: 1px; }
.cs-tb .sw.empty { background: repeating-linear-gradient(45deg, var(--cs-panel) 0 3px, var(--cs-hover) 3px 6px); border-style: dashed; cursor: default; outline: none; }
.cs-tb label.b input[type=color] { width: 0; height: 0; opacity: 0; border: 0; padding: 0; position: absolute; }
.cs-tb .none { grid-column: 1 / -1; justify-content: flex-start; }
.cs-tb .none::after { content: attr(aria-label); font-size: 13px; }

.cs-area { background: var(--cs-panel); border: 1px solid var(--cs-border); border-top: 0; border-radius: 0 0 10px 10px; }
.cs-area .ProseMirror { min-height: 140px; padding: 14px 18px; outline: none; white-space: pre-wrap; word-wrap: break-word; font-variant-ligatures: none; }
.cs-area .ProseMirror p { margin: 0 0 .5em; }
/* List markers are drawn by the editor, at the start of an item's first line: they follow the
   paragraph's alignment, and nested numbered lists count across levels (1.2.3). Left-aligned
   items hang the marker so wrapped lines line up with the text. */
.cs-area .ProseMirror ul, .cs-area .ProseMirror ol { margin: 0 0 .5em; padding-left: 0; list-style: none; }
.cs-area .ProseMirror ol { counter-reset: cs-item; }
.cs-area .ProseMirror ol > li { counter-increment: cs-item; }
.cs-area .ProseMirror li { margin-left: 1.6em; }
.cs-area .ProseMirror li > p, .cs-area .ProseMirror li > ul, .cs-area .ProseMirror li > ol { margin: 0; }
.cs-area .ProseMirror li > p:first-child::before { display: inline-block; min-width: 1.6em; margin-left: -1.6em; padding-right: .3em; text-align: right; }
.cs-area .ProseMirror ul > li > p:first-child::before { content: "•"; text-align: center; }
.cs-area .ProseMirror ul ul > li > p:first-child::before { content: "◦"; }
.cs-area .ProseMirror ul ul ul > li > p:first-child::before { content: "▪"; }
.cs-area .ProseMirror ol > li > p:first-child::before { content: counters(cs-item, ".") "."; }
.cs-area .ProseMirror li > p[style*="text-align"]:first-child::before { min-width: 0; margin-left: 0; }
.cs-area .ProseMirror:focus-within { box-shadow: inset 0 0 0 2px var(--cs-focus); border-radius: 0 0 10px 10px; }
.cs-document > .cs-area > .ProseMirror:focus-within { box-shadow: none; } /* a page: the cursor is enough */

/* read-only: the text alone, without the toolbar */
.cs-editor.readonly .cs-tb { display: none; }
.cs-editor.readonly .cs-area { border-top: 1px solid var(--cs-border); border-radius: 10px; }
.cs-editor.readonly .cs-area .ProseMirror { min-height: 0; }

/* links: web links underlined, item links dashed; they open on Ctrl/⌘+click while editing, on a click when reading */
.cs-area .ProseMirror a { color: var(--cs-link); text-decoration: underline; cursor: text; }
.cs-area .ProseMirror a.cs-item { text-decoration-style: dashed; }
.cs-editor.readonly .cs-area .ProseMirror a { cursor: pointer; }
/* The editor's small dialogs are panels of @corestone/ui (.ui-pop in ui.css: colours, border, corners, shadow);
   here they get the editor's text size and lose the limits a menu has. Each sets its own width and padding below. */
.cs-pop { z-index: 20; min-width: 0; max-width: none; max-height: none; overflow: visible; padding: 0; font-size: 13px; }
/* the bubble under a link is no dialog: it has a frame of its own */
.cs-linkbubble { position: absolute; z-index: 20; background: var(--cs-panel); color: var(--cs-text); border: 1px solid var(--cs-border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); font-size: 13px; }
.cs-linkpop { padding: 8px; width: min(440px, 100%); }
.cs-linkpop .row { display: flex; gap: 4px; align-items: center; }
.cs-linkpop .addr { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--cs-border); border-radius: 5px; padding: 0 8px;
  font: inherit; background: var(--cs-panel); color: inherit; }
.cs-linkpop .addr.bad { border-color: var(--cs-error); }
.cs-linkpop .msg { color: var(--cs-muted); font-size: 12px; margin-top: 4px; }
.cs-linkpop .msg:empty { display: none; }
.cs-linkpop .addr.bad ~ .msg, .cs-linkpop:has(.addr.bad) .msg { color: var(--cs-error); }
.cs-linkbubble { display: flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; max-width: min(440px, 100%); }
.cs-linkbubble .tgt { color: var(--cs-link); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; margin-right: 6px; cursor: pointer; }
.cs-editor .lb { height: 26px; padding: 0 8px; border: 0; border-radius: 5px; background: transparent; color: var(--cs-text); font: inherit; cursor: pointer; white-space: nowrap; }
.cs-editor .lb:hover { background: var(--cs-hover); }
.cs-editor .lb.apply { background: var(--cs-pressed); }
.cs-linkbubble[hidden], .cs-editor .lb[hidden] { display: none; }

/* tables (prosemirror-tables): grid lines, header row, selected cells, column resizing */
.cs-area .ProseMirror .tableWrapper { overflow-x: auto; margin: 0 0 .5em; }
.cs-area .ProseMirror table { border-collapse: collapse; table-layout: fixed; width: 100%; margin: 0 0 .5em; }
.cs-area .ProseMirror .tableWrapper table { margin: 0; }
.cs-area .ProseMirror td, .cs-area .ProseMirror th { border: 1px solid var(--cs-border); padding: 4px 8px; vertical-align: top;
  position: relative; min-width: 2em; box-sizing: border-box; text-align: left; }
.cs-area .ProseMirror th { background: var(--cs-hover); font-weight: 600; }
/* the last paragraph of a cell has no margin, also while the column resize handle (added at the
   cell's end while the pointer is on a column edge) follows it: otherwise the row jumps */
.cs-area .ProseMirror :is(td, th) > :last-child, .cs-area .ProseMirror :is(td, th) > :has(+ .column-resize-handle:last-child) { margin-bottom: 0; }
.cs-area .ProseMirror .selectedCell::after { content: ""; position: absolute; inset: 0; background: var(--cs-focus); pointer-events: none; }
.cs-area .ProseMirror .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; background: var(--cs-link); pointer-events: none; z-index: 2; }
.cs-area .ProseMirror.resize-cursor { cursor: col-resize; }
.cs-editor.readonly .cs-area .ProseMirror .column-resize-handle { display: none; }

/* table style: stripes, and which lines are drawn (absent: the full grid). While editing, lines
   that are not drawn show as faint dashes so that the cells can be found. */
.cs-area .ProseMirror table.cs-s-rows tr:nth-child(odd) > td,
.cs-area .ProseMirror table.cs-s-columns tr > td:nth-child(odd) { background: var(--cs-s1, transparent); color: var(--cs-s1-ink, inherit); }
.cs-area .ProseMirror table.cs-s-rows tr:nth-child(even) > td,
.cs-area .ProseMirror table.cs-s-columns tr > td:nth-child(even) { background: var(--cs-s2, var(--cs-stripe)); color: var(--cs-s2-ink, inherit); }
.cs-area .ProseMirror table:is(.cs-b-none, .cs-b-outside) :is(td, th) { border-style: none; }
.cs-area .ProseMirror table.cs-b-rows :is(td, th) { border-left-style: none; border-right-style: none; }
.cs-area .ProseMirror table.cs-b-columns :is(td, th) { border-top-style: none; border-bottom-style: none; }
.cs-area .ProseMirror table.cs-b-outside { border: 1px solid var(--cs-border); }
.cs-editor:not(.readonly) .cs-area .ProseMirror table:is(.cs-b-none, .cs-b-outside) :is(td, th) { border: 1px dashed var(--cs-guide); }
.cs-editor:not(.readonly) .cs-area .ProseMirror table.cs-b-rows :is(td, th) { border-left: 1px dashed var(--cs-guide); border-right: 1px dashed var(--cs-guide); }
.cs-editor:not(.readonly) .cs-area .ProseMirror table.cs-b-columns :is(td, th) { border-top: 1px dashed var(--cs-guide); border-bottom: 1px dashed var(--cs-guide); }

/* table panels: the size grid, the context menu, the properties dialog */
.cs-tablegrid { padding: 8px; }
.cs-tablegrid .size { color: var(--cs-muted); margin-bottom: 6px; }
.cs-tablegrid .cells { display: grid; grid-template-columns: repeat(10, 18px); gap: 2px; }
.cs-tablegrid .cells button { width: 18px; height: 18px; padding: 0; border: 1px solid var(--cs-border); border-radius: 3px; background: var(--cs-panel); cursor: pointer; }
.cs-tablegrid .cells button.on { background: var(--cs-pressed); border-color: var(--cs-link); }
/* the menus are those of @corestone/ui (ui.css); here they only get the editor's size (the colours: .cs-editor) */
.cs-menu { font-size: 13px; }
.cs-tableprops { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; width: 262px; }
/* The head of the small dialogs is dialogHead's (.ui-head in ui.css); here its close button only moves into the padding. */
.cs-tableprops .head, .cs-formulapop .head, .cs-filepop .head { margin-right: -4px; }
/* A choice among a few options, shown as icon buttons. */
:is(.cs-tableprops, .cs-formulapop) button.opt { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 30px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--cs-text); cursor: pointer; }
:is(.cs-tableprops, .cs-formulapop) button.opt:hover { background: var(--cs-hover); }
:is(.cs-tableprops, .cs-formulapop) button.opt[aria-checked="true"] { background: var(--cs-pressed); box-shadow: inset 0 0 0 1px var(--cs-link); }
.cs-tableprops .size { display: flex; align-items: center; gap: 6px; }
.cs-tableprops .num { display: inline-flex; align-items: center; gap: 4px; color: var(--cs-muted); }
.cs-tableprops .times { color: var(--cs-muted); }
.cs-tableprops .line { display: flex; flex-direction: column; gap: 2px; }
.cs-tableprops .lbl { color: var(--cs-muted); font-size: 12px; }
.cs-tableprops .choice { display: flex; gap: 2px; }
.cs-tableprops .colors { display: flex; align-items: center; gap: 6px; }
.cs-tableprops .colors[hidden] { display: none; }
.cs-tableprops .sq { width: 26px; height: 26px; border: 1px solid var(--cs-border); border-radius: 5px; padding: 0; cursor: pointer; background: var(--cs-panel); }
.cs-tableprops .sq.theme { background: repeating-linear-gradient(45deg, var(--cs-panel) 0 4px, var(--cs-hover) 4px 8px); }
.cs-tableprops input, .cs-tableprops select { height: 28px; border: 1px solid var(--cs-border); border-radius: 5px; padding: 0 6px; font: inherit;
  font-size: 13px; background: var(--cs-panel); color: var(--cs-text); }
.cs-tableprops input { width: 64px; }
.cs-tableprops select { flex: 1; min-width: 0; }
.cs-tableprops .msg { color: var(--cs-error); font-size: 12px; }
.cs-tableprops .msg:empty { display: none; }
.cs-tableprops .btns { display: flex; justify-content: flex-end; }
.cs-tableprops .colorpop { position: absolute; z-index: 1; display: grid; grid-template-columns: repeat(8, 24px); gap: 4px; padding: 6px;
  background: var(--cs-panel); border: 1px solid var(--cs-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.cs-tableprops .colorpop[hidden] { display: none; }
.cs-tableprops .colorpop .sw { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--cs-border); cursor: pointer; padding: 0; }
.cs-tableprops .colorpop .pick { position: relative; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; cursor: pointer; color: var(--cs-text); }
.cs-tableprops .colorpop .pick:hover { background: var(--cs-hover); }
.cs-tableprops .colorpop .pick input { position: absolute; width: 0; height: 0; opacity: 0; border: 0; padding: 0; }

/* images: inline, at most the text's width; selected ones get an outline and a resize handle */
.cs-area .ProseMirror .cs-img { position: relative; display: inline-block; max-width: 100%; line-height: 0; vertical-align: bottom; }
.cs-area .ProseMirror .cs-img img { max-width: 100%; height: auto; border-radius: 2px; }
.cs-area .ProseMirror .cs-img img:not([src]) { width: 120px; height: 80px; background: var(--cs-hover); }
.cs-area .ProseMirror .cs-img.pending img { opacity: .4; }
.cs-area .ProseMirror .cs-img.selected img { outline: 2px solid var(--cs-link); outline-offset: 1px; }
.cs-area .ProseMirror .cs-img .handle { display: none; position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px;
  background: var(--cs-panel); border: 2px solid var(--cs-link); border-radius: 2px; cursor: nwse-resize; }
.cs-editor:not(.readonly) .cs-area .ProseMirror .cs-img.selected .handle { display: block; }
/* a file link: a small file sign before its name */
.cs-area .ProseMirror a.cs-file::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: 2px; vertical-align: -.1em;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E") center / contain no-repeat; }

/* formulas: their picture as a mask in the colour of the text; the LaTeX while there is none */
.cs-area .ProseMirror .cs-formula { display: inline-block; line-height: 0; border-radius: 2px; }
.cs-area .ProseMirror .cs-formula .glyph { display: inline-block; background: currentColor;
  -webkit-mask: var(--cs-formula) center / 100% 100% no-repeat; mask: var(--cs-formula) center / 100% 100% no-repeat; }
.cs-area .ProseMirror .cs-formula.display { display: block; width: fit-content; margin: .5em auto; }
.cs-area .ProseMirror .cs-formula.source { line-height: inherit; font-family: ui-monospace, monospace; font-size: .9em; color: var(--cs-muted); }
.cs-area .ProseMirror .cs-formula.pending { opacity: .5; }
.cs-area .ProseMirror .cs-formula.selected { outline: 2px solid var(--cs-link); outline-offset: 2px; }
.cs-editor:not(.readonly) .cs-area .ProseMirror .cs-formula { cursor: pointer; }
.cs-formulapop { padding: 8px 10px 10px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 8px; box-sizing: border-box; }
.cs-formulapop .latex { width: 100%; height: auto; min-height: 0; flex: none; box-sizing: border-box; resize: vertical; border: 1px solid var(--cs-border); border-radius: 5px; padding: 6px 8px;
  font: 13px/1.4 ui-monospace, monospace; background: var(--cs-panel); color: inherit; }
.cs-formulapop .preview { min-height: 40px; max-height: 200px; overflow: auto; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--cs-border); border-radius: 5px; padding: 6px; }
.cs-formulapop .preview img { max-width: none; }
.cs-formulapop .lb.apply[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.cs-formulapop .msg { color: var(--cs-error); min-height: 1em; }
.cs-formulapop .msg:empty { display: none; }
.cs-formulapop .foot { display: flex; align-items: center; justify-content: space-between; }
.cs-formulapop .choice { display: flex; gap: 2px; }

/* diagrams: shown like images, on white (draw.io draws for a light page); draw.io in a large panel */
.cs-area .ProseMirror .cs-diagram img { background: #fff; }
/* the backdrop darkens and blurs the page; the box is the dialog */
.cs-diagrampop { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.25); backdrop-filter: blur(2px); }
.cs-diagrampop .box { position: absolute; inset: 6vh 6vw; display: flex; flex-direction: column; background: var(--cs-panel);
  color: var(--cs-text); border: 1px solid var(--cs-border); border-radius: 10px; box-shadow: 0 16px 48px rgba(0,0,0,.28); overflow: hidden; }
.cs-diagrampop[hidden] { display: none; }
.cs-diagrampop .head { gap: 10px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--cs-border); font-size: 13px; }
.cs-diagrampop .title { flex: 1; }
.cs-diagrampop .ask { display: inline-flex; align-items: center; gap: 6px; }
.cs-diagrampop .ask[hidden] { display: none; }
.cs-diagrampop .lb.danger { color: var(--cs-error); }
.cs-diagrampop iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* the file picker, the alternative text, notices */
.cs-filepop { padding: 8px 10px 10px; width: 280px; display: flex; flex-direction: column; gap: 8px; }
.cs-filepop .list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.cs-filepop .list .none { color: var(--cs-muted); padding: 4px 0; }
.cs-filepop button.file { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cs-filepop button.file:hover, .cs-filepop button.file:focus-visible { background: var(--cs-hover); outline: none; }
.cs-filepop button.file img { width: 40px; height: 28px; object-fit: cover; border-radius: 3px; border: 1px solid var(--cs-border); flex: none; }
.cs-filepop button.file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-filepop .upload { display: inline-flex; align-items: center; gap: 6px; align-self: flex-end; }
.cs-altpop { padding: 8px; display: flex; gap: 4px; width: min(360px, 100%); }
.cs-altpop .alt { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--cs-border); border-radius: 5px; padding: 0 8px; font: inherit;
  background: var(--cs-panel); color: inherit; }
.cs-notice { position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 20; padding: 6px 10px; border-radius: 6px; font-size: 13px;
  background: var(--cs-text); color: var(--cs-panel); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.cs-notice[hidden] { display: none; }

/* documents: headings by level (Arial, bold; deeper than 6 underlined), their numbers, placed
   entries, cross-references and generated lists */
.cs-editor.cs-document { max-width: 900px; }
/* a toolbar placed by the host elsewhere: its own row of the host's bar */
.cs-editor.cs-tbhost { max-width: none; min-width: 0; }
.cs-editor.cs-tbhost .cs-tb { border: 0; border-radius: 0; background: transparent; padding: 0; }
.cs-editor.cs-document > .cs-editor.cs-tbaway .cs-area { border-top: 1px solid var(--cs-border); border-radius: 10px; }
.cs-document > .cs-area > .ProseMirror { min-height: 60vh; padding: 20px 28px; }
.cs-document .cs-section { display: block; }
.cs-document .cs-heading { font-family: Arial, Helvetica, sans-serif; font-weight: 700; line-height: 1.25; margin: 1em 0 .4em; }
.cs-document .cs-heading::before { content: attr(data-num); margin-right: .6em; color: var(--cs-muted); font-weight: 600; }
.cs-document .cs-heading:empty::after, .cs-document .cs-heading:has(> br:only-child)::after { content: "Heading"; color: var(--cs-disabled, #8c959f); font-weight: 400; }
.cs-document .cs-h1 { font-size: 1.75em; }
.cs-document .cs-h2 { font-size: 1.45em; }
.cs-document .cs-h3 { font-size: 1.25em; }
.cs-document .cs-h4 { font-size: 1.1em; }
.cs-document .cs-h5 { font-size: 1em; }
.cs-document .cs-h6, .cs-document .cs-h7 { font-size: .95em; }
.cs-document .cs-h7 { text-decoration: underline; }
.cs-document .cs-placement { position: relative; margin: .4em 0 .6em; border-radius: 8px; cursor: default; white-space: normal; } /* the host's markup, not text */
.cs-document .cs-placement.ProseMirror-selectednode { outline: 2px solid var(--cs-link); outline-offset: 2px; }
.cs-document .cs-toc { margin: .5em 0 1em; padding: 8px 12px; border: 1px dashed var(--cs-border); border-radius: 8px; }
.cs-document .cs-toc .toc-head { font-weight: 700; margin-bottom: 4px; }
.cs-document .cs-toc .toc-row { line-height: 1.6; }
.cs-document .cs-toc .toc-none { color: var(--cs-muted, inherit); opacity: .7; }
.cs-document .ProseMirror[contenteditable="false"] .cs-toc .toc-row { cursor: pointer; }
.cs-document .ProseMirror[contenteditable="false"] .cs-toc .toc-row:hover { text-decoration: underline; }
.cs-xref { color: var(--cs-link); text-decoration: underline dotted; cursor: pointer; }
.cs-xref.missing { color: var(--cs-error); text-decoration: line-through; }
.cs-xrefpop { width: 320px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cs-xrefpop .head { font-weight: 600; }
.cs-xrefpop .filter { height: 28px; padding: 0 8px; border: 1px solid var(--cs-border); border-radius: 6px; background: var(--cs-panel); color: var(--cs-text); }
.cs-xrefpop .list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.cs-xrefpop .row { text-align: left; padding: 5px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--cs-text); cursor: pointer; }
.cs-xrefpop .row:hover, .cs-xrefpop .row:focus-visible { background: var(--cs-hover); outline: none; }
.cs-xrefpop .none { color: var(--cs-muted); padding: 4px 8px; }

/* code: a listing (fixed-width, tighter lines, a frame; line numbers, language and a copy button) and code within a line */
.cs-area .cs-inline-code { font-family: 'Courier New', Courier, monospace; background: var(--cs-hover); border-radius: 3px; padding: 0 .25em; }
.cs-area .cs-code { position: relative; margin: .2em 0 .7em; border: 1px solid var(--cs-border); border-radius: 6px; background: var(--cs-panel);
  font-family: 'Courier New', Courier, monospace; font-size: .92em; line-height: 1.25; --cs-gutter: calc(var(--cs-digits, 2) * 1ch + 18px); }
/* (pre and code are not positioned: the numbers are placed against the frame, so they stay put when the text scrolls sideways) */
.cs-area .cs-code pre { min-width: 0; min-height: 0; max-height: none; margin: 0; padding: 8px 12px; overflow-x: auto; white-space: pre; font: inherit;
  border: 0; border-radius: 0; background: transparent; color: inherit; }
.cs-area .cs-code code { display: block; min-width: max-content; white-space: pre; font: inherit; outline: none; padding: 0; border: 0; background: transparent; }
/* with numbers: a column left of the text, and a strip above the first line for the small × that hides them */
.cs-area .cs-code.numbered pre { margin-left: var(--cs-gutter); padding-top: 16px; border-left: 1px solid var(--cs-border); }
.cs-area .cs-code .ln { display: none; }
.cs-area .cs-code.numbered .ln { display: block; position: absolute; left: 0; width: calc(var(--cs-gutter) - 8px); text-align: right; color: var(--cs-muted);
  user-select: none; pointer-events: none; }
.cs-area .cs-code .ln::before { content: attr(data-n); }
.cs-area .cs-code .off { display: none; position: absolute; top: 1px; left: calc(var(--cs-gutter) - 22px); width: 14px; height: 14px; padding: 0; border: 0;
  background: transparent; color: var(--cs-muted); font: 11px/14px Arial, Helvetica, sans-serif; cursor: pointer; border-radius: 3px; }
.cs-area .cs-code.numbered .off { display: block; }
.cs-area .cs-code .off:hover { background: var(--cs-hover); color: var(--cs-text); }
.cs-area .cs-code .tools { position: absolute; top: 3px; right: 4px; display: flex; align-items: center; gap: 6px; opacity: .5; }
.cs-area .cs-code .tools:hover, .cs-area .cs-code .tools:focus-within { opacity: 1; }
.cs-area .cs-code .lang { font: 11px Arial, Helvetica, sans-serif; color: var(--cs-muted); user-select: none; }
.cs-area .cs-code .copy { display: grid; place-items: center; width: 24px; height: 22px; padding: 0; border: 1px solid var(--cs-border); border-radius: 5px;
  background: var(--cs-panel); color: var(--cs-text); cursor: pointer; }
.cs-area .cs-code .copy:hover { background: var(--cs-hover); }
.cs-area .cs-code .copy.done { color: var(--cs-link); border-color: var(--cs-link); }
.cs-editor.readonly .cs-code.numbered .off { display: none; }
/* on paper nothing scrolls: long lines wrap (anywhere, if they have no spaces), and a number stays with its line */
@media print {
  .cs-area .cs-code .tools, .cs-area .cs-code.numbered .off { display: none; }
  .cs-area .cs-code pre { overflow: visible; white-space: pre-wrap; overflow-wrap: anywhere; }
  .cs-area .cs-code code { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
  .cs-area .cs-code.numbered pre { padding-top: 8px; }
}
