/* Qalam — application interface styles (title bar, ribbon, panes, dialogs, backstage).
 * Uses logical properties so the whole UI mirrors automatically for right-to-left (Arabic). */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", "Geeza Pro", Tahoma, Arial, sans-serif;
  --accent: #2b579a; --accent-hover: #24497f; --accent-text: #185abd; --accent-weak: #d6e3f5; --accent-dark: #1e4f8f;
  --ic-accent: #2b579a;
  --titlebar-bg: #2b579a; --titlebar-fg: #fff;
  --chrome-bg: #f3f3f3; --ribbon-bg: #ffffff; --sep: #e1dfdd;
  --fg: #242424; --fg-muted: #616161;
  --hover: #ebebeb; --pressed: #e0e0e0; --checked: #dce7f6; --checked-border: #b9cde9;
  --canvas-bg: #e6e6e6; --page-color: #fff; --focus-bg: #2b2b2b;
  --menu-bg: #fff; --menu-border: #d6d6d6; --menu-shadow: 0 8px 24px rgba(0,0,0,.16);
  --input-bg: #fff; --input-border: #c8c8c8; --btn-bg: #fff; --btn-border: #c8c8c8; --bs-bg: #fff;
  --ruler-margin: #d4d4d4; --ruler-page: #fff; --ruler-ink: #555; --ruler-marker: #6f6f6f;
  --ctx-bg: #e7eefa;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #3b78d8; --accent-hover: #4a86e3; --accent-text: #8ab4f8; --accent-weak: #2a3a52; --accent-dark: #1b3557;
  --ic-accent: #8ab4f8;
  --titlebar-bg: #1d3557;
  --chrome-bg: #1f1f1f; --ribbon-bg: #2b2b2b; --sep: #3d3d3d;
  --fg: #f0f0f0; --fg-muted: #b3b3b3;
  --hover: #3a3a3a; --pressed: #454545; --checked: #34465f; --checked-border: #46607f;
  --canvas-bg: #161616; --focus-bg: #101010;
  --menu-bg: #2b2b2b; --menu-border: #474747; --menu-shadow: 0 8px 24px rgba(0,0,0,.5);
  --input-bg: #1e1e1e; --input-border: #565656; --btn-bg: #333; --btn-border: #565656; --bs-bg: #242424;
  --ruler-margin: #3b3b3b; --ruler-page: #565656; --ruler-ink: #d0d0d0; --ruler-marker: #d0d0d0;
  --ctx-bg: #2a3a52;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 13px/1.35 var(--font-ui); color: var(--fg); background: var(--chrome-bg); -webkit-font-smoothing: antialiased; }
