/* ---- chapter editor ---- */
.editor-canvas { min-height: 60vh; border: 2px dashed #ced4da; border-radius: .5rem; padding: .75rem; background: #fafbfc; }
.editor-canvas.drag-over { border-color: #0d6efd; background: #f0f6ff; }
.editor-empty { text-align: center; padding: 3rem 1rem; }
.editor-canvas:not(:has(.block)) .editor-empty { display: block; }
.editor-canvas:has(.block) .editor-empty { display: none; }
.block { background: #fff; border: 1px solid #dee2e6; border-radius: .5rem; margin-bottom: .75rem; }
.block.dragging { opacity: .4; }
.block-head { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border-bottom: 1px solid #eee; background: #f8f9fa; border-radius: .5rem .5rem 0 0; }
.block-handle { cursor: grab; user-select: none; color: #6c757d; }
.block-type { font-weight: 600; flex: 1; }
.block-type svg { width: 1.15rem; height: 1.15rem; vertical-align: -.22rem; margin-right: .45rem; color: #495057; }
.block-body { padding: .75rem; }
.block-body textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875rem; }
.drop-slot { height: 6px; margin: -3px 0; border-radius: 3px; }
.drop-slot.active { height: 14px; background: #0d6efd; margin: 2px 0; }

.quill-host { min-height: 220px; font-size: 1rem; }
.quill-host .ql-editor { min-height: 180px; }
.block-body .ql-toolbar { border-radius: .4rem .4rem 0 0; background: #f8f9fa; }
.block-body .ql-container { border-radius: 0 0 .4rem .4rem; }

.math-preview { border: 1px solid #dee2e6; border-radius: .4rem; padding: .75rem; min-height: 3rem; overflow-x: auto; background: #fff; }

/* ---- chapter view ---- */
.course-math-out { padding: .5rem 0; overflow-x: auto; }
.course-text .ql-size-small { font-size: .8em; }
.course-text .ql-size-large { font-size: 1.4em; }
.course-text .ql-size-huge { font-size: 2em; }
.course-text .ql-align-center { text-align: center; }
.course-text .ql-align-right { text-align: right; }
.course-text .ql-align-justify { text-align: justify; }
.course-text .ql-indent-1 { padding-left: 3em; }  .course-text .ql-indent-2 { padding-left: 6em; }
.course-text .ql-indent-3 { padding-left: 9em; }  .course-text .ql-indent-4 { padding-left: 12em; }
.course-text .ql-indent-5 { padding-left: 15em; } .course-text .ql-indent-6 { padding-left: 18em; }
.course-text .ql-indent-7 { padding-left: 21em; } .course-text .ql-indent-8 { padding-left: 24em; }
.course-text blockquote { border-left: 4px solid #ccc; margin: 1rem 0; padding-left: 1rem; color: #555; }
.course-text h2, .course-text h3, .course-text h4 { margin-top: 1.5rem; }
.course-text pre { background: #f6f8fa; padding: .75rem; border-radius: .4rem; overflow-x: auto; }
/* Inline drawings keep their authored size on a wide screen and shrink in
   proportion on a narrow one (every drawing carries a viewBox). */
.course-text svg { max-width: 100%; height: auto; }
/* Real tables: styled, and scrolling sideways inside themselves when wider
   than the column, so the page itself never scrolls sideways. */
.course-text table { display: block; width: max-content; max-width: 100%; overflow-x: auto;
                     border-collapse: collapse; margin: 1rem 0; }
.course-text th, .course-text td { border: 1px solid #dee2e6; padding: .35rem .9rem; text-align: center; }
/* The dark row is the header row: <thead>, or the first row of a table written without one.
   A header column (the first cell of each body row) is lighter. */
.course-text tbody th { background: #e9edf2; }
.course-text thead th,
.course-text table > tbody:first-child > tr:first-child > th,
.course-text table > caption + tbody > tr:first-child > th { background: #2f3b4c; color: #fff; white-space: nowrap; }
.course-text tbody tr:nth-child(even) { background: #f4f6f8; }
.course-text img { max-width: 100%; height: auto; }
/* A timing diagram or typed diagram: an image drawn in the browser (diagrams.js). It shrinks
   to a narrow column, down to 60% of its size (set on the image); beyond that it scrolls sideways. */
.course-drawn { margin: 1rem 0; }
.course-drawn-out { overflow-x: auto; }
.course-drawn-img, .drawn-preview img { max-width: 100%; height: auto; display: block; }
.course-drawn-source { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: .4rem; padding: .5rem .75rem; font-size: .8rem; margin: .35rem 0 0; white-space: pre-wrap; }
.course-code-pre { background: #1e1e1e; color: #d4d4d4; padding: .75rem; border-radius: .4rem; overflow-x: auto; font-size: .875rem; }
.course-code .monaco-host { border: 1px solid #dee2e6; border-radius: .4rem; overflow: hidden; }
.course-code-tools { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; }
.sim-editor { border: 1px solid #dee2e6; border-radius: .4rem; min-height: 160px; }
.sim-wave .iw { margin-top: .25rem; }

/* ---- logic canvas (circuit.js) ---- */
.ic { border: 1px solid #d0d5db; border-radius: .5rem; background: #fff; overflow: hidden; }
.ic-bar { display: flex; flex-wrap: wrap; gap: .3rem; padding: .4rem .5rem; background: #f8f9fa; border-bottom: 1px solid #e3e6ea; }
.ic-btn { font-size: .8rem; padding: .15rem .5rem; border: 1px solid #c9ced4; border-radius: .3rem; background: #fff; cursor: pointer; }
.ic-btn:hover { background: #eef1f4; }
.ic-btn.ic-primary { background: #0d6efd; border-color: #0d6efd; color: #fff; margin-left: auto; }
.ic-btn.ic-danger { color: #b02a37; border-color: #e3a6ac; }
/* how many inputs the selected multiplexer has */
.ic-size { display: inline-flex; align-items: center; gap: .3rem; margin: 0 0 0 .35rem; font-size: .8rem; color: #495057; white-space: nowrap; }
.ic-size[hidden] { display: none; }
.ic-size-select { font-size: .8rem; padding: .1rem .3rem; border: 1px solid #0d6efd; border-radius: .3rem; background: #fff; }
/* In the chapter editor the canvas's controls sit on the card's title bar, the add buttons as gate symbols. */
.ic-bar.ic-bar-head { padding: 0; background: none; border: 0; align-items: center; gap: .25rem; }
.ic-btn.ic-icon { padding: .12rem .2rem; line-height: 0; color: #343a40; }
.ic-btn.ic-icon svg { display: block; }
.block-head.has-tools { flex-wrap: wrap; row-gap: .35rem; }
.block-head.has-tools .block-type { flex: 0 0 auto; }
.block-tools { flex: 1 1 14rem; min-width: 0; }
.ic-svg { display: block; width: 100%; touch-action: none; user-select: none; }
.ic-comp { cursor: grab; }
.ic-pin { cursor: crosshair; }
.ic-wire-hit { cursor: pointer; }
.ic-label { font: 600 var(--ic-label, 12px) ui-monospace, Menlo, Consolas, monospace; fill: #222; pointer-events: none; }
.ic-sym { font: 700 14px system-ui, sans-serif; fill: #222; pointer-events: none; }
.ic-pinname { font: var(--ic-small, 10px) ui-monospace, Menlo, Consolas, monospace; fill: #666; pointer-events: none; }
.ic-status { font-size: .8rem; color: #666; padding: .3rem .6rem; border-top: 1px solid #eef0f2; min-height: 1.6rem; }
.ic-result:not(:empty) { padding: .5rem .6rem; border-top: 1px solid #eef0f2; }
.ic-verdict { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.ic-good { color: #146c43; } .ic-bad { color: #b02a37; }
.ic-table { border-collapse: collapse; font: 12px ui-monospace, Menlo, Consolas, monospace; }
.ic-table th, .ic-table td { border: 1px solid #dee2e6; padding: .1rem .5rem; text-align: center; }
.ic-table th { background: #f1f3f5; } .ic-table .ic-out { background: #f6fbf7; } .ic-table .ic-exp { color: #666; }
.ic-table tr.ic-rowbad td { background: #fde8e8; }
.ic-sym-small { font-size: 11px; }

/* ---- chapter reader: contents panel (course_nav.js) ---- */
/* The panel is pinned to the window and scrolls on its own; the page scrolls
   beside it. (position: sticky cannot be used: the site sets overflow-x on
   <body>, which stops sticky elements following the window.) --course-nav-top
   is kept just under the site's navigation bar by course_nav.js. */
/* The page takes the width left beside the panel (never more than a comfortable
   reading width), so nothing runs off the right edge. */
.course-reader .course-main { width: auto; max-width: 1140px; margin-left: 280px; margin-right: 0; min-width: 0; }
.course-nav { position: fixed; left: 0; top: var(--course-nav-top, 56px); bottom: 0; width: 280px;
              overflow-y: auto; overscroll-behavior: contain;
              border-right: 1px solid #e3e6ea; background: #f8f9fa; font-size: .9rem; z-index: 1010; }
.course-reader.nav-collapsed .course-main { margin-left: auto; margin-right: auto; }
.course-nav-head { display: flex; align-items: center; gap: .5rem; padding: .75rem .75rem .5rem; position: sticky; top: 0;
                   background: #f8f9fa; border-bottom: 1px solid #e9ecef; z-index: 1; }
.course-nav-title { flex: 1; font-weight: 600; color: #212529; text-decoration: none; line-height: 1.25; }
.course-nav-title:hover { text-decoration: underline; }
.course-nav-btn { border: 1px solid #ced4da; background: #fff; border-radius: .3rem; padding: 0 .5rem; line-height: 1.6; cursor: pointer; }
.course-nav-btn:hover { background: #e9ecef; }
.course-nav-list, .course-nav-sections { list-style: none; margin: 0; padding: 0; }
.course-nav-list { padding: .4rem 0 .6rem; }
.course-nav-discussion { display: block; margin: 0 0 2rem; padding: .45rem .9rem; border-top: 1px solid #e3e6ea; color: #0d6efd; text-decoration: none; font-size: .9rem; }
.course-nav-discussion:hover { background: #eef1f4; }
/* ---- contents and index of a course ---- */
.course-contents { list-style: none; margin: .3rem 0 0; padding: 0 0 0 .2rem; font-size: .875rem; color: #6c757d; }
.course-contents .lvl3 { padding-left: 1.2rem; font-size: .8rem; }
.index-letters a { display: inline-block; min-width: 1.6rem; text-align: center; margin: 0 .15rem .3rem 0; padding: .1rem .3rem; border: 1px solid #dee2e6; border-radius: .3rem; text-decoration: none; }
.course-index { columns: 2 18rem; column-gap: 2.5rem; }
.course-index dl { margin: 0 0 1rem; }
.course-index dt { font-weight: 600; margin-top: .45rem; break-after: avoid; }
.course-index dd { margin: 0 0 0 1rem; font-size: .9rem; break-inside: avoid; }
.index-letter { border-bottom: 1px solid #dee2e6; padding-bottom: .15rem; break-after: avoid; }
.flow .block.needs-attention { box-shadow: 0 0 0 3px #dc3545; }
/* ---- index marks ---- */
/* In the editor a marked term is underlined with dots and shows its entry; a reader sees nothing. */
.flow .ql-editor span.ix { border-bottom: 2px dotted #6f42c1; cursor: help; }
.flow .ql-editor span.ix::after { content: " ⁱ " attr(data-ix); font-size: .7em; color: #6f42c1; vertical-align: super; }
.fmt-bar .ql-toolbar button.ql-index { width: auto; padding: 0 .4rem; font-size: .8rem; font-weight: 600; color: #444; }
.fmt-bar .ql-toolbar button.ql-index.ql-active { color: #6f42c1; }
.course-text span.ix.ix-found { background: #fff3cd; box-shadow: 0 0 0 3px #fff3cd; border-radius: .2rem; transition: background 2s; }
/* ---- discussion board ---- */
.post-body p { margin-bottom: .6rem; overflow-wrap: anywhere; }
.post-body p:last-child { margin-bottom: 0; }
.post-code { background: #f6f8fa; border: 1px solid #e3e6ea; border-radius: .4rem; padding: .5rem .75rem; font-size: .85rem; overflow-x: auto; margin-bottom: .6rem; }
.disc-removed { opacity: .6; background: #f8f9fa; }
.post-report > summary { list-style: none; padding: 0; text-decoration: none; }
.post-report > summary::-webkit-details-marker { display: none; }
.course-nav-list > li > a { display: flex; gap: .5rem; padding: .4rem .75rem; color: #343a40; text-decoration: none; border-left: 3px solid transparent; }
.course-nav-list > li > a:hover { background: #e9ecef; }
.course-nav-list > li.current > a { font-weight: 600; background: #e7f1ff; border-left-color: #0d6efd; color: #0a58ca; }
.course-nav-list > li.locked > a { color: #868e96; }
.course-nav-num { flex: 0 0 1.4em; text-align: right; color: #868e96; font-variant-numeric: tabular-nums; }
.course-nav-text { flex: 1; }
.course-nav-lock { font-size: .75em; }
.course-nav-sections { padding: .15rem 0 .4rem; }
.course-nav-sections a { display: block; padding: .22rem .75rem .22rem 2.9rem; color: #495057; text-decoration: none; font-size: .85rem;
                         border-left: 3px solid transparent; }
.course-nav-sections li.sub a { padding-left: 3.9rem; font-size: .8rem; }
.course-nav-sections a:hover { background: #e9ecef; }
.course-nav-sections li.active a { color: #0a58ca; border-left-color: #9ec5fe; background: #f1f6ff; font-weight: 600; }
.course-nav-open { display: none; position: fixed; left: 0; top: calc(var(--course-nav-top, 56px) + .75rem); z-index: 1020; border: 1px solid #ced4da; border-left: 0;
                   background: #fff; border-radius: 0 .4rem .4rem 0; padding: .35rem .6rem; font-size: .85rem; cursor: pointer;
                   box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.course-nav-open:hover { background: #e9ecef; }
.course-nav-backdrop { display: none; }
.course-anchor { scroll-margin-top: 1rem; }
.course-reader.nav-collapsed .course-nav { display: none; }
.course-reader.nav-collapsed .course-nav-open { display: block; }
@media (max-width: 991.98px) {
  /* a drawer over the page */
  .course-reader .course-main { margin-left: auto; margin-right: auto; max-width: 100%; }
  .course-nav { top: 0; z-index: 1045; width: min(86vw, 320px); box-shadow: 0 0 24px rgba(0,0,0,.25);
                transform: translateX(-100%); transition: transform .18s ease; display: block !important; }
  .course-reader.nav-open .course-nav { transform: none; }
  .course-reader.nav-open .course-nav-backdrop { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(0,0,0,.35); }
  .course-nav-open { display: block; top: auto; bottom: 1rem; border-left: 1px solid #ced4da; left: .75rem; border-radius: 2rem; padding: .45rem .9rem; }
  .course-reader.nav-open .course-nav-open { display: none; }
}
@media print { .course-nav, .course-nav-open { display: none !important; } }

/* ---- automatic numbering (course_nav.js) ---- */
.course-text h2 .course-num, .course-text h3 .course-num { color: #6c757d; font-weight: 400; }
.course-nav-sections .course-num { color: #868e96; font-variant-numeric: tabular-nums; }
.course-text table caption { caption-side: top; text-align: left; padding: 0 0 .35rem; color: #6c757d; font-size: .875rem; }
.course-text figure, .course-fig { margin: 1rem 0; }
.course-text figure figcaption, .course-fig figcaption { margin-top: .35rem; }
figcaption .course-num, caption .course-num { color: #343a40; }

/* ---- chapter editor: one flowing page (chapter_editor.js) ---- */
/* The workspace fills the window under the site's navigation bar. Nothing
   above the page scrolls: the page has its own scrollbar (.ed-scroll), so the
   save buttons, the formatting bar and the tools are always in reach.
   (position: sticky is not an option here; see the note on .course-nav.) */
html.ed-root { overflow: hidden; }
body.ed-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.ed-page > nav.navbar { flex: 0 0 auto; }
.ed-shell { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; background: #e9ecef; }

/* top bar: tools toggle, chapter name (opens the details), save / cancel */
.ed-bar { flex: 0 0 auto; display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; background: #fff; border-bottom: 1px solid #dee2e6; }
.ed-icon-btn { flex: 0 0 auto; width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center;
               border: 1px solid #ced4da; border-radius: .4rem; background: #fff; color: #343a40; padding: 0; }
.ed-icon-btn:hover { background: #e9ecef; }
.ed-icon-btn svg { width: 1.25rem; height: 1.25rem; }
.ed-shell:not(.strip-closed) .ed-icon-btn { background: #e7f1ff; border-color: #9ec5fe; color: #0a58ca; }
.ed-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: .5rem; border: 0; background: transparent;
            text-align: left; padding: .3rem .5rem; border-radius: .4rem; color: #212529; }
.ed-title:hover { background: #f1f3f5; }
.ed-title-num { flex: 0 0 auto; color: #6c757d; font-size: .85rem; white-space: nowrap; }
.ed-title-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-title-text.is-missing { font-weight: 400; color: #b02a37; }
.ed-caret { flex: 0 0 auto; color: #6c757d; transition: transform .15s; }
.ed-shell:not(.details-closed) .ed-caret { transform: rotate(180deg); }
.ed-unsaved { flex: 0 0 auto; font-size: .8rem; color: #b45309; white-space: nowrap; }
.ed-actions { flex: 0 0 auto; display: flex; gap: .4rem; }

/* chapter name, free preview, co-authors, AI draft: collapsed while writing */
.ed-details { flex: 0 0 auto; max-height: 60vh; overflow-y: auto; padding: .75rem 1rem; background: #fff; border-bottom: 1px solid #dee2e6; }
.ed-shell.details-closed .ed-details { display: none; }

/* formatting bar: belongs to the text that has the cursor */
.fmt-bar { flex: 0 0 auto; position: relative; z-index: 30; min-height: 2.6rem; background: #f8f9fa; border-bottom: 1px solid #ced4da; }
.fmt-bar .ql-toolbar.ql-snow { border: 0; padding: .3rem .5rem; }
.fmt-bar:not(.has-bar)::before { content: "Click in the text to format it"; display: block; padding: .6rem .75rem; color: #868e96; font-size: .875rem; }

/* tools: a narrow strip of icons, as in a drawing program; names are in the tooltips */
.ed-body { flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; position: relative; }
.ed-strip { flex: 0 0 3.25rem; display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .5rem 0;
            background: #2b3035; overflow-y: auto; }
.ed-shell.strip-closed .ed-strip { display: none; }
.ed-strip .tool { width: 2.5rem; height: 2.5rem; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 0;
                  border: 1px solid transparent; border-radius: .45rem; background: transparent; color: #dee2e6; cursor: pointer; }
.ed-strip .tool:hover, .ed-strip .tool:focus-visible { background: #495057; border-color: #6c757d; color: #fff; }
.ed-strip .tool:active { cursor: grabbing; }
.ed-strip .tool svg { width: 1.5rem; height: 1.5rem; pointer-events: none; }

/* the chapter page */
/* position: relative keeps absolutely placed pieces inside the chapter (an equation's hidden
   MathML, for one) scrolling with it; otherwise they stretch the window's own scroll height
   and the browser can slide the whole workspace up when the cursor is placed. */
.ed-scroll { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: 1rem; position: relative; }
.ed-message { max-width: 62rem; margin: 0 auto .75rem; }
.editor-canvas.flow { max-width: 62rem; min-height: calc(100% - .25rem); margin: 0 auto; padding: 1.5rem 2rem 4rem; background: #fff;
                      border: 1px solid #dee2e6; border-radius: .35rem; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.editor-canvas.flow.drag-over { border-color: #0d6efd; background: #f8fbff; }
.ed-switch { white-space: nowrap; color: #495057; }
/* narrow windows: the second save button keeps its name for screen readers and shows a short label */
@media (max-width: 767.98px) {
  .ed-actions .ed-save-add { font-size: 0; }
  .ed-actions .ed-save-add::after { content: "Save +"; font-size: .875rem; }
}
@media (max-width: 575.98px) {
  .ed-scroll { padding: .4rem; }
  .editor-canvas.flow { padding: 1rem .8rem 4rem; }
  .ed-strip { flex-basis: 2.9rem; }
  .ed-unsaved, .ed-title-num { display: none; }      /* room for the chapter's name */
  .ed-bar { gap: .35rem; padding: .35rem .4rem; }
  .ed-actions .ed-save { font-size: 0; }
  .ed-actions .ed-save::after { content: "Save"; font-size: .875rem; }
  .block-head { flex-wrap: wrap; }
  .block-head .ed-switch { order: 5; flex-basis: 100%; margin: .15rem 0 0 1.4rem; }   /* its own line under the card's name */
  .block-head.has-tools .block-type { flex: 1 1 auto; }
  .block-head .block-tools { order: 5; flex-basis: 100%; }                               /* and so do a tool's controls */
}
/* text: no frame, no header, grows with what is written */
.flow .block.seg { border: 0; background: transparent; margin: 0; }
.flow .block.seg > .block-body { padding: 0; }
.flow .seg .quill-host { min-height: 0; }
.flow .seg .ql-container.ql-snow { border: 0; font-size: 1rem; font-family: inherit; }
.flow .seg .ql-editor { min-height: 1.6rem; padding: .15rem 0; line-height: 1.6; overflow: visible; }
.flow .seg .ql-editor.ql-blank::before { left: 0; right: 0; font-style: normal; color: #adb5bd; }
.flow .seg .ql-editor h2, .flow .seg .ql-editor h3, .flow .seg .ql-editor h4 { margin-top: 1.2rem; }
.flow .seg .ql-editor p { margin-bottom: .8rem; }
/* an empty gap between two tools stays out of the way until wanted */
.flow .seg.is-empty:not(.is-active) .ql-editor.ql-blank::before { content: ""; }
.flow .seg.is-empty:not(.is-active):hover .ql-editor.ql-blank::before { content: "Write here…"; }
.flow .seg.is-empty:not(.is-active) .ql-editor { min-height: .9rem; padding: 0; }
.flow .seg.is-empty:first-child .ql-editor.ql-blank::before, .flow .seg.is-empty:last-child .ql-editor.ql-blank::before { content: "Write here…"; }
.flow .seg.is-empty:last-child .ql-editor { min-height: 6rem; }
/* tools are cards set into the page */
.flow .block.tool-card { margin: .9rem 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.flow .tool-card .html-preview { background: #fff; overflow-x: auto; }

/* ---- table grid in a card (table_editor.js) ---- */
.tbl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-bottom: .5rem; }
.tbl-group { display: inline-flex; align-items: center; gap: .35rem; }
.tbl-group-name { font-size: .8rem; color: #6c757d; }
.tbl-bar .btn { --bs-btn-padding-y: .1rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .8rem; white-space: nowrap; }
.tbl-bar .tbl-del { color: #dc3545; }
.tbl-bar .tbl-del:hover { color: #fff; background: #dc3545; border-color: #dc3545; }
.tbl-switch { white-space: nowrap; color: #495057; }
.tbl-caption { max-width: 34rem; }
.tbl-wrap table.tbl-grid { margin: .5rem 0 .25rem; }
.tbl-grid th, .tbl-grid td { min-width: 3.5rem; height: 2.15rem; outline: none; cursor: text; }
.tbl-grid th:focus, .tbl-grid td:focus { box-shadow: inset 0 0 0 2px #0d6efd; }
.tbl-grid thead th { caret-color: #fff; }
/* ---- drawing canvas in a card (draw.js) ---- */
.drw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-bottom: .5rem; }
.drw-group { display: inline-flex; align-items: center; gap: .35rem; }
.drw-btn { --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .35rem; line-height: 0; }
.drw-btn svg { display: block; }
.drw-btn.active { background: #0d6efd; border-color: #0d6efd; color: #fff; }
.drw-btn.drw-del:not(:disabled) { color: #dc3545; }
.drw-pick { position: relative; display: inline-block; }
.drw-colour { --bs-btn-padding-y: .12rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .8rem; display: inline-flex; align-items: center; gap: .35rem; }
.drw-chip { display: inline-block; width: 1rem; height: 1rem; border: 1px solid #868e96; border-radius: .2rem; background: #fff; }
.drw-none { background: linear-gradient(to top right, #fff 45%, #dc3545 46%, #dc3545 54%, #fff 55%) !important; }
.drw-palette { position: absolute; z-index: 35; top: calc(100% + .25rem); left: 0; display: grid; grid-template-columns: repeat(8, 1.45rem); gap: .25rem;
               padding: .45rem; background: #fff; border: 1px solid #ced4da; border-radius: .4rem; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.drw-palette[hidden] { display: none; }
.drw-swatch { width: 1.45rem; height: 1.45rem; padding: 0; border: 1px solid #868e96; border-radius: .25rem; cursor: pointer; }
.drw-swatch:hover { outline: 2px solid #0d6efd; outline-offset: 1px; }
.drw-any { width: 1.45rem; height: 1.45rem; padding: 0; border: 1px solid #868e96; border-radius: .25rem; background: none; cursor: pointer; }
.drw-select { width: auto; --bs-form-select-bg-img: none; padding: .12rem .5rem; font-size: .8rem; background-image: none; }
.drw-check { display: inline-flex; align-items: center; gap: .3rem; padding-left: 0; white-space: nowrap; color: #495057; }
.drw-check .form-check-input { float: none; margin: 0; }
.drw-label { font-size: .8rem; color: #6c757d; }
.drw-dim { width: 4.6rem; padding: .12rem .4rem; font-size: .8rem; }
.drw-stage { position: relative; overflow: auto; border: 1px solid #ced4da; border-radius: .4rem; background: #eef0f3; padding: .5rem; }
.drw-svg { display: block; margin: 0 auto; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); touch-action: none; user-select: none; outline: none; }
.drw-svg:focus-visible { box-shadow: 0 0 0 2px #86b7fe; }
.drw-svg .drw-grid { pointer-events: none; }
.drw-svg .drw-handle { cursor: pointer; }
.drw-svg text { cursor: inherit; }
.drw-text-edit { position: absolute; z-index: 5; padding: .1rem .35rem; border: 2px solid #0d6efd; border-radius: .25rem; background: #fff; font-family: inherit; }
.drw-caption { max-width: 34rem; margin-top: .5rem; }
/* a typed diagram's preview in its card */
.drawn-preview { background: #fff; overflow-x: auto; min-height: 3.5rem; }
/* a note over the page for something the editor will not do (a pasted picture) */
.ed-toast { position: absolute; top: .75rem; left: 50%; transform: translateX(-50%); z-index: 40;
            width: max-content; max-width: min(36rem, 92%); margin: 0; font-size: .875rem; }
