/* Niyya PDF Suite (web). The desktop app's light and dark themes (niyya_pdf/theme.py). */
:root {
  --window: #F1F1F1; --base: #FFFFFF; --alt: #F6F7F8; --text: #1B2530; --muted: #5E6A75;
  --border: #D6D1D3; --accent: #0088B1; --accent-text: #FFFFFF; --accent-soft: #D6ECF4;
  --viewer: #E2E6EA; --icon: #26404F; --icon-off: #B1B6BB; --brand: #D4006C;
  --shadow: 0 1px 3px rgba(20, 30, 40, .18), 0 8px 24px rgba(20, 30, 40, .12);
  --danger: #C62828;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --window: #1B2026; --base: #232A31; --alt: #2A323A; --text: #E9EDF0; --muted: #9AA6B0;
    --border: #3A434C; --accent: #1FA6D3; --accent-text: #FFFFFF; --accent-soft: #173E4E;
    --viewer: #14181C; --icon: #D5DEE4; --icon-off: #59636C; --brand: #FF3D96;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 28px rgba(0, 0, 0, .45);
    --danger: #EF5350;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --window: #1B2026; --base: #232A31; --alt: #2A323A; --text: #E9EDF0; --muted: #9AA6B0;
  --border: #3A434C; --accent: #1FA6D3; --accent-text: #FFFFFF; --accent-soft: #173E4E;
  --viewer: #14181C; --icon: #D5DEE4; --icon-off: #59636C; --brand: #FF3D96;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 28px rgba(0, 0, 0, .45);
  --danger: #EF5350;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  background: var(--window); color: var(--text);
  font: 13.5px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.busy, body.busy * { cursor: progress !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center-text { text-align: center; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
noscript p { padding: 24px; }

/* ---------------------------------------------------------------- menu bar */
.menubar {
  display: flex; align-items: center; gap: 2px; padding: 2px 8px; flex: none;
  background: var(--window); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.menubar::-webkit-scrollbar { display: none; }
.brand { display: inline-flex; align-items: center; gap: 7px; margin-inline-end: 10px; color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; }
.logo { display: inline-flex; flex: none; }
.logo img { display: block; }
.logo.small img { width: 22px; height: 22px; }
.logo.large img { width: 84px; height: 84px; }
.logo .for-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .for-light { display: none; }
  :root:not([data-theme="light"]) .logo .for-dark { display: block; }
}
:root[data-theme="dark"] .logo .for-light { display: none; }
:root[data-theme="dark"] .logo .for-dark { display: block; }
.menu-title {
  border: 0; background: none; padding: 5px 10px; border-radius: 5px; cursor: default; white-space: nowrap;
}
.menu-title:hover, .menu-title.open { background: var(--accent-soft); }
.menu-title:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------------- toolbars */
.toolbar {
  display: flex; align-items: center; gap: 2px; padding: 3px 6px; flex: none;
  background: var(--window); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: thin;
}
.tb {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  min-width: 32px; height: 32px; padding: 3px 5px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--icon); cursor: pointer; white-space: nowrap;
}
.tb:hover:not(:disabled) { background: var(--alt); border-color: var(--border); }
.tb:active:not(:disabled), .tb.checked { background: var(--accent-soft); border-color: var(--accent); }
.tb:disabled, .tb.disabled { color: var(--icon-off); cursor: default; }
.tb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tb-text { color: var(--text); font-size: 12.5px; }
.tb:disabled .tb-text, .tb.disabled .tb-text { color: var(--icon-off); }
.tb.under { flex-direction: column; gap: 1px; height: auto; min-width: 54px; padding: 3px 4px 2px; }
.tb.under .tb-text { font-size: 11.5px; line-height: 1.2; }
.tools-toolbar .tb.tool.checked { border-bottom: 3px solid var(--brand); }
.tb.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); padding: 3px 10px; font-weight: 600; }
.tb.primary .tb-text { color: var(--accent-text); font-size: 13px; }
.tb.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--text); }
.tb.primary:disabled { background: var(--border); border-color: var(--border); color: var(--icon-off); }
.tb.primary:disabled .tb-text { color: var(--icon-off); }
.split { display: inline-flex; margin-inline-start: 4px; }
.split .split-main { border-start-end-radius: 0; border-end-end-radius: 0; }
.split .split-arrow { min-width: 22px; padding: 3px 2px; border-start-start-radius: 0; border-end-start-radius: 0; border-inline-start: 1px solid rgba(255, 255, 255, .35); }
.split .split-arrow .ic { width: 14px; height: 14px; }
.main-toolbar > .tb.primary:last-child { margin-inline-start: 4px; }
.tb-sep { width: 1px; align-self: stretch; margin: 6px 5px; background: var(--border); flex: none; }
.tb-spacer { flex: 1; min-width: 8px; }
.page-input {
  width: 48px; height: 26px; text-align: center; border: 1px solid var(--border); border-radius: 5px; background: var(--base); flex: none;
}
.page-count { padding: 0 6px; color: var(--muted); white-space: nowrap; flex: none; }
.zoom-select, .width-input {
  height: 26px; border: 1px solid var(--border); border-radius: 5px; background: var(--base); padding: 0 4px; flex: none;
}
.zoom-select { width: 104px; margin: 0 2px; }
.page-input:focus, .zoom-select:focus, .width-input:focus { outline: none; border-color: var(--accent); }
.color-wrap, .width-wrap { cursor: default; }
.color-input { width: 30px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--base); cursor: pointer; }
.color-input:disabled { opacity: .45; cursor: default; }
.width-box { display: inline-flex; align-items: center; gap: 2px; height: 22px; }
.width-input { width: 52px; height: 22px; }
label.disabled { opacity: .55; }