html[lang="ar"] body { font-size: 13.5px; }
button { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#app { display: flex; flex-direction: column; height: 100vh; position: relative; }
.ic { width: 18px; height: 18px; flex: none; display: block; direction: ltr; }
.ic .f { fill: currentColor; stroke: none; }
.ic .a { stroke: var(--ic-accent); }
.ic .af { fill: var(--ic-accent); stroke: none; }
.ic .w { fill: var(--ribbon-bg); }
.ic .rd { stroke: #d13438; }
.ic .pf { fill: #e3008c; stroke: none; }
.ic text { fill: currentColor; stroke: none; }
.ic .at { fill: var(--ic-accent); }
.ic .rt { fill: #c43e1c; }
[dir="rtl"] .ic.flip { transform: scaleX(-1); }

/* ---------------- title bar ---------------- */
#titlebar { height: 38px; flex: none; display: flex; align-items: center; padding: 0 8px; background: var(--titlebar-bg); color: var(--titlebar-fg); user-select: none; -webkit-user-select: none; }
.tb-side { flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-end { justify-content: flex-end; }
.tb-center { flex: 0 1 auto; min-width: 0; padding: 0 12px; }
.tb-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.tb-title.dirty::after { content: " •"; opacity: .8; }
.app-logo { width: 20px; height: 20px; background: url(../img/icon.svg) center / contain no-repeat; margin-inline-end: 4px; }
.qat { display: flex; align-items: center; gap: 2px; }
.qbtn { width: 30px; height: 28px; display: flex; align-items: center; justify-content: center; border: none; background: none; color: inherit; border-radius: 5px; padding: 0; }
.qbtn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.qbtn:disabled { opacity: .45; }
.qbtn .ic { width: 17px; height: 17px; }
.cmd-search { width: min(320px, 34vw); height: 26px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 6px; background: rgba(255,255,255,.92); color: #333; }
:root[data-theme="dark"] .cmd-search { background: rgba(255,255,255,.12); color: #eee; }
.cmd-search .search-icon .ic { width: 14px; height: 14px; opacity: .7; }
.search-input { flex: 1; min-width: 0; border: none; background: transparent; font: inherit; font-size: 12.5px; color: inherit; outline: none; }
.search-input::placeholder { color: inherit; opacity: .6; }
body.native #titlebar { display: none; }
.qat.in-tabbar { margin-inline-end: 6px; padding-inline-end: 6px; border-inline-end: 1px solid var(--sep); align-self: center; }
.qat.in-tabbar .qbtn { color: var(--fg); width: 28px; height: 26px; }
.qat.in-tabbar .qbtn:hover:not(:disabled) { background: var(--hover); }

/* ---------------- tabs ---------------- */
#tabbar { height: 34px; flex: none; display: flex; align-items: flex-end; gap: 2px; padding: 0 8px; background: var(--chrome-bg); user-select: none; -webkit-user-select: none; }
.tab { height: 30px; padding: 0 11px; border: none; background: none; color: var(--fg); font-size: 13px; border-radius: 5px 5px 0 0; position: relative; white-space: nowrap; cursor: default; }
html[lang="ar"] .tab { font-size: 13.5px; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--accent-text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; inset-inline: 10px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--accent); }
.tab-file { color: var(--accent-text); font-weight: 600; }
.tab.ctx { background: var(--ctx-bg); color: var(--accent-text); }
.tab-spacer { flex: 1; }
.tab-collapse { width: 28px; height: 26px; margin-bottom: 3px; border: none; background: none; color: var(--fg-muted); border-radius: 5px; display: flex; align-items: center; justify-content: center; padding: 0; }
.tab-collapse:hover { background: var(--hover); }
.tab-collapse .ic { width: 14px; height: 14px; }
body.ribbon-collapsed .tab-collapse .ic { transform: rotate(180deg); }

/* ---------------- ribbon ---------------- */
#ribbon { height: 98px; flex: none; display: flex; margin: 0 6px 6px; background: var(--ribbon-bg); border-radius: 8px; box-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.12); overflow: hidden; user-select: none; -webkit-user-select: none; }
body.ribbon-collapsed #ribbon { display: none; }
body.ribbon-collapsed.ribbon-peek #ribbon { display: flex; position: absolute; top: 72px; inset-inline: 0; z-index: 60; box-shadow: var(--menu-shadow); }
body.native.ribbon-collapsed.ribbon-peek #ribbon { top: 34px; }
.rpanel { display: none; flex: 1; align-items: stretch; padding: 4px 2px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.rpanel::-webkit-scrollbar { display: none; }
.rpanel.active { display: flex; }
.rgroup { display: flex; flex-direction: column; flex: none; padding: 0 6px; position: relative; }
.rgroup + .rgroup { border-inline-start: 1px solid var(--sep); }
.rgroup-body { flex: 1; display: flex; align-items: flex-start; gap: 2px; padding-top: 1px; }
.rgroup-label { height: 18px; line-height: 16px; font-size: 11px; color: var(--fg-muted); text-align: center; white-space: nowrap; padding: 0 16px; }
.rlauncher { position: absolute; bottom: 2px; inset-inline-end: 3px; width: 16px; height: 16px; padding: 0; border: none; background: none; color: var(--fg-muted); border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.rlauncher:hover { background: var(--hover); color: var(--fg); }
.rlauncher .ic { width: 11px; height: 11px; }
.rbtn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 26px; min-width: 26px; padding: 0 4px; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--fg); font-size: 12px; white-space: nowrap; position: relative; cursor: default; }
html[lang="ar"] .rbtn { font-size: 12.5px; }
.rbtn:hover:not(:disabled) { background: var(--hover); }
.rbtn:active:not(:disabled), .rbtn.open { background: var(--pressed); }
.rbtn.on { background: var(--checked); border-color: var(--checked-border); }
.rbtn:disabled, .rbtn.disabled { opacity: .38; }
.rbtn-icon { display: flex; align-items: center; justify-content: center; flex: none; }
.rbtn.big { flex-direction: column; justify-content: flex-start; height: 74px; min-width: 52px; max-width: 86px; padding: 4px 4px 2px; gap: 3px; }
.rbtn.big .ic { width: 32px; height: 32px; stroke-width: 1.15; }
.rbtn.big .rbtn-label { white-space: normal; text-align: center; line-height: 1.15; max-width: 82px; }
.rbtn .caret { display: flex; }
.rbtn .caret .ic { width: 10px; height: 10px; stroke-width: 2; }
.rbtn.big.dd .caret { margin-top: -2px; }
.rbtn.labeled { justify-content: flex-start; padding-inline: 4px 7px; }
.rcol { display: flex; flex-direction: column; gap: 0; padding-top: 0; }
.rcol > .rbtn, .rcol > .rsplit > .rbtn { height: 25px; }
.rcol > .rbtn, .rcol > .rsplit { width: 100%; justify-content: flex-start; }
.rrows { display: flex; flex-direction: column; gap: 5px; padding-top: 3px; }
.rrow { display: flex; align-items: center; gap: 1px; }
.rsep { width: 1px; height: 20px; background: var(--sep); margin: 0 4px; flex: none; }
.rsplit { display: inline-flex; align-items: stretch; border-radius: 4px; }
.rsplit > .rbtn { border-radius: 0; }
.rsplit > .rbtn:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.rsplit > .rbtn:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }
.rsplit:hover > .rbtn:not(:disabled) { border-color: var(--sep); }
.rsplit .rarrow { min-width: 14px; width: 14px; padding: 0; }
.rsplit .rarrow .ic { width: 10px; height: 10px; stroke-width: 2; }
.rsplit.big { flex-direction: column; }
.rsplit.big > .rbtn.big { height: 54px; border-radius: 4px 4px 0 0; }
.rsplit.big > .rarrow { width: auto; height: 20px; border-radius: 0 0 4px 4px; }
.color-btn .rbtn-icon { flex-direction: column; gap: 0; }
.cbar { display: block; width: 16px; height: 4px; margin-top: -2px; border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.rbtn.big .cbar { width: 28px; height: 5px; }
.rcombo { display: inline-flex; align-items: center; height: 24px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--input-bg); margin-inline-end: 2px; }
.rcombo:hover { border-color: var(--fg-muted); }
.rcombo:focus-within { border-color: var(--accent); }
.rcombo-input { height: 100%; border: none; background: transparent; padding: 0 6px; font: inherit; font-size: 12px; color: var(--fg); outline: none; min-width: 0; }
.rcombo-arrow { width: 18px; height: 100%; border: none; background: none; color: var(--fg-muted); padding: 0; display: flex; align-items: center; justify-content: center; }
.rcombo-arrow .ic { width: 10px; height: 10px; stroke-width: 2; }
.rgallery { display: flex; align-items: stretch; height: 70px; border: 1px solid var(--sep); border-radius: 6px; margin-top: 1px; }
.gal-list { display: flex; flex-wrap: wrap; width: 332px; height: 68px; overflow: hidden; }
.gal-item { width: 82px; height: 68px; flex: none; border: 1px solid transparent; border-radius: 5px; background: none; padding: 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--fg); overflow: hidden; }
.gal-item:hover { background: var(--hover); }
.gal-item.on { border-color: var(--accent); background: var(--checked); }
.gal-prev { height: 38px; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; font-family: Arial, "Geeza Pro", sans-serif; font-size: 13px; white-space: nowrap; }
.gal-prev > * { margin: 0 !important; padding: 0 !important; border: none !important; line-height: 1.2 !important; text-align: center !important; font-size: 13px; white-space: nowrap; }
.gal-prev p:not([class]) { color: var(--fg); }
.gal-prev h1 { font-size: 16px; } .gal-prev h2 { font-size: 14.5px; } .gal-prev h3, .gal-prev h4 { font-size: 13.5px; }
.gal-prev .st-title { font-size: 20px; color: var(--fg); } .gal-prev .st-subtitle { font-size: 12px; } .gal-prev .st-quote, .gal-prev .st-intense { font-size: 12.5px; }
:root[data-theme="dark"] .gal-prev h1, :root[data-theme="dark"] .gal-prev h2, :root[data-theme="dark"] .gal-prev h4, :root[data-theme="dark"] .gal-prev .st-intense { color: #8ab4f8; }
:root[data-theme="dark"] .gal-prev p { color: var(--fg); }
:root[data-theme="dark"] .gal-prev h3 { color: #a8c7fa; } :root[data-theme="dark"] .gal-prev .st-subtitle, :root[data-theme="dark"] .gal-prev .st-quote { color: #c8c8c8; }
.gal-name { font-size: 11px; color: var(--fg-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-nav { display: flex; flex-direction: column; border-inline-start: 1px solid var(--sep); }
.gal-scroll { flex: 1; width: 17px; border: none; background: none; padding: 0; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.gal-scroll:hover { background: var(--hover); }
.gal-scroll .ic { width: 11px; height: 11px; stroke-width: 2; }
.rspin { display: flex; align-items: center; gap: 6px; height: 27px; font-size: 12px; white-space: nowrap; }
.rspin-label { min-width: 56px; }
.rspin-input { width: 62px; height: 23px; border: 1px solid var(--input-border); border-radius: 4px; padding: 0 4px; font: inherit; font-size: 12px; background: var(--input-bg); color: var(--fg); }
.rspin-unit { color: var(--fg-muted); font-size: 11px; min-width: 26px; }
.rcheck { display: flex; align-items: center; gap: 6px; height: 23px; padding: 0 4px; font-size: 12.5px; white-space: nowrap; }
#ribbon.compact .rbtn.big { height: auto; min-width: 28px; max-width: none; padding: 3px; }
#ribbon.compact .rbtn.big .rbtn-label { display: none; }
#ribbon.compact .rbtn.big .ic { width: 22px; height: 22px; }
#ribbon.compact .rsplit.big > .rbtn.big { height: auto; }
#ribbon.compact .gal-list { width: 249px; }
#ribbon.compact .rgroup-label { padding: 0 4px; }
#ribbon.compact .rbtn.labeled .rbtn-label { display: none; }
#ribbon.compact .rcol > .rbtn, #ribbon.compact .rcol > .rsplit { width: auto; }
#ribbon.compact .rgroup { padding: 0 3px; }
#ribbon.compact .rcombo-input[aria-label] { max-width: 110px; }

/* ---------------- main area ---------------- */
#main { flex: 1; display: flex; min-height: 0; }
#navpane { width: 260px; flex: none; display: flex; flex-direction: column; background: var(--ribbon-bg); border-inline-end: 1px solid var(--sep); }
#navpane[hidden] { display: none; }
#docarea { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#ruler { height: 22px; flex: none; background: var(--chrome-bg); border-bottom: 1px solid var(--sep); overflow: hidden; }
#ruler[hidden] { display: none; }
#ruler canvas { display: block; }
#workspace { flex: 1; overflow: auto; background: var(--canvas-bg); position: relative; direction: ltr; }
#zoomer { position: relative; margin: 20px auto 44px; }
#docroot { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#sheets .sheet { position: absolute; left: 0; background: var(--page-color); box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 2px 7px rgba(0,0,0,.18); }
.hf { position: absolute; overflow: hidden; color: #000; pointer-events: none; min-height: 1em; outline: none; }
.hf > :last-child { margin-bottom: 0; }
#docroot.hf-editing .hf { pointer-events: auto; z-index: 2; overflow: visible; }
#docroot.hf-editing .hf[contenteditable] { outline: 1px dashed var(--accent); outline-offset: 4px; }
#docroot.hf-editing .hf[contenteditable]::before { content: attr(data-label); position: absolute; inset-inline-start: -6px; font: 11px var(--font-ui); background: var(--accent); color: #fff; padding: 1px 8px; border-radius: 3px; white-space: nowrap; }
#docroot.hf-editing .hf-header[contenteditable]::before { top: -24px; }
#docroot.hf-editing .hf-footer[contenteditable]::before { bottom: -24px; }
#docroot.hf-editing #flow { opacity: .45; pointer-events: none; }
#flow { position: absolute; display: flow-root; z-index: 1; }
.pg-sp { float: left; clear: left; width: 0; }
.pg-gap { float: left; clear: left; width: 100%; pointer-events: none; }
.pg-ex { float: left; clear: left; pointer-events: none; }
.pg-spr { float: right; clear: right; width: 0; }
.pg-exr { float: right; clear: right; pointer-events: none; }
#editor { outline: none; caret-color: #000; }
#editor.obj-sel { caret-color: transparent; }   /* a picture or shape is selected: no text cursor, like Word */
#docroot.web { background: var(--page-color); }
body.view-web #workspace { background: var(--page-color); }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.img-overlay { position: absolute; outline: 1.5px solid var(--accent); pointer-events: none; }
.img-overlay[hidden] { display: none; }
.img-handle { position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--accent); border-radius: 50%; pointer-events: auto; }
.h-nw { left: -6px; top: -6px; cursor: nwse-resize; } .h-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.h-sw { left: -6px; bottom: -6px; cursor: nesw-resize; } .h-se { right: -6px; bottom: -6px; cursor: nwse-resize; }
body.resizing, body.resizing * { cursor: nwse-resize !important; user-select: none !important; }
body.painting #editor { cursor: copy; }
::highlight(qalam-find) { background-color: #fff19a; }
::highlight(qalam-find-current) { background-color: #ffb900; color: #000; }
body.focus-mode #titlebar, body.focus-mode #tabbar, body.focus-mode #ribbon, body.focus-mode #statusbar, body.focus-mode #ruler, body.focus-mode #navpane { display: none !important; }
body.focus-mode #workspace { background: var(--focus-bg); }

/* ---------------- status bar ---------------- */
#statusbar { height: 26px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--chrome-bg); border-top: 1px solid var(--sep); font-size: 12px; color: var(--fg-muted); user-select: none; -webkit-user-select: none; }
.sb-item { height: 22px; padding: 0 8px; border: none; background: none; border-radius: 4px; font: inherit; color: inherit; white-space: nowrap; }
.sb-item:hover, .sb-icon:hover { background: var(--hover); color: var(--fg); }
.sb-spacer { flex: 1; }
.sb-views { display: flex; gap: 1px; margin-inline-end: 10px; }
.sb-icon { width: 26px; height: 22px; padding: 0; border: none; background: none; border-radius: 4px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.sb-icon .ic { width: 15px; height: 15px; }
.sb-icon.on { background: var(--checked); color: var(--accent-text); }
.sb-zoom { display: flex; align-items: center; gap: 2px; direction: ltr; }
.zoom-slider { width: 110px; accent-color: var(--accent); }
.zoom-pct { min-width: 48px; }

/* ---------------- navigation pane ---------------- */
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 12px; font-weight: 600; font-size: 14px; }
.np-x { width: 26px; height: 26px; border: none; background: none; border-radius: 4px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }
.np-x:hover { background: var(--hover); }
.np-x .ic { width: 14px; height: 14px; }
.np-search { padding: 4px 12px 8px; }
.np-search .inp { width: 100%; }
.np-tab { margin: 0 12px; padding: 4px 2px 6px; width: fit-content; font-size: 12px; font-weight: 600; color: var(--accent-text); border-bottom: 2px solid var(--accent); }
.np-list { flex: 1; overflow: auto; padding: 8px 6px; border-top: 1px solid var(--sep); }
.np-item { display: block; width: 100%; padding: 5px 8px; border: none; background: none; border-radius: 4px; text-align: start; font: inherit; font-size: 13px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-item:hover { background: var(--hover); }
.np-item.on { background: var(--checked); font-weight: 600; }
.np-item.lvl0 { font-weight: 600; } .np-item.lvl1 { padding-inline-start: 22px; } .np-item.lvl2 { padding-inline-start: 36px; } .np-item.lvl3 { padding-inline-start: 50px; }
.np-empty { padding: 12px; font-size: 12px; color: var(--fg-muted); line-height: 1.6; }

/* ---------------- menus & popups ---------------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 2500; }
.menu { position: fixed; pointer-events: auto; min-width: 190px; max-width: 420px; max-height: 76vh; overflow: auto; padding: 4px; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 8px; box-shadow: var(--menu-shadow); }
.mi { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 10px; border-radius: 5px; white-space: nowrap; cursor: default; outline: none; }
.mi:hover, .mi:focus { background: var(--hover); }
.mi.disabled { opacity: .45; pointer-events: none; }
.mi.hint { font-size: 11px; min-height: 24px; }
.mi.checked-icon { background: var(--checked); }
.mi-icon { width: 18px; height: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
.mi-icon .ic { width: 16px; height: 16px; }
.mi.checked .mi-icon { color: var(--accent-text); }
.mi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.mi-sample { color: var(--fg-muted); font-size: 15px; }
.mi-sc { color: var(--fg-muted); font-size: 11.5px; direction: ltr; unicode-bidi: isolate; margin-inline-start: 18px; }
.mi-sub .ic { width: 12px; height: 12px; }
.msep { height: 1px; background: var(--sep); margin: 4px 6px; }
.mhead { padding: 7px 10px 3px; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); }
.combo-menu { max-height: 440px; }
.font-menu { width: 320px; }
.color-panel { width: 236px; padding-bottom: 2px; }
.swatches { display: grid; gap: 2px; padding: 2px 10px; justify-content: start; }
.swatches.cols10 { grid-template-columns: repeat(10, 18px); }
.swatches.cols5 { grid-template-columns: repeat(5, 24px); gap: 4px; padding: 6px 10px; }
.swatches.first { margin-bottom: 5px; }
.swatches.tints { row-gap: 0; padding-top: 0; padding-bottom: 0; }
.sw { width: 18px; height: 18px; padding: 0; border: 1px solid rgba(0,0,0,.14); border-radius: 2px; }
.cols5 .sw { width: 24px; height: 24px; }
.sw:hover { outline: 2px solid var(--accent); outline-offset: 1px; position: relative; z-index: 1; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,.2); }
.hidden-color { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.tgrid-wrap { padding-bottom: 4px; }
.tgrid { display: grid; grid-template-columns: repeat(10, 19px); gap: 3px; padding: 4px 10px 6px; }
.tg-cell { width: 19px; height: 19px; border: 1px solid #c8c6c4; background: #fff; }
.tg-cell.on { border-color: var(--accent); background: #cfe0f7; }
.list-lib { display: grid; grid-template-columns: repeat(4, 54px); gap: 6px; padding: 6px 10px 10px; }
.lib-item { height: 54px; border: 1px solid var(--sep); background: var(--ribbon-bg); color: var(--fg); border-radius: 5px; font-size: 22px; padding: 0; }
.lib-item:hover { border-color: var(--accent); }
.lib-item.on { border-color: var(--accent); background: var(--checked); }
.list-lib.num { grid-template-columns: repeat(3, 72px); }
.list-lib.num .lib-item { height: 76px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; padding: 4px 10px; font-size: 12.5px; }
.sym-grid { display: grid; grid-template-columns: repeat(10, 30px); gap: 3px; padding: 6px 10px; }
.sym-grid.big { grid-template-columns: repeat(12, 34px); max-height: 300px; overflow: auto; margin-top: 10px; padding: 0; }
.sym { height: 30px; padding: 0; border: 1px solid var(--sep); background: var(--ribbon-bg); color: var(--fg); border-radius: 4px; font-size: 16px; }
.sym-grid.big .sym { height: 34px; font-size: 18px; }
.sym:hover { border-color: var(--accent); background: var(--checked); }
.tooltip { position: fixed; max-width: 300px; padding: 8px 10px; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 6px; box-shadow: var(--menu-shadow); font-size: 12px; pointer-events: none; z-index: 3000; }
.tt-title { font-weight: 600; }
.tt-sc { font-weight: normal; color: var(--fg-muted); direction: ltr; unicode-bidi: isolate; }
.tt-desc { margin-top: 4px; color: var(--fg-muted); line-height: 1.45; }
.toast { position: fixed; bottom: 44px; left: 50%; transform: translate(-50%, 16px); max-width: 80vw; padding: 10px 18px; border-radius: 8px; background: #323130; color: #fff; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s, transform .25s; z-index: 4000; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- dialogs ---------------- */
.dlg-back { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.28); }
.dlg-back.modeless { background: transparent; pointer-events: none; align-items: flex-start; padding-top: 130px; }
.dlg-back.modeless .dlg { pointer-events: auto; box-shadow: 0 10px 36px rgba(0,0,0,.3); }
.dlg { max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; background: var(--menu-bg); color: var(--fg); border: 1px solid var(--menu-border); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.dlg-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px 16px; padding-inline: 16px 10px; font-size: 14px; font-weight: 600; cursor: move; user-select: none; -webkit-user-select: none; }
.dlg-x { width: 28px; height: 28px; border: none; background: none; border-radius: 5px; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; padding: 0; }
.dlg-x:hover { background: var(--hover); }
.dlg-x .ic { width: 14px; height: 14px; }
.dlg-body { padding: 6px 16px 12px; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 8px 16px 14px; }
.dlg-foot .btn[hidden] { display: none; }
.btn { height: 30px; padding: 0 16px; border: 1px solid var(--btn-border); border-radius: 6px; background: var(--btn-bg); color: var(--fg); font-size: 13px; white-space: nowrap; cursor: default; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.form { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
.field-label { color: var(--fg-muted); }
.inp { height: 30px; min-width: 0; padding: 0 8px; border: 1px solid var(--input-border); border-radius: 6px; background: var(--input-bg); color: var(--fg); font: inherit; font-size: 13px; }
.inp:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
.inp.wide { width: 100%; }
.inp.ltr { direction: ltr; text-align: left; }
.inp.list { height: auto; padding: 4px; width: 100%; }
.inp.color { width: 64px; padding: 2px; }
select.inp { padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1.2fr 1fr; gap: 8px 10px; }
.fs-title { margin-top: 6px; padding-bottom: 3px; border-bottom: 1px solid var(--sep); font-size: 12px; font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 2px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.dlg-tabs { display: flex; gap: 2px; margin-bottom: 12px; border-bottom: 1px solid var(--sep); }
.dlg-tab { padding: 6px 12px; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--fg-muted); font: inherit; }
.dlg-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.find-dlg .pane { display: flex; flex-direction: column; gap: 8px; }
.find-dlg .pane[hidden], .find-dlg [hidden] { display: none; }
.find-status { min-height: 18px; font-size: 12px; color: var(--fg-muted); }
.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats td { padding: 7px 4px; border-bottom: 1px solid var(--sep); }
.stats td.num, .stats td.kbd { text-align: end; direction: ltr; unicode-bidi: isolate; }
.keys-wrap { max-height: 60vh; overflow: auto; }
.stats.keys td.kbd { color: var(--fg-muted); white-space: nowrap; }
.font-preview { height: 72px; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; border: 1px solid var(--sep); border-radius: 6px; background: #fff; color: #000; }
.about { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.about h2 { margin: 4px 0 0; font-size: 22px; }
.about p { max-width: 420px; line-height: 1.6; }
.about-logo { width: 72px; height: 72px; background: url(../img/icon.svg) center / contain no-repeat; }
.about.big { align-items: flex-start; text-align: start; }
.about.big .about-logo { width: 96px; height: 96px; }
.confirm-msg { font-size: 14px; font-weight: 600; line-height: 1.5; }
.confirm-sub { margin-top: 6px; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }

/* ---------------- backstage (File tab) ---------------- */
#backstage { position: fixed; inset: 0; z-index: 1500; display: flex; background: var(--bs-bg); color: var(--fg); }
#backstage[hidden] { display: none; }
.bs-nav { width: 220px; flex: none; display: flex; flex-direction: column; padding: 10px 0; background: var(--accent-dark); color: #fff; user-select: none; -webkit-user-select: none; }
.bs-back { width: 42px; height: 42px; margin: 4px 12px 14px; padding: 0; border: none; background: none; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.bs-back:hover { background: rgba(255,255,255,.15); }
.bs-back .ic { width: 30px; height: 30px; stroke-width: 1.15; }
.bs-item { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 20px; border: none; background: none; color: #fff; font-size: 14px; text-align: start; }
.bs-item:hover { background: rgba(255,255,255,.12); }
.bs-item.active { background: rgba(255,255,255,.22); font-weight: 600; }
.bs-item .ic { width: 18px; height: 18px; }
.bs-spacer { flex: 1; }
.bs-main { flex: 1; overflow: auto; padding: 32px 48px; }
.bs-h1 { margin: 0 0 24px; font-size: 30px; font-weight: 300; }
.bs-h2 { margin: 28px 0 12px; font-size: 16px; font-weight: 600; }
.tpl-grid { display: flex; flex-wrap: wrap; gap: 22px; }
.tpl { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0; border: none; background: none; color: var(--fg); font-size: 13px; }
.tpl-thumb { width: 150px; height: 212px; position: relative; overflow: hidden; background: #fff; border: 1px solid var(--sep); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tpl:hover .tpl-thumb { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.tpl-page { position: absolute; top: 0; left: 0; width: 794px; height: 1123px; padding: 72px; transform: scale(.189); transform-origin: 0 0; pointer-events: none; color: #000; font-size: 14pt; }
.bs-row { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 18px; }
.bs-big { width: 112px; height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--sep); border-radius: 8px; background: var(--ribbon-bg); color: var(--fg); font-size: 14px; }
.bs-big .ic { width: 36px; height: 36px; stroke-width: 1.1; }
.bs-big:hover { border-color: var(--accent); background: var(--checked); }
.bs-big.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.recent { display: flex; flex-direction: column; max-width: 780px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; background: none; border-radius: 6px; color: var(--fg); text-align: start; font-size: 13px; }
.recent-item:hover { background: var(--hover); }
.ri-icon .ic { width: 28px; height: 28px; stroke-width: 1.1; }
.ri-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ri-title { font-weight: 600; }
.ri-sub { font-size: 12px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: start; }
[dir="rtl"] .ri-sub { text-align: right; }
.ri-date { font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.fmt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; max-width: 920px; }
.fmt-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--sep); border-radius: 8px; background: var(--ribbon-bg); color: var(--fg); text-align: start; }
.fmt-card:hover { border-color: var(--accent); background: var(--checked); }
.fmt-icon .ic { width: 40px; height: 40px; stroke-width: 1; }
.fmt-text { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.info-card { max-width: 660px; }
.info-doc { display: flex; align-items: center; gap: 12px; }
.info-doc .ic { width: 44px; height: 44px; stroke-width: 1; }
.info-name { font-size: 18px; font-weight: 600; }
.props { width: 100%; border-collapse: collapse; }
.props th { width: 170px; padding: 8px 0; text-align: start; font-weight: normal; color: var(--fg-muted); vertical-align: middle; }
.props td { padding: 6px 0; }
.opt-row { display: flex; align-items: center; gap: 16px; max-width: 580px; padding: 8px 0; }
.opt-row label { width: 230px; }
.opt-row .inp { min-width: 230px; }

/* ---------------- review: comments column, change bars ---------------- */
.ic .gr { stroke: #107c10; }
:root[data-theme="dark"] .ic .gr { stroke: #5cc95c; }
.rcombo.readonly .rcombo-input { cursor: default; caret-color: transparent; }
.btn.small { height: 26px; padding: 0 12px; font-size: 12px; }
.sb-track { color: var(--accent-text); font-weight: 600; }
.sb-track::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #c42b1c; margin-inline-end: 6px; vertical-align: 1px; }
.sb-track[hidden] { display: none; }
#tc-bars { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.tc-bar { position: absolute; width: 2px; background: #8a8a8a; border-radius: 1px; }
#tc-bars.simple .tc-bar { background: #c42b1c; }
#markup { position: absolute; top: 0; transform-origin: 0 0; z-index: 4; font: 13px/1.4 var(--font-ui); color: var(--fg); }
html[lang="ar"] #markup { font-size: 13.5px; }
#markup[hidden] { display: none; }
.cmt-card { position: absolute; inset-inline: 0; background: var(--menu-bg); border: 1px solid var(--sep); border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.10); padding: 10px 12px 10px; transition: top .18s ease, box-shadow .15s, transform .15s; }
.cmt-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.cmt-card.on { border-color: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
#markup[dir="rtl"] .cmt-card.on, #markup[dir="ltr"] .cmt-card.on { transform: translateX(var(--cc-shift, 0)); }
.cmt-card.done { background: var(--chrome-bg); }
.cmt-card.done .cc-text, .cmt-card.done .cc-reply { opacity: .7; }
.cc-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.cc-av { width: 26px; height: 26px; flex: none; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0; user-select: none; -webkit-user-select: none; }
.cc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cc-who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-time { font-size: 11px; color: var(--fg-muted); }
.cc-badge { font-size: 11px; color: #107c10; background: rgba(16,124,16,.1); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.cc-btn { width: 26px; height: 26px; flex: none; border: none; background: none; border-radius: 5px; color: var(--fg-muted); padding: 0;
  display: inline-flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s; }
.cc-btn .ic { width: 16px; height: 16px; }
.cmt-card:hover .cc-btn, .cmt-card.on .cc-btn, .cc-btn:focus-visible, .cc-btn.open { opacity: 1; }
.cc-btn:hover { background: var(--hover); color: var(--fg); }
.cc-text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.cc-reply { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--sep); }
.cc-reply .cc-av { width: 22px; height: 22px; font-size: 10px; }
.cc-box { display: none; align-items: flex-end; gap: 6px; margin-top: 10px; }
.cmt-card.on .cc-box, .cc-box:focus-within { display: flex; }
.cc-input { flex: 1; width: 100%; min-height: 32px; max-height: 220px; resize: none; border: 1px solid var(--input-border); border-radius: 6px;
  background: var(--input-bg); color: var(--fg); font: inherit; padding: 6px 8px; line-height: 1.4; display: block; overflow-y: auto; }
.cc-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cmt-card.draft .cc-input { margin-top: 8px; min-height: 56px; }
.cc-send { width: 32px; height: 32px; flex: none; border: none; border-radius: 6px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.cc-send .ic { width: 16px; height: 16px; }
.cc-send:disabled { background: var(--pressed); color: var(--fg-muted); }
.cc-edit { margin-top: 6px; }
.cc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.cc-hint { margin-inline-end: auto; font-size: 11px; color: var(--fg-muted); }

/* ---------------- shapes: handles, drawing, gallery ---------------- */
body.shape-drawing #docroot, body.shape-drawing #docroot * { cursor: crosshair !important; }
body.shape-moving, body.shape-moving * { cursor: move !important; }
.shape-ui { position: absolute; transform-origin: 50% 50%; pointer-events: none; z-index: 6; --hs: 10px; }
.shape-ui[hidden] { display: none; }
.sh-frame { position: absolute; inset: 0; border: 1px solid rgba(90,90,90,.75); }
.shape-ui.editing .sh-frame { border-style: dashed; border-color: var(--accent); }
.sh-h, .sh-rot, .sh-adj, .sh-end { position: absolute; width: var(--hs); height: var(--hs); margin: calc(var(--hs) / -2) 0 0 calc(var(--hs) / -2);
  box-sizing: border-box; border-radius: 50%; background: #fff; border: 1px solid #5f5f5f; pointer-events: auto; box-shadow: 0 0 0 0.5px rgba(255,255,255,.8); }
.sh-h.nw { left: 0; top: 0; cursor: nwse-resize; } .sh-h.n { left: 50%; top: 0; cursor: ns-resize; } .sh-h.ne { left: 100%; top: 0; cursor: nesw-resize; }
.sh-h.e { left: 100%; top: 50%; cursor: ew-resize; } .sh-h.se { left: 100%; top: 100%; cursor: nwse-resize; } .sh-h.s { left: 50%; top: 100%; cursor: ns-resize; }
.sh-h.sw { left: 0; top: 100%; cursor: nesw-resize; } .sh-h.w { left: 0; top: 50%; cursor: ew-resize; }
.sh-rot { left: 50%; top: calc(var(--hs) * -2.4); width: calc(var(--hs) * 1.5); height: calc(var(--hs) * 1.5); margin: calc(var(--hs) * -0.75) 0 0 calc(var(--hs) * -0.75); cursor: grab;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23444' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M15.6 10.5a5.6 5.6 0 1 1-1.8-4.4'/%3E%3Cpath d='M14.6 2.8v3.6H11'/%3E%3C/svg%3E") center / 72% no-repeat; }
.sh-rotline { position: absolute; left: 50%; top: calc(var(--hs) * -1.7); height: calc(var(--hs) * 1.7); border-left: 1px solid rgba(90,90,90,.6); }
.sh-adjs { position: absolute; inset: 0; }
.sh-adj { background: #ffd34e; border-color: #8a6d00; cursor: pointer; }
.sh-end { cursor: move; }
.shape-ui.line .sh-frame, .shape-ui.line .sh-h, .shape-ui.line .sh-rot, .shape-ui.line .sh-rotline { display: none; }
.shape-ui:not(.line) .sh-end { display: none; }
.shape-ui.editing .sh-rot, .shape-ui.editing .sh-rotline { display: none; }
.sh-preview { position: absolute; border: 1px solid #4472C4; background: rgba(68,114,196,.12); pointer-events: none; z-index: 6; }
.sh-preview.line { border: none; background: none; }
.sh-preview svg { position: absolute; left: 0; top: 0; overflow: visible; }
.shape-gallery { width: 318px; max-height: min(68vh, 560px); overflow-y: auto; padding: 0 2px 6px; }
.shape-gallery .mhead { position: sticky; top: 0; background: var(--menu-bg); z-index: 1; }
.sg-grid { display: grid; grid-template-columns: repeat(12, 24px); gap: 1px; padding: 2px 6px 6px; direction: ltr; }
.sg-item { width: 24px; height: 24px; border: 1px solid transparent; border-radius: 3px; background: none; padding: 0; color: var(--fg); display: flex; align-items: center; justify-content: center; }
.sg-item:hover { background: var(--hover); border-color: var(--sep); color: var(--accent-text); }
.sg-ic { width: 20px; height: 20px; display: block; }
.shape-styles { padding: 0 6px 8px; }
.ss-grid { display: grid; grid-template-columns: repeat(7, 40px); gap: 6px; padding: 2px 2px 6px; direction: ltr; }
.ss-item { width: 40px; height: 30px; border: 1.5px solid; border-radius: 3px; font: 600 12px var(--font-ui); padding: 0; }
.ss-item.shadow { box-shadow: 2px 3px 4px rgba(0,0,0,.35); }
.ss-item:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------- pictures: crop, Layout Options, panels ---------------- */
.shape-ui.crop .sh-h { border-radius: 0; background: #111; border: 1.5px solid #fff; width: calc(var(--hs) * 1.4); height: calc(var(--hs) * 1.4); margin: calc(var(--hs) * -0.7) 0 0 calc(var(--hs) * -0.7); }
.shape-ui.crop .sh-h.n, .shape-ui.crop .sh-h.s { width: calc(var(--hs) * 2.2); height: calc(var(--hs) * 0.7); margin: calc(var(--hs) * -0.35) 0 0 calc(var(--hs) * -1.1); }
.shape-ui.crop .sh-h.e, .shape-ui.crop .sh-h.w { width: calc(var(--hs) * 0.7); height: calc(var(--hs) * 2.2); margin: calc(var(--hs) * -1.1) 0 0 calc(var(--hs) * -0.35); }
.shape-ui.crop .sh-rot, .shape-ui.crop .sh-rotline, .shape-ui.crop .sh-adjs { display: none; }
.shape-ui.crop .sh-frame { border: 1px solid rgba(255,255,255,.9); outline: 1px solid rgba(0,0,0,.6); }
.crop-ghost { position: absolute; opacity: .38; pointer-events: none; }
.crop-ghost img { width: 100%; height: 100%; display: block; }
.shape-ui.inline .sh-rot, .shape-ui.inline .sh-rotline { display: none; }
.lo-btn { position: absolute; z-index: 7; pointer-events: auto; padding: 0; border: 1px solid #c8c8c8; border-radius: 3px; background: #fff; color: #444;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.2); cursor: default; }
.lo-btn[hidden] { display: none; }
.lo-btn .ic { width: 72%; height: 72%; }
.lo-btn:hover { background: #f1f5fc; border-color: var(--accent); }
.pic-panel { padding: 0 6px 8px; }
.pic-grid { display: grid; gap: 6px; padding: 2px 4px 6px; direction: ltr; justify-content: start; }
.pic-cell { padding: 2px; border: 2px solid transparent; border-radius: 4px; background: none; display: flex; }
.pic-cell:hover { border-color: var(--accent-weak); background: var(--hover); }
.pic-cell.on { border-color: var(--accent); }
.pt-img { width: 58px; height: 42px; overflow: hidden; display: block; position: relative; background: #fff; }
.pic-grid.styles .pt-img { width: 66px; height: 48px; margin: 5px; overflow: visible; }
.pt-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.pos-cell, .lo-cell { width: 40px; height: 40px; padding: 4px; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--fg); display: flex; align-items: center; justify-content: center; }
.pos-cell .ic, .lo-cell .ic { width: 28px; height: 28px; }
.pos-cell:hover, .lo-cell:hover { background: var(--hover); border-color: var(--sep); }
.pos-cell.on, .lo-cell.on { border-color: var(--accent); background: var(--checked); }
.pos-cell.inline { margin: 2px 8px 6px; }
.layout-panel { min-width: 270px; }
.lo-sub { font-size: 11.5px; color: var(--fg-muted); padding: 6px 8px 2px; }
.lo-row { display: flex; gap: 4px; padding: 2px 6px 4px; direction: ltr; }

/* ---------------- printing ---------------- */
#print-root { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .print-page { position: relative; overflow: hidden; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page .sheet { position: absolute; left: 0; top: 0; box-shadow: none !important; }
  .print-clip { position: absolute; overflow: hidden; }
  .print-flow { position: absolute; left: 0; display: flow-root; }
  .print-flow .shape:not([data-wrap="inline"]) { display: none !important; }
  .print-shapes { position: absolute; inset: 0; overflow: visible; }
  .print-page .hf { overflow: hidden; }
  .doc table.tbl-plain td, .doc table.tbl-plain th { border-color: transparent !important; }
  .doc .fld-page, .doc .fld-pages { background: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
