/* WASecret Docs: layout on top of the shared Bloom theme (../shared/theme.css). */
:root { --pw: 210mm; --ph: 297mm; --m: 25.4mm; --doc-font: "AD Calibri", Calibri, Carlito, sans-serif; --doc-size: 11pt; --mono: "AD Mono", "Courier New", monospace; --urdu: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", "Segoe UI", Tahoma, serif; }
html, body { overflow: hidden; }
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar { flex-wrap: nowrap; gap: 8px; }
.brand-text b { color: var(--accent); font-weight: 750; }
.title-input { min-width: 120px; width: 260px; max-width: 32vw; padding: 6px 10px; font-weight: 600; border-color: transparent; background: transparent; }
.title-input:hover, .title-input:focus { border-color: #d9dcea; background: #fff; }
.save-state { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.save-state.err { color: #c2410c; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 210px; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.menu button { display: flex; justify-content: space-between; gap: 16px; align-items: center; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; font: inherit; cursor: pointer; color: var(--fg); }
.menu button span { color: var(--muted); font-size: 12px; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.show-sm { display: none; }

/* ---------- formatting toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 12px; background: var(--bar); border-bottom: 1px solid var(--line); position: relative; z-index: 15; }
.tgroup { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
.tgroup:last-child { border-right: 0; }
.tb { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 32px; height: 32px; padding: 0 7px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--fg); font: 600 13px/1 system-ui, sans-serif; cursor: pointer; white-space: nowrap; transition: background .12s; }
.tb:hover { background: var(--hover); }
.tb.on { background: #efedff; border-color: #cfc9ff; color: var(--accent); }
.tb:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
.tb svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.tb svg circle, .tb svg text { fill: currentColor; stroke: none; }
.tb.color { position: relative; }
.tb.color input { position: absolute; inset: auto 3px 2px 3px; width: calc(100% - 6px); height: 5px; padding: 0; border: 0; opacity: 1; cursor: pointer; -webkit-appearance: none; appearance: none; background: none; }
.tb.color input::-webkit-color-swatch-wrapper { padding: 0; }
.tb.color input::-webkit-color-swatch { border: 0; border-radius: 2px; }
.swatch-a { font-weight: 800; transform: translateY(-2px); }
.swatch-h { transform: translateY(-2px); }
.tsel { height: 32px; border: 1px solid #d9dcea; border-radius: 8px; background: #fff; font: 13px system-ui, sans-serif; padding: 0 6px; max-width: 150px; color: var(--fg); }
.tsel.narrow { max-width: 84px; }

.ctxbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; background: #f8f7ff; border-bottom: 1px solid var(--line); font-size: 13px; position: relative; z-index: 14; }
.ctxbar .btn { padding: 5px 10px; font-size: 13px; }
.ctx-label { font-weight: 700; color: var(--accent); margin-right: 4px; }
.range { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- workspace ---------- */
.workspace { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.viewer { flex: 1 1 auto; overflow: auto; position: relative; padding: 28px 20px 60px; }
.paper-wrap { width: max-content; min-width: 100%; display: flex; justify-content: center; }
.paper { position: relative; width: var(--pw); min-height: var(--ph); padding: var(--m); background-color: #fff; box-shadow: 0 1px 3px rgba(27, 33, 51, .1), 0 10px 30px rgba(27, 33, 51, .08); border-radius: 4px;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--ph) - 1px), #d9dcea calc(var(--ph) - 1px), #d9dcea var(--ph)); }
.page-head, .page-foot { position: absolute; left: var(--m); right: var(--m); text-align: center; color: #8a93a8; font: 9pt/1.2 var(--doc-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.page-head { top: calc(var(--m) / 2 - 6pt); }
.page-foot { bottom: calc(var(--m) / 2 - 6pt); }

/* ---------- the document ---------- */
.editor { font-family: var(--doc-font); font-size: var(--doc-size); line-height: 1.5; color: #1b2133; outline: none; min-height: 60mm; caret-color: var(--accent); overflow-wrap: break-word; }
.editor > :first-child { margin-top: 0; }
.editor p { margin: 0 0 6pt; }
.editor h1 { font-size: 22pt; line-height: 1.25; margin: 14pt 0 6pt; }
.editor h2 { font-size: 17pt; line-height: 1.25; margin: 12pt 0 5pt; }
.editor h3 { font-size: 14pt; line-height: 1.3; margin: 9pt 0 5pt; }
.editor blockquote { margin: 8pt 0; padding: 2pt 0 2pt 14pt; border-left: 4px solid #b4b0f5; color: #475569; font-style: italic; }
.editor blockquote p { margin: 0 0 4pt; }
.editor pre { background: #f1f5f9; padding: 8px 10px; border-radius: 6px; font-family: var(--mono); font-size: .9em; white-space: pre-wrap; margin: 4pt 0 8pt; }
.editor code { font-family: var(--mono); font-size: .92em; background: #f1f5f9; padding: 0 3px; border-radius: 3px; }
.editor pre code { background: none; padding: 0; }
.editor ul, .editor ol { margin: 0 0 6pt; padding-left: 24pt; }
.editor li { margin: 0 0 2pt; }
.editor ul ul, .editor ul ol, .editor ol ul, .editor ol ol { margin: 2pt 0; }
.editor ol ol, .editor ul ol { list-style-type: lower-alpha; }
.editor ol ol ol, .editor ul ol ol, .editor ol ul ol { list-style-type: lower-roman; }
.editor ul ul { list-style-type: circle; }
.editor ul ul ul { list-style-type: square; }
.editor ul.check { list-style: none; padding-left: 26pt; }
.editor ul.check > li { position: relative; }
.editor ul.check > li::before { content: ""; position: absolute; left: -20pt; top: .3em; width: 11pt; height: 11pt; border: 1.6px solid var(--accent); border-radius: 3px; background: #fff center / 80% no-repeat; cursor: pointer; }
.editor ul.check > li[data-checked="true"]::before { background-color: var(--accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.editor ul.check > li[data-checked="true"] { color: #8a93a8; text-decoration: line-through; }
.editor [dir="rtl"] ul.check > li::before, .editor ul.check > li[dir="rtl"]::before { left: auto; right: -20pt; }
.editor table { border-collapse: collapse; width: 100%; table-layout: fixed; margin: 6pt 0 10pt; }
.editor td, .editor th { border: 1px solid #94a3b8; padding: 4px 6px; vertical-align: top; text-align: left; min-width: 30px; }
.editor th { background: #efedff; font-weight: 700; }
.editor td:focus-within, .editor th:focus-within { box-shadow: inset 0 0 0 2px rgba(91, 76, 240, .25); }
.editor hr { border: 0; border-top: 1px solid #c7cbe0; margin: 10pt 0; }
.editor .pb { position: relative; height: 0; margin: 18pt 0; border-top: 2px dashed #b4b0f5; user-select: none; }
.editor .pb::after { content: "Page break"; position: absolute; left: 50%; top: -9px; transform: translateX(-50%); background: #fff; color: var(--accent); font: 600 11px/18px system-ui, sans-serif; padding: 0 8px; border-radius: 9px; }
.editor img { max-width: 100%; height: auto; vertical-align: bottom; border-radius: 2px; }
.editor img.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.editor .imgp { margin: 6pt 0; }
.editor a { color: #0563c1; }
.editor [dir="rtl"] { font-family: var(--doc-font), var(--urdu); }
.editor.is-empty > p:first-child { position: relative; }
.editor.is-empty > p:first-child::before { content: "Start typing, or pick a template…"; color: #a3abbd; pointer-events: none; position: absolute; left: 0; top: 0; white-space: nowrap; }
::highlight(ad-find) { background: #fde68a; }
::highlight(ad-find-cur) { background: #f59e0b; color: #fff; }

.img-handle { position: absolute; width: 14px; height: 14px; border-radius: 4px; background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: nwse-resize; z-index: 5; touch-action: none; }

/* ---------- side panel ---------- */
.side { width: 340px; flex: none; margin: 12px 12px 12px 0; overflow: auto; position: relative; border-radius: 16px; animation: slidein .2s var(--ease); }
.side h2 { font-size: 17px; margin: 2px 34px 12px 0; }
.side h3 { font-size: 14px; margin: 16px 0 8px; }
.side-close { position: absolute; top: 10px; right: 10px; padding: 4px 9px; }
.panel-sec { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field .ad-input { font-weight: 400; color: var(--fg); width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.hint { margin: 0; padding: 8px 10px; background: #f6f5ff; border-radius: 10px; font-size: 13px; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-result { border: 1px solid #d9d4ff; border-radius: 12px; padding: 10px; background: #fbfaff; }
.ai-label { margin: 0 0 6px; font: 700 12px/1 system-ui, sans-serif; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.ai-text { white-space: pre-wrap; font-size: 14px; max-height: 240px; overflow: auto; margin-bottom: 8px; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-msg { padding: 10px 12px; border-radius: 10px; background: #fff7ed; color: #9a3412; font-size: 13.5px; }
.ai-msg.ok { background: #ecfdf5; color: #047857; }
.ai-msg.busy { background: #f1f2f8; color: var(--muted); }
.soon-box:empty { display: none; }
.soon-box .ad-soon { padding: 18px 14px; }
.outline-list { display: flex; flex-direction: column; gap: 2px; }
.outline-list button { text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--fg); }
.outline-list button:hover { background: var(--hover); }
.outline-list .l2 { padding-left: 22px; } .outline-list .l3 { padding-left: 36px; font-size: 13px; color: var(--muted); }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.recent-list li { display: flex; align-items: center; gap: 6px; }
.recent-list .open { flex: 1; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; color: var(--fg); min-width: 0; }
.recent-list .open:hover { border-color: #cfc9ff; background: #f8f7ff; }
.recent-list .open.cur { border-color: var(--accent); }
.recent-list .name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-list .when { display: block; font-size: 12px; color: var(--muted); }

/* ---------- status, popovers, dialog ---------- */
.status { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--bar); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.popover { position: fixed; z-index: 70; width: 320px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; gap: 10px; }
.dlg { padding: 18px; width: 760px; max-width: calc(100vw - 32px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 19px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-top: 12px; max-height: 64vh; overflow: auto; padding: 2px; }
.tpl { display: flex; flex-direction: column; gap: 6px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 10px; cursor: pointer; font: inherit; color: var(--fg); transition: border-color .15s, transform .15s var(--ease); }
.tpl:hover, .tpl:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.tpl-thumb { height: 110px; border-radius: 8px; background: #f6f6fb; border: 1px solid #eceef6; padding: 10px; overflow: hidden; font-size: 5.5px; line-height: 1.4; color: #4b5563; }
.tpl-thumb .t1 { font-size: 10px; font-weight: 800; color: #1b2133; margin-bottom: 4px; }
.tpl-thumb .t2 { font-size: 7px; font-weight: 700; color: #1b2133; margin: 4px 0 2px; }
.tpl-thumb .ln { height: 3px; background: #dfe2ee; border-radius: 2px; margin: 3px 0; }
.tpl b { font-size: 14px; }
.tpl span { font-size: 12.5px; color: var(--muted); }
.ad-toast { animation: toast .25s var(--ease); }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- phones: tools in a bottom bar, panels as bottom sheets, paper fills the width ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand-text { display: none; }
  .ad-brand-mark { width: 32px; height: 32px; }
  .title-input { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; }
  .save-state, .hide-sm { display: none !important; }
  .show-sm { display: block; }
  #magicBtn { padding: 7px 10px; }
  #downloadBtn, #moreBtn { padding: 7px 10px; }
  .toolbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; background: rgba(255, 255, 255, .97); backdrop-filter: blur(12px); border-top: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -6px 20px rgba(27, 33, 51, .08); padding: 7px 8px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  .toolbar::-webkit-scrollbar { display: none; }
  .tgroup { flex: none; }
  .tb { height: 36px; min-width: 36px; }
  .tsel { height: 36px; }
  .ctxbar { position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); z-index: 39; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; }
  .ctxbar > * { flex: none; }
  .viewer { padding: 10px 8px 130px; }
  .paper-wrap { width: 100%; min-width: 0; zoom: 1 !important; }
  .paper { width: 100%; min-height: 60vh; padding: 18px 16px; background-image: none; border-radius: 10px; }
  .page-head, .page-foot { display: none; }
  .status { display: none; }
  .side { position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); width: auto; max-height: 68vh; margin: 0; z-index: 45; border-radius: 18px 18px 0 0; box-shadow: 0 -12px 30px rgba(27, 33, 51, .18); animation: rise .22s var(--ease); }
  .menu { right: 0; max-width: calc(100vw - 20px); }
  .popover { left: 12px !important; right: 12px; top: auto !important; bottom: calc(70px + env(safe-area-inset-bottom)); width: auto; }
  .ad-toast { bottom: 80px; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- print: just the pages, with header, footer and page numbers from @page rules ---------- */
@media print {
  html, body { overflow: visible; height: auto; display: block; background: #fff; }
  .topbar, .toolbar, .ctxbar, .side, .status, .img-handle, .ad-toast, .popover, dialog { display: none !important; }
  .workspace, .viewer { display: block; overflow: visible; padding: 0; }
  .paper-wrap { display: block; width: auto; zoom: 1 !important; }
  .paper { width: auto; min-height: 0; padding: 0; box-shadow: none; background-image: none; border-radius: 0; }
  .page-head, .page-foot { display: none; }
  .editor .pb { break-after: page; border: 0; margin: 0; }
  .editor .pb::after { display: none; }
  .editor h1, .editor h2, .editor h3 { break-after: avoid; }
  .editor tr, .editor img { break-inside: avoid; }
}

/* ================= Canva-like frame (CANVA-FLOW) ================= */
.doc-stage { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
body.shelled .topbar, body.shelled .status { display: none !important; }
body.shelled .doc-stage { height: 100%; }
body.shelled .workspace { background: transparent; }
body.shelled .viewer { padding: 22px 20px 70px 56px; }

/* context toolbar: one white pill */
.toolbar { flex-wrap: wrap; justify-content: center; gap: 2px 4px; background: #fff; border: 1px solid #e6e8f0; border-radius: 14px; box-shadow: 0 4px 18px rgba(27, 33, 51, .1); padding: 5px 8px; margin: 8px auto; width: max-content; max-width: calc(100% - 16px); }
body.shelled .toolbar { margin: 0 auto; }
.tgroup { border-right: 0; padding-right: 2px; margin-right: 0; gap: 1px; }
.tgroup + .tgroup { border-left: 1px solid #eceef5; padding-left: 4px; }
.tb.magic { background: linear-gradient(90deg, #5b4cf0, #8b5cf6); color: #fff; border-radius: 10px; margin-left: 4px; }
.tb.magic:hover { filter: brightness(1.08); background: linear-gradient(90deg, #5b4cf0, #8b5cf6); }
.dot-swatch { width: 20px; height: 20px; border-radius: 50%; background: #1b2133; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px #c9cde0; display: inline-block; }
.tsel.htype { font-weight: 700; width: 74px; }
.size-group .tsel { width: 56px; text-align: center; }
.tb[disabled] { opacity: .4; cursor: default; }

/* toolbar popovers */
.tpop { position: fixed; z-index: 80; width: 264px; max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; border-radius: 14px; }
.pop-h { margin: 2px 0 0; font: 700 12px/1.2 system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #d5d8e5; cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.12); }
.swatch.none { background: linear-gradient(135deg, #fff 45%, #ef4444 46%, #ef4444 54%, #fff 55%); }
.pop-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg); }
.pop-row input[type="color"] { width: 40px; height: 26px; border: 1px solid #d5d8e5; border-radius: 6px; padding: 1px; background: #fff; }
.pop-row input[type="range"] { flex: 1; }
.pop-list { display: flex; flex-direction: column; gap: 2px; }
.pop-list.row { flex-direction: row; flex-wrap: wrap; gap: 4px; }
.pop-list button { border: 1px solid transparent; background: none; text-align: left; padding: 8px 10px; border-radius: 9px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--fg); }
.pop-list.row button { border-color: #e1e4ee; padding: 6px 10px; }
.pop-list button:hover { background: var(--hover); }
.pop-list .tb.wide { justify-content: flex-start; width: 100%; font-weight: 500; }
.pop-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.deco-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.deco-btn { height: 44px; border: 1px solid #e1e4ee; border-radius: 9px; background: #f6f6fb; cursor: pointer; padding: 4px; font-size: 16px; color: var(--muted); }
.deco-btn img { width: 100%; height: 100%; object-fit: contain; }
.deco-btn:hover { border-color: var(--accent); }
.ms-pop { width: 300px; }

/* blocks: hover handle, selection box, action pill */
.blk-handle { position: absolute; z-index: 6; width: 26px; height: 32px; border: 1px solid #e1e4ee; border-radius: 9px; background: #fff; color: #6a7389; box-shadow: 0 2px 8px rgba(27, 33, 51, .12); font: 700 14px/1 system-ui, sans-serif; letter-spacing: -3px; cursor: grab; touch-action: none; display: flex; align-items: center; justify-content: center; padding: 0 3px 0 0; }
.blk-handle:active { cursor: grabbing; }
.blk-handle.on { color: var(--accent); border-color: #cfc9ff; }
.drop-line { position: absolute; z-index: 6; height: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 2px rgba(91, 76, 240, .2); pointer-events: none; }
.sel-box { position: absolute; z-index: 3; border: 2px solid #8b5cf6; border-radius: 4px; pointer-events: none; }
.blk-pill { position: absolute; z-index: 7; display: flex; gap: 2px; padding: 4px; background: #fff; border-radius: 999px; box-shadow: 0 4px 16px rgba(27, 33, 51, .18); }
.blk-pill button { width: 34px; height: 30px; border: 0; border-radius: 999px; background: none; cursor: pointer; color: #1b2133; font: 700 16px/1 system-ui, sans-serif; display: flex; align-items: center; justify-content: center; }
.blk-pill button:hover { background: var(--hover); }
.blk-pill svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.blk-menu { position: absolute; z-index: 8; width: 200px; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.blk-menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--fg); }
.blk-menu button:hover { background: var(--hover); }
.blk-menu button[disabled] { opacity: .45; cursor: default; }
.blk-comment { position: absolute; z-index: 8; width: 280px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
body[data-mode="view"] .blk-handle, body[data-mode="view"] .blk-pill { display: none !important; }

/* coloured blocks and table styles in the page */
.editor .band { border-radius: 2px; margin: 10pt 0 8pt; display: flow-root; }
.editor h1.band { margin-top: 0; }
.editor > [data-cmt] { box-shadow: -4px 0 0 #ffd166; }
.editor > [data-cmt]::after { content: "💬"; position: absolute; margin-left: 6px; font-size: 13px; }
.editor table.t-lines td, .editor table.t-lines th { border: 0; border-bottom: 1px dotted #94a3b8; padding: 7px 8px; }
.editor table.t-lines th { background: transparent; }
/* columns and sidebars: no lines in the page or the PDF; a faint outline only while editing */
.editor table.t-cols { table-layout: fixed; }
.editor table.t-cols td, .editor table.t-cols th { border: 0; padding: 4px 10px; vertical-align: top; background: transparent; outline: 1px dashed transparent; outline-offset: -1px; }
.editor table.t-cols:hover td, .editor table.t-cols:focus-within td { outline-color: #cbd5e1; }
/* "Set as full page" picture: as wide as the page */
.editor p.img-full img { width: 100% !important; max-width: 100%; height: auto; }
.editor p.img-full { box-shadow: 0 0 0 2px #5b4cf033; }
/* dropdown editor, small insert forms, spacing sliders, divider style */
.dd-editor { position: absolute; z-index: 9; width: 320px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.dd-opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.dd-opts li { display: grid; grid-template-columns: 78px 1fr 28px 28px 28px; gap: 4px; align-items: center; }
.dd-opts .tb { width: 28px; height: 30px; padding: 0; }
.chip-edit { border-top: 1px solid var(--line, #e2e8f0) !important; margin-top: 4px; color: var(--accent, #5b4cf0) !important; }
.mini-form { display: flex; flex-direction: column; gap: 8px; padding: 6px; }
.mini-form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.mini-form input[type="number"] { width: 72px; }
.mini-form .chk { justify-content: flex-start; }
.range-row { display: grid; grid-template-columns: 1fr 64px; gap: 8px; align-items: center; }
.range-row .num { width: 64px; padding: 4px 6px; }
.blk-hr { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line, #e2e8f0); margin-top: 4px; padding-top: 6px; }
.blk-hr .pop-list.row { display: flex; gap: 4px; flex-wrap: wrap; }
.blk-hr .pop-list button { width: 30px; height: 30px; padding: 0; text-align: center; }
.dp-cols { display: flex; gap: 3px; width: 100%; height: 34px; }
.dp-cols i { display: block; background: #e0e7ff; border: 1px solid #a5b4fc; border-radius: 3px; }
.publish-dlg { width: min(520px, calc(100vw - 32px)); padding: 20px; border: 0; border-radius: 14px; }
.publish-dlg::backdrop { background: #0f172a66; }
.publish-form { display: flex; flex-direction: column; gap: 12px; }
.publish-form h2 { margin: 0; font-size: 20px; }
.publish-form .field { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.publish-form .chk { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.blk-hr .sw { border: 1px solid #0002 !important; border-radius: 50% !important; width: 22px !important; height: 22px !important; }
.editor .imgp img[src^="data:image/svg"] { border-radius: 0; }
.paper.digital { width: 240mm; background-image: none; }

/* side panels rendered by Docs (Elements, Text, Tools) */
.docs-panel { display: flex; flex-direction: column; gap: 6px; }
.dp-h { font-size: 14px; margin: 12px 0 4px; color: var(--fg); }
.dp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dp-grid.one { grid-template-columns: 1fr; }
.dp-grid.emoji { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dp-tile { border: 1px solid #e3e6ef; background: #f7f7fb; border-radius: 10px; padding: 6px; min-height: 64px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: inherit; color: var(--fg); overflow: hidden; }
.dp-tile:hover, .dp-tile:focus-visible { border-color: var(--accent); background: #fff; outline: none; }
.dp-tile.wide { grid-column: 1 / -1; align-items: stretch; min-height: 0; padding: 8px 10px; }
.dp-tile img { max-width: 100%; max-height: 54px; object-fit: contain; }
.dp-tile small { font-size: 11px; color: var(--muted); }
.dp-pal { display: flex; gap: 0; width: 100%; height: 28px; border-radius: 8px; overflow: hidden; }
.dp-pal i { flex: 1; }
.dp-line { display: block; width: 80%; height: 2px; background: #5b4cf0; }
.dp-table { display: grid; grid-template-columns: repeat(var(--c), 1fr); gap: 2px; width: 70%; }
.dp-table i { height: 8px; background: #d9dcea; border-radius: 1px; }
.dp-table i:nth-child(-n + 4) { background: var(--a, #b4b0f5); }
.dp-txt { font-size: 11px; line-height: 1.4; text-align: left; }
.dp-emoji { font-size: 22px; }
.dp-band { display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 0 0 12px; border-radius: 4px; font-weight: 700; font-size: 14px; }
.dp-band img { height: 34px; max-width: 46%; }
.t-h1 { font-size: 24px; font-weight: 800; text-align: left; }
.t-h2 { font-size: 18px; font-weight: 700; text-align: left; }
.t-h3 { font-size: 15px; font-weight: 700; text-align: left; }
.t-p { font-size: 13px; text-align: left; }
.t-q { font-size: 14px; font-style: italic; border-left: 3px solid #b4b0f5; padding-left: 8px; text-align: left; }
.t-band { display: block; background: #a7e8c5; color: #1d3a30; padding: 6px 10px; border-radius: 4px; font-weight: 700; text-align: left; }
.t-pair { display: flex; flex-direction: column; text-align: left; gap: 2px; }
.t-pair b { font-size: 16px; }
.t-pair span { font-size: 12px; color: var(--muted); }
.dp-tool { text-align: left; font-weight: 600; font-size: 13.5px; }
.dp-color { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.dp-color input { width: 44px; height: 28px; border: 1px solid #d5d8e5; border-radius: 6px; padding: 1px; background: #fff; }
.dp-count { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-count div { background: #f6f5ff; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.dp-count b { font-size: 18px; }
.dp-count span { font-size: 12px; color: var(--muted); }
.docs-outline { display: flex; flex-direction: column; gap: 2px; min-width: 220px; max-height: 50vh; overflow: auto; }
.docs-outline .ol-item { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-outline .ol-item:hover { background: var(--hover); }
.docs-outline .l2 { padding-left: 22px; } .docs-outline .l3 { padding-left: 36px; color: var(--muted); }

@media (max-width: 760px) {
  body.shelled .toolbar { position: relative; left: auto; right: auto; bottom: auto; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; width: auto; max-width: calc(100vw - 16px); box-shadow: 0 2px 10px rgba(27, 33, 51, .1); border-radius: 12px; padding-bottom: 5px; }
  body.shelled .viewer { padding: 10px 8px 90px 34px; }
  body.shelled .ctxbar { bottom: auto; position: relative; }
  .blk-handle { width: 24px; }
  .tpop { left: 8px !important; right: 8px; width: auto; }
}
@media print { .blk-handle, .blk-pill, .blk-menu, .blk-comment, .sel-box, .drop-line, .tpop { display: none !important; } .editor > [data-cmt]::after { display: none; } .editor > [data-cmt] { box-shadow: none; } }
/* inside the shell's floating pill: the pill is the frame's, so the toolbar itself is flat */
body.shelled .toolbar { background: none; border: 0; box-shadow: none; margin: 0; padding: 0; flex-wrap: nowrap; width: auto; max-width: none; }
body.shelled .ad-toast, .ad-toast { z-index: 1200; }
@media (max-width: 759.98px) {
  body.shelled .side { position: absolute; left: 0; right: 0; bottom: 0; max-height: 70%; }
  body.shelled .ctxbar { position: relative; bottom: auto; border-radius: 0; }
}
/* a coloured header block at the very top of the page bleeds to the page edges, like a cover band */
.editor > h1.band:first-child { margin: calc(-1 * var(--m)) calc(-1 * var(--m)) 14pt; padding-left: max(var(--m), 26px) !important; border-radius: 4px 4px 0 0; }
.editor > h1.band[data-deco="avatar"]:first-child { padding-left: calc(var(--m) + 120px) !important; background-position: calc(var(--m) - 6px) center !important; }
/* round portrait photo (résumé, about me): sits where the avatar sat, the text starts after it */
.editor > h1.band[data-pimg]:first-child { --px: calc(var(--m) - 6px); padding-left: calc(var(--m) + var(--pd, 110px) + 18px) !important; }
@media (max-width: 640px) { .editor > h1.band:first-child { margin: -18px -16px 12px; padding-left: 18px !important; } .editor > h1.band[data-deco="avatar"]:first-child { padding-left: 118px !important; background-position: 12px center !important; } .editor > h1.band[data-pimg]:first-child { --px: 12px; padding-left: calc(var(--pd, 110px) + 32px) !important; } }

/* "+" add-block button and the "/" insert menu */
.blk-add { position: absolute; z-index: 6; width: 26px; height: 32px; border: 1px solid #e1e4ee; border-radius: 9px; background: #fff; color: #6a7389; box-shadow: 0 2px 8px rgba(27, 33, 51, .12); font: 600 18px/1 system-ui, sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.blk-add:hover { color: var(--accent); border-color: #cfc9ff; }
.slash-menu { width: 230px; max-height: 320px; overflow: auto; }
.slash-menu button.on { background: var(--hover); }
body[data-mode="view"] .blk-add { display: none !important; }
@media print { .blk-add, .slash-menu { display: none !important; } }

/* ================= round 2: suggestions, comments + mentions, version history, chips, embeds ================= */
.editor ins.sg { text-decoration: none; background: #dcfce7; color: #166534; border-bottom: 2px solid #22c55e; }
.editor del.sg { text-decoration: line-through; text-decoration-color: #dc2626; background: #fee2e2; color: #991b1b; }
.editor .sg.flash { outline: 3px solid #f59e0b; outline-offset: 1px; }
.tb.suggest { border: 1px solid #d9dcea; border-radius: 10px; font-weight: 600; }
.tb.suggest.on { background: #dcfce7; border-color: #22c55e; color: #166534; }
body.suggesting .editor { caret-color: #16a34a; }
.sg-head { display: flex; flex-direction: column; gap: 6px; }
.sg-count { margin: 0; font-size: 13.5px; }
.sg-card { border: 1px solid #e3e6ef; border-left: 4px solid #22c55e; border-radius: 10px; padding: 8px 10px; background: #fff; }
.sg-card.del { border-left-color: #dc2626; }
.sg-card p { margin: 0 0 4px; font-size: 13.5px; }
.cmt-card { border: 1px solid #e3e6ef; border-radius: 12px; padding: 8px 10px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.cmt-card.resolved { opacity: .7; background: #f8fafc; }
.cmt-quote { border: 0; border-left: 3px solid #ffd166; background: #fffbeb; text-align: left; padding: 4px 8px; border-radius: 6px; font: inherit; font-size: 12.5px; color: #475569; cursor: pointer; }
.cmt-msg { font-size: 13.5px; }
.cmt-msg.reply { margin-left: 12px; padding-left: 8px; border-left: 2px solid #e3e6ef; }
.cmt-list { display: flex; flex-direction: column; gap: 8px; }
.mention { color: #4338ca; background: #e0e7ff; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.mention-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0; }
.mention-list button { border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.cmt-people summary { cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 6px 0; }
.ppl-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ppl { display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12.5px; }
.ppl button { border: 0; background: none; cursor: pointer; color: #64748b; }
.ver-list { display: flex; flex-direction: column; gap: 6px; }
.ver-item { border: 1px solid #e3e6ef; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; background: #fff; }
.ver-item.auto b { font-weight: 600; color: #475569; }
.ver-dialog .ver-preview { max-height: 60vh; overflow: auto; border: 1px solid #e3e6ef; border-radius: 10px; padding: 16px 20px; margin: 10px 0; background: #fff; }
.chip-dot { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; }
#chipMenu { width: 180px; }
.dp-embed { display: flex; flex-direction: column; text-align: left; }
.dp-embed small { color: var(--muted); font-size: 11.5px; }
/* printing matches downloads: the text without pending suggestions */
@media print { .editor ins.sg { display: none; } .editor del.sg { text-decoration: none; background: none; color: inherit; } }

/* pageless: one continuous page, no page edges, no header/footer, page breaks shown as a gap */
.paper.pageless { background-image: none; min-height: 0; padding-bottom: 40mm; }
.paper.pageless .page-head, .paper.pageless .page-foot { display: none; }
.paper.pageless .editor .pb { border-top-style: dotted; opacity: .5; }
#aiStop { align-self: flex-start; }