/* ---------------------------------------------------------------- work area */
.workspace { flex: 1; min-height: 0; display: flex; position: relative; }
.center { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--viewer); }
.docs { flex: 1; min-height: 0; position: relative; }
.doc-pane { position: absolute; inset: 0; display: flex; flex-direction: column; }

.tabbar { flex: none; background: var(--window); border-bottom: 1px solid var(--border); }
.tab-list { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: thin; }
.tab {
  display: flex; align-items: center; gap: 6px; min-width: 110px; max-width: 260px; padding: 0 6px 0 12px; height: 36px;
  color: var(--muted); border-inline-end: 1px solid var(--border); border-top: 3px solid transparent; cursor: default; flex: none;
  user-select: none;
}
.tab:hover:not(.active) { color: var(--text); background: var(--alt); }
.tab.active { color: var(--text); background: var(--viewer); border-top-color: var(--brand); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab .tab-ic { width: 16px; height: 16px; opacity: .7; }
.tab-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-dot { color: var(--brand); font-weight: 700; }
.tab-close { display: inline-flex; border: 0; background: none; padding: 3px; border-radius: 4px; color: var(--muted); cursor: pointer; }
.tab-close .ic { width: 14px; height: 14px; }
.tab-close:hover { background: var(--border); color: var(--text); }
.new-tab {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 34px; height: 30px; margin: 3px 4px;
  border: 0; border-radius: 6px; background: var(--window); color: var(--icon); cursor: pointer;
  position: sticky; inset-inline-end: 0;
}
.new-tab:hover { background: var(--alt); }
.new-tab .ic { width: 18px; height: 18px; }

/* the pages */
.scroller {
  flex: 1; min-height: 0; overflow: auto; position: relative; direction: ltr; outline: none;
  background: var(--viewer); overscroll-behavior: contain;
}
.pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 20px 24px; width: max-content; min-width: 100%; }
.page {
  position: relative; flex: none; background: #fff; box-shadow: var(--shadow);
  --user-unit: 1; --total-scale-factor: calc(var(--scale-factor) * var(--user-unit)); --scale-round-x: 1px; --scale-round-y: 1px;
}
.canvas-box, .canvas-box canvas { position: absolute; inset: 0; display: block; }
.canvas-box canvas.stale { width: 100% !important; height: 100% !important; }
.link-layer, .overlay { position: absolute; inset: 0; }
.link-layer { pointer-events: none; z-index: 2; }
.pdf-link { position: absolute; pointer-events: auto; cursor: pointer; }
.pdf-link:hover { background: rgba(0, 136, 177, .12); }
.pdf-note { position: absolute; pointer-events: auto; cursor: help; }
.overlay { z-index: 3; pointer-events: none; }
.scroller[data-tool="add_text"] .overlay, .scroller[data-tool="image"] .overlay, .scroller[data-tool="rect"] .overlay,
.scroller[data-tool="whiteout"] .overlay, .scroller[data-tool="redact"] .overlay, .scroller[data-tool="ink"] .overlay { pointer-events: auto; cursor: crosshair; }
.scroller[data-tool="edit_text"] .overlay { pointer-events: auto; cursor: text; }
.scroller:not([data-tool="select"]):not([data-tool="hand"]) .overlay { touch-action: none; }  /* draw, do not scroll */
.scroller[data-tool="note"] .overlay { pointer-events: auto; cursor: copy; }
.scroller[data-tool="hand"] { cursor: grab; }
.scroller[data-tool="hand"].grabbing { cursor: grabbing; }
.scroller[data-tool="hand"] .textLayer, .scroller[data-tool="hand"] .link-layer { pointer-events: none; }
.scroller[data-tool="hand"] .textLayer :is(span, br) { cursor: inherit; }
.scroller:is([data-tool="highlight"], [data-tool="underline"], [data-tool="strikeout"]) .link-layer { display: none; }
.scroller[data-tool="highlight"] .textLayer ::selection { background: rgba(255, 213, 79, .55); }
.band { position: absolute; border: 1.5px dashed var(--accent); background: rgba(0, 136, 177, .08); }
.band-whiteout { border-color: #888; background: rgba(255, 255, 255, .75); }
.band-redact { border-color: #000; background: rgba(0, 0, 0, .35); }
.ink-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hit { position: absolute; background: rgba(255, 196, 0, .38); mix-blend-mode: multiply; border-radius: 2px; pointer-events: none; }
.hit.current { background: rgba(255, 120, 0, .55); outline: 2px solid #ff7800; }

/* PDF.js text layer (from pdf_viewer.css): invisible text over the page, for selecting. */
.textLayer {
  color-scheme: only light; position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1;
  letter-spacing: normal; word-spacing: normal; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none;
  transform-origin: 0 0; caret-color: CanvasText; z-index: 1;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(0, 120, 215, .3); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
[data-main-rotation="90"] { transform: rotate(90deg) translateY(-100%); }
[data-main-rotation="180"] { transform: rotate(180deg) translate(-100%, -100%); }
[data-main-rotation="270"] { transform: rotate(270deg) translateX(-100%); }

/* find bar */
.findbar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--window); border-bottom: 1px solid var(--border); flex: none; }
.findbar > .ic { color: var(--muted); margin-inline-end: 2px; }
.find-input { width: min(320px, 50vw); height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--base); }
.find-input:focus { outline: none; border-color: var(--accent); }
.find-status { color: var(--muted); padding: 0 6px; white-space: nowrap; }

/* ---------------------------------------------------------------- side panels */
.sidebar { width: 190px; flex: none; display: flex; flex-direction: column; background: var(--base); border-inline-end: 1px solid var(--border); min-height: 0; }
.side-tabs { display: flex; flex: none; border-bottom: 1px solid var(--border); }
.side-tab { flex: 1; border: 0; background: none; padding: 7px 6px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.side-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.thumbs { flex: 1; overflow-y: auto; padding: 10px 0 16px; outline: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.thumbs:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 6px 4px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; user-select: none; }
.thumb:hover { background: var(--alt); }
.thumb.selected { background: var(--accent-soft); }
.thumb.current .thumb-box { outline: 2px solid var(--accent); }
.thumb.drop-before { border-top-color: var(--brand); }
.thumb.drop-after { border-bottom-color: var(--brand); }
.thumb-box { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.thumb-box canvas { display: block; width: 100%; height: 100%; }
.thumb-no { font-size: 12px; color: var(--muted); }
.outline { flex: 1; overflow: auto; padding: 6px 4px; }
.outline ul { list-style: none; margin: 0; padding: 0; }
.outline ul ul { padding-inline-start: 14px; }
.mark-row { display: flex; align-items: center; }
.twisty { width: 18px; flex: none; border: 0; background: none; color: var(--muted); padding: 0; cursor: pointer; font-size: 11px; }
.mark { flex: 1; min-width: 0; text-align: start; border: 0; background: none; padding: 4px 4px; border-radius: 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark:hover { background: var(--accent-soft); }
.pad { padding: 10px; }

.textpanel { width: 360px; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--base); border-inline-start: 1px solid var(--border); min-height: 0; }
.textpanel header { display: flex; align-items: center; justify-content: space-between; }
.panel-title { margin: 0; font-size: 14px; font-weight: 600; }
.panel-sub { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.panel-text { flex: 1; min-height: 120px; resize: none; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--alt); line-height: 1.5; unicode-bidi: plaintext; }
.panel-text:focus { outline: none; border-color: var(--accent); }
.panel-buttons { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------------------------------------------------------- welcome */
.welcome { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; overflow: auto; background: var(--viewer); }
.welcome-card {
  width: min(500px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 32px 36px 26px;
  background: var(--base); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.welcome-card .logo { align-self: center; }
.welcome-card h1 { margin: 2px 0 0; text-align: center; font-size: 28px; font-weight: 600; }
.brand-bar { align-self: center; width: 56px; height: 4px; border-radius: 2px; background: var(--brand); }
.subtitle { margin: 4px 0 10px; text-align: center; color: var(--muted); font-size: 15px; }
.welcome-card p { margin: 0; }
.privacy { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin-top: 4px !important; border-radius: 8px; background: var(--alt); color: var(--muted); font-size: 12.5px; }
.privacy .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }

/* ---------------------------------------------------------------- status bar */
.statusbar { display: flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 8px; flex: none; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; background: var(--window); }
.status-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-page, .status-zoom { padding: 0 8px; white-space: nowrap; }

.drop-hint { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 136, 177, .12); border: 3px dashed var(--accent); pointer-events: none; }
.drop-hint > div { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 30px; border-radius: 12px; background: var(--base); box-shadow: var(--shadow); }
.drop-hint .ic { width: 36px; height: 36px; color: var(--accent); }
.drop-hint p { margin: 0; font-size: 15px; font-weight: 600; }

/* ---------------------------------------------------------------- buttons, dialogs, menus */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 14px; min-height: 32px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--base); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.big { min-height: 40px; font-size: 14.5px; }
.btn .ic { width: 18px; height: 18px; }

.dlg-back { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(10, 16, 22, .38); }
.dlg {
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column;
  background: var(--base); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.dlg.nudge { animation: nudge .25s; }
@keyframes nudge { 30% { transform: scale(1.015); } }
.dlg header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 4px 18px; }
.dlg h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dlg-x { display: inline-flex; border: 0; background: none; padding: 4px; border-radius: 5px; color: var(--muted); cursor: pointer; }
.dlg-x:hover { background: var(--alt); color: var(--text); }
.dlg-x .ic { width: 18px; height: 18px; }
.dlg-body { padding: 8px 18px 6px; overflow: auto; }
.dlg-body p { margin: 0 0 6px; }
.dlg-body h3 { margin: 8px 0 0; font-size: 13.5px; font-weight: 600; }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 16px; flex-wrap: wrap; }
.dlg-error { margin-top: 8px; padding: 7px 10px; border-radius: 6px; background: rgba(198, 40, 40, .1); color: var(--danger); }
.msg-main { font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.tight { gap: 4px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 120px; }
.form-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: start; }
.form-row > .form-label { padding-top: 5px; color: var(--text); }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; gap: 4px; } }
.dlg input[type="text"], .dlg input[type="password"], .dlg input[type="number"], .dlg select, .dlg textarea {
  min-height: 30px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--base); width: 100%;
}
.dlg input.num { width: 80px; }
.dlg input[type="color"] { width: 40px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 5px; background: var(--base); }
.dlg textarea { resize: vertical; line-height: 1.5; }
.dlg textarea.text-edit { min-height: 110px; unicode-bidi: plaintext; }
.dlg input:focus, .dlg select:focus, .dlg textarea:focus { outline: none; border-color: var(--accent); }
.dlg .inline input[type="text"] { width: auto; }
.radio, .check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.radio input, .check input { margin: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.indent { margin: -2px 0 4px !important; padding-inline-start: 23px; font-size: 12.5px; }
.merge-row { display: flex; gap: 10px; }
.file-list { flex: 1; list-style: none; margin: 0; padding: 4px; min-height: 200px; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--alt); }
.file-list li { display: flex; gap: 8px; padding: 6px 8px; border-radius: 5px; cursor: grab; }
.file-list li.sel { background: var(--accent-soft); }
.file-list li.drop { box-shadow: inset 0 2px 0 var(--brand); }
.file-list li.empty { cursor: default; }
.file-no { color: var(--muted); min-width: 18px; }
.file-name { overflow-wrap: anywhere; }
.side-buttons .btn { width: 100%; }
@media (max-width: 520px) { .merge-row { flex-direction: column; } }
.progress-text { margin: 4px 0 10px !important; }
.progress-bar { height: 8px; border-radius: 4px; background: var(--alt); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 2%; background: var(--accent); border-radius: 4px; transition: width .2s; }
.progress-bar.busy .progress-fill { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
[dir="rtl"] .progress-bar.busy .progress-fill { animation-name: slide-rtl; }
@keyframes slide-rtl { from { transform: translateX(100%); } to { transform: translateX(-290%); } }
.about { text-align: center; }
.about .logo { justify-content: center; margin: 4px auto 0; }
.about h3 { font-size: 17px; }

.menu {
  position: fixed; z-index: 200; min-width: 220px; max-width: calc(100vw - 8px); max-height: calc(100vh - 8px); overflow: auto; padding: 4px;
  background: var(--base); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.menu-item {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 12px 6px 8px;
  border: 0; border-radius: 5px; background: none; text-align: start; cursor: pointer; white-space: nowrap;
}
.menu-item:hover:not(:disabled), .menu-item:focus { background: var(--accent-soft); outline: none; }
.menu-item:disabled { color: var(--icon-off); cursor: default; }
.mi-icon { display: inline-flex; color: var(--icon); }
.menu-item:disabled .mi-icon { color: var(--icon-off); }
.mi-icon .ic { width: 17px; height: 17px; }
.mi-key { color: var(--muted); font-size: 12px; padding-inline-start: 18px; }
.menu .sep { height: 1px; margin: 4px 8px; background: var(--border); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 760px) {
  .brand span { display: none; }
  .sidebar { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 20; box-shadow: var(--shadow); }
  .textpanel { position: absolute; inset-block: 0; inset-inline-end: 0; z-index: 20; width: min(360px, 92vw); box-shadow: var(--shadow); }
  .tb.under { min-width: 46px; }
  .tb-text { font-size: 11px; }
  .main-toolbar .tb.primary .tb-text { display: none; }
  .zoom-select { width: 84px; }
  .tab { min-width: 90px; }
}

/* ---------------------------------------------------------------- printing: only the document's pages */
#print-pages { display: none; }
@media print {
  @page { margin: 0; }
  html, body { height: auto; overflow: visible; background: #fff; display: block; }
  body > *:not(#print-pages) { display: none !important; }
  #print-pages { display: block; }
  .print-page { break-after: page; page-break-after: always; display: flex; align-items: center; justify-content: center; height: 100vh; overflow: hidden; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page img { max-width: 100%; max-height: 100vh; object-fit: contain; }
}

/* ---------------------------------------------------------------- signatures, stamps, crop, count */
.ghost { position: absolute; opacity: .6; pointer-events: none; outline: 1px dashed var(--accent); }
.band-crop { border-color: var(--accent); background: none; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .42); }
.overlay { overflow: hidden; }
.band-count { border-color: #E53935; background: rgba(229, 57, 53, .08); }
.band-sign, .band-stamp { border-color: var(--accent); background: none; }
.count-mark { position: absolute; border: 1.6px solid var(--mark); background: color-mix(in srgb, var(--mark) 15%, transparent); pointer-events: none; border-radius: 1px; }
.count-mark[data-label]::before {
  content: attr(data-label); position: absolute; bottom: 100%; inset-inline-start: -1.6px; padding: 0 3px;
  background: var(--mark); color: #fff; font: 600 10px/13px "Segoe UI", system-ui, sans-serif; border-radius: 2px 2px 0 0; white-space: nowrap;
}
.scroller[data-tool="sign"] .overlay, .scroller[data-tool="stamp"] .overlay,
.scroller[data-tool="crop"] .overlay, .scroller[data-tool="count"] .overlay { cursor: crosshair; }
.side-tab .ic { width: 18px; height: 18px; vertical-align: middle; }

/* sidebar: comments */
.comments { flex: 1; overflow: auto; padding: 4px 6px 12px; }
.comment-page { margin: 10px 4px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.comment { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.comment:hover, .comment:focus-visible { background: var(--accent-soft); border-color: var(--accent); outline: none; }
.comment-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 12.5px; }
.comment-text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.pad { padding: 8px; margin: 0; }

/* count results panel */
.countpanel { width: 320px; }
.count-tree { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--alt); padding: 4px; }
.count-group { border-radius: 6px; }
.count-group.current { background: var(--accent-soft); }
.count-group > summary { display: flex; align-items: center; gap: 8px; padding: 6px; cursor: pointer; font-weight: 600; list-style-position: inside; }
.count-group .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.count-page { display: flex; justify-content: space-between; padding: 4px 10px 2px 28px; color: var(--muted); font-size: 12px; }
.count-item { display: flex; align-items: center; gap: 6px; padding: 1px 10px 1px 34px; font-size: 12.5px; cursor: pointer; }
.count-item input { accent-color: var(--accent); }
.count-item-text:hover { color: var(--accent); text-decoration: underline; }
.grow { flex: 1; min-width: 0; }

/* dialogs */
.mini-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mini-tab { border: 0; background: none; padding: 6px 12px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.mini-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.sign-wrap { position: relative; }
.sign-pad { width: 100%; height: auto; aspect-ratio: 960 / 380; background: #fff; border: 1px solid var(--border); border-radius: 6px; touch-action: none; cursor: crosshair; display: block; }
.sign-hint { position: absolute; inset-inline-start: 12px; bottom: 26%; pointer-events: none; border-top: 1px dashed #aaa; width: calc(100% - 24px); padding-top: 2px; font-size: 11px; color: #999; }
.mark-preview { min-height: 120px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.mark-preview p { color: #666; text-align: center; margin: 0; }
.mark-canvas { max-width: 100%; max-height: 160px; }
.mark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 300px; overflow: auto; }
.mark-item { position: relative; background: #fff; border: 2px solid var(--border); border-radius: 6px; height: 90px; display: flex; align-items: center; justify-content: center; padding: 6px; cursor: pointer; }
.mark-item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.mark-item img { max-width: 100%; max-height: 100%; }
.mark-del { position: absolute; top: 2px; inset-inline-end: 2px; border: 0; background: rgba(255, 255, 255, .85); border-radius: 4px; padding: 1px; cursor: pointer; color: #333; }
.mark-del .ic { width: 14px; height: 14px; }
.margin-grid { display: grid; grid-template-columns: auto auto; gap: 6px 10px; align-items: center; justify-content: start; }
.num { width: 80px; }
.num-out { min-width: 3em; text-align: end; }
.blank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 340px; overflow: auto; padding: 4px; background: var(--alt); border-radius: 6px; min-height: 60px; }
.blank-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.blank-item img { max-width: 120px; max-height: 150px; background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.bm-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.bm-table { width: 100%; border-collapse: collapse; }
.bm-table th { position: sticky; top: 0; background: var(--alt); text-align: start; font-weight: 600; padding: 6px; font-size: 12px; }
.bm-table td { padding: 3px 6px; border-top: 1px solid var(--border); }
.bm-table td:nth-child(2) { width: 100%; }
.bm-table input[type="text"] { width: 100%; }
@media (max-width: 760px) { .countpanel { position: absolute; inset-block: 0; inset-inline-end: 0; z-index: 20; width: min(340px, 92vw); box-shadow: var(--shadow); } }
.panel-buttons.start { justify-content: flex-start; flex-wrap: wrap; }

/* ---------------------------------------------------------------- forms, measuring, view modes */
/* Opaque: the field's own appearance on the page would otherwise show through twice. */
.pdf-field { position: absolute; box-sizing: border-box; margin: 0; padding: 0 3px; border: 1px solid rgba(0, 110, 200, .45);
  background: #EAF2FF; color: #000; font-family: Arial, Helvetica, sans-serif; border-radius: 2px; pointer-events: auto; }
.pdf-field:focus { outline: 2px solid var(--accent); background: rgba(255, 255, 255, .95); }
textarea.pdf-field { resize: none; padding-top: 2px; }
.pdf-check { appearance: auto; accent-color: #1565C0; padding: 0; }
.pdf-sig { position: absolute; border: 1.5px dashed #2E7D32; background: rgba(46, 125, 50, .07); pointer-events: auto; cursor: help; }
.measure-svg, .poly-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.measure-label { font: 600 12px "Segoe UI", system-ui, sans-serif; paint-order: stroke; stroke: #fff; stroke-width: 3px; text-anchor: middle; }
.scroller[data-tool="measure"] .overlay, .scroller[data-tool="calibrate"] .overlay,
.scroller[data-tool="line"] .overlay, .scroller[data-tool="arrow"] .overlay, .scroller[data-tool="ellipse"] .overlay,
.scroller[data-tool="textbox"] .overlay { cursor: crosshair; }
.band-ellipse { border-radius: 50%; border-style: solid; border-color: #E53935; background: none; }
.band-textbox { border-style: solid; border-color: #1E3A5F; background: rgba(255, 255, 255, .6); }
.pages.spread { display: grid; grid-template-columns: repeat(2, max-content); justify-content: center; align-items: start; }
.docs.night .canvas-box canvas, .docs.night .thumb-box canvas { filter: invert(1) hue-rotate(180deg); }
.docs.night .page { background: #111; }
.docs.split { display: flex; }
.docs.split .doc-pane { position: relative; inset: auto; flex: 1; min-width: 0; }
.docs.split .doc-pane.split-partner { border-inline-start: 2px solid var(--border); }
.scroller:fullscreen { background: #111; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
