/* Add Dots PDF — Pro feature styles (annotate, organize, forms, document ops)
   Loads after app.css and reuses its variables, so the reading themes,
   the mobile layout and the dark chrome all carry over unchanged. */

/* ---------------------------------------------------------------
   Annotate & comment
   --------------------------------------------------------------- */

/* Text-markup tools read from the text layer, so the capture layer that
   the drawing tools rely on has to get out of the way. */
body[data-tool="highlight"] .capture,
body[data-tool="underline"] .capture,
body[data-tool="strike"]    .capture { display: none }

body[data-tool="highlight"] .textLayer,
body[data-tool="underline"] .textLayer,
body[data-tool="strike"]    .textLayer {
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
/* the drag shows the colour that is about to be applied */
body[data-tool="highlight"] .textLayer ::selection,
body[data-tool="underline"] .textLayer ::selection,
body[data-tool="strike"]    .textLayer ::selection {
  background: var(--mk-sel, #F2C14E);
  opacity: .5;
}

body[data-tool="ink"]   .capture { cursor: crosshair }
body[data-tool="note"]  .capture { cursor: copy }
body[data-tool="stamp"] .capture { cursor: cell }

/* marks stay clickable in Read mode so a comment can be opened from the page */
body[data-tool="select"] .anno .mk *,
body[data-tool="select"] .anno .note-mk,
body[data-tool="select"] .anno .stamp-mk { pointer-events: all }
.anno .note-mk:hover  { filter: brightness(1.12) }
.anno .stamp-mk:hover { filter: brightness(1.12) }

/* --- mode-bar extras --- */
.anno-ctl { display: flex; align-items: center; gap: 6px }
.anno-ctl[hidden], .anno-ctl [hidden] { display: none }
.anno-lbl {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim);
}
.anno-sw { gap: 5px }
.anno-sw .sw {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  cursor: pointer; padding: 0;
}
.anno-sw .sw.on {
  box-shadow: 0 0 0 2px var(--chrome), 0 0 0 4px var(--marker);
}

/* --- stamps made from a picture of your own: the strip beside the picker.
   Each one shows as a thumbnail on a light backing, since a stamp's ink is
   almost always dark and would vanish against the chrome. --- */
.stampimgs { display: flex; align-items: center; gap: 5px }
.stampimgs:empty { display: none }
.stampimg { position: relative; display: block; line-height: 0 }
.stampimg .pick {
  display: grid; place-items: center; cursor: pointer;
  width: 34px; height: 26px; padding: 2px;
  background: #EFEFF2; border: 1px solid var(--line); border-radius: 5px;
}
.stampimg .pick img { max-width: 100%; max-height: 100%; object-fit: contain }
.stampimg.on .pick {
  border-color: var(--marker);
  box-shadow: 0 0 0 2px var(--chrome), 0 0 0 3px var(--marker);
}
.stampimg .x {
  position: absolute; top: -6px; right: -6px;
  width: 15px; height: 15px; padding: 0; border: 1px solid var(--line);
  border-radius: 50%; cursor: pointer;
  background: var(--chrome-2); color: var(--text-dim);
  font-size: 11px; line-height: 1; opacity: 0; transition: opacity .12s;
}
.stampimg:hover .x, .stampimg .x:focus-visible { opacity: 1 }
.stampimg .x:hover { color: var(--text); border-color: var(--text-dim) }
/* a picture stamp is in hand: the list of worded ones steps back */
#stampK.off { opacity: .45 }

/* --- comment thread popover --- */
.cthread {
  position: fixed; z-index: 90; width: 310px; max-width: calc(100vw - 24px);
  background: var(--chrome-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
  padding: 10px; color: var(--text); font-size: 13px;
  display: flex; flex-direction: column; gap: 8px;
}
.cthread[hidden] { display: none }
.cthread.resolved { opacity: .82 }
.cthread header { display: flex; align-items: center; gap: 8px; font-size: 12px }
.cthread header .grow { flex: 1 }
.cthread .lnk {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 12px; padding: 2px 4px; border-radius: 4px;
}
.cthread .lnk:hover { color: var(--text); background: rgba(255,255,255,.07) }
.cthread .lnk.del:hover { color: var(--danger) }
.cthread .x {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 2px;
}
.cthread .x:hover { color: var(--text) }
.cthread .cq, .citem blockquote {
  margin: 0; padding: 6px 9px; border-left: 2px solid var(--line);
  color: var(--text-dim); font-style: italic; font-size: 12px;
  max-height: 84px; overflow: auto;
}
.cthread textarea {
  width: 100%; resize: vertical; min-height: 58px;
  background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px;
  font: inherit;
}
.cthread textarea:focus { outline: none; border-color: var(--text-dim) }
.creplies { display: flex; flex-direction: column; gap: 5px }
.crep {
  display: flex; align-items: flex-start; gap: 6px;
  background: rgba(255,255,255,.04); border-radius: 6px; padding: 5px 7px;
}
.crep p { margin: 0; flex: 1; font-size: 12px; white-space: pre-wrap; word-break: break-word }
.cacts { display: flex; gap: 6px }
.cacts input {
  flex: 1; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font: inherit;
}
.cacts input:focus { outline: none; border-color: var(--text-dim) }

/* --- comments rail --- */
.cbar { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line) }
.cbar select {
  flex: 1; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; font: inherit; font-size: 12px;
}
.ccount { padding: 7px 10px; font-size: 12px; color: var(--text-dim) }
.cempty { padding: 18px 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.6 }
.citem {
  padding: 9px 11px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; gap: 5px;
}
.citem:hover { background: rgba(255,255,255,.045) }
.citem.done { opacity: .55 }
.citem.done p { text-decoration: line-through }
.citem header { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim) }
.citem .dot { width: 9px; height: 9px; border-radius: 50%; flex: none }
.citem .pg { margin-left: auto }
.citem p { margin: 0; font-size: 12.5px; line-height: 1.45; word-break: break-word }
.citem p.muted { color: var(--text-dim); font-style: italic }
.citem .reps { font-size: 11px; color: var(--text-dim) }

/* ---------------------------------------------------------------
   Organize & combine
   --------------------------------------------------------------- */

/* drop marker for both the sidebar column and the Organize grid */
.thumb.dragging, .orgcell.dragging { opacity: .35 }
.thumb { position: relative }
.thumb.drop-before::before, .thumb.drop-after::after,
.orgcell.drop-before::before, .orgcell.drop-after::after {
  content: ''; position: absolute; background: var(--marker); border-radius: 2px; z-index: 5;
}
.thumb.drop-before::before { left: 6px; right: 6px; top: -2px; height: 3px }
.thumb.drop-after::after   { left: 6px; right: 6px; bottom: -2px; height: 3px }
.orgcell.drop-before::before { top: 4px; bottom: 4px; left: -3px; width: 3px }
.orgcell.drop-after::after   { top: 4px; bottom: 4px; right: -3px; width: 3px }
.thumb[draggable="true"] .hitbox { cursor: grab }
.thumb[draggable="true"]:active .hitbox { cursor: grabbing }

/* --- Organize Pages --- */
.orgview {
  position: fixed; inset: 0; z-index: 70;
  background: var(--chrome); color: var(--text);
  display: flex; flex-direction: column;
}
.orgview[hidden] { display: none }
.orgview > header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--chrome-2);
}
.orgview > header .grow { flex: 1 }
.orgview > header .sep { width: 1px; height: 20px; background: var(--line) }
.orgcount { font-size: 12px; color: var(--text-dim) }
.orghint { margin: 0; padding: 8px 14px; font-size: 12px; color: var(--text-dim) }
.orggrid {
  flex: 1; overflow: auto; padding: 8px 14px 24px;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start;
}
.orgcell {
  margin: 0; position: relative; cursor: grab;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.orgcell:active { cursor: grabbing }
.orgshell {
  width: 100%; aspect-ratio: 1 / 1.35;
  background: var(--stage); border: 1px solid var(--line); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.orgshell canvas { max-width: 100%; max-height: 100%; display: block }
.orgshell.pending { background: repeating-linear-gradient(45deg, #1a1a1a 0 8px, #1f1f1f 8px 16px) }
.orgcell figcaption { font-size: 11.5px; color: var(--text-dim) }
.orgcell figcaption.isnew { color: var(--marker-ink) }
.orgcell.picked .orgshell { border-color: var(--marker); box-shadow: 0 0 0 2px var(--marker) }
.orgcell.picked figcaption { color: var(--text) }
.orgview .btn.del:hover:not(:disabled) { color: var(--danger); border-color: var(--danger) }
.orgview .btn:disabled { opacity: .4; cursor: default }
body.organizing { overflow: hidden }

/* --- split popover extras --- */
#splitPop .row { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-size: 13px }
#splitPop .mini {
  width: 48px; text-align: center; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 4px; font: inherit;
}
#splitPop .note { margin: 8px 0 2px; font-size: 12px; color: var(--text-dim) }

/* ---------------------------------------------------------------
   Forms & signatures
   --------------------------------------------------------------- */

.formlayer { position: absolute; inset: 0; z-index: 4; pointer-events: none }
.formlayer[hidden] { display: none }
.ffield {
  position: absolute; pointer-events: auto; box-sizing: border-box;
  font-family: inherit; color: #0B0B0B;
  background: rgba(123,92,255,.14);
  border: 1px solid rgba(123,92,255,.55); border-radius: 2px;
  padding: 0 3px; margin: 0;
}
.ffield:hover  { background: rgba(123,92,255,.24) }
.ffield:focus  { outline: 2px solid #7B5CFF; outline-offset: 0; background: rgba(255,255,255,.92) }
.ffield:disabled { background: rgba(140,140,140,.16); border-style: dashed; cursor: not-allowed }
textarea.ffield { resize: none; line-height: 1.25; padding: 2px 3px }
select.ffield { padding: 0 2px }
input.ffield[type="checkbox"], input.ffield[type="radio"] {
  padding: 0; accent-color: #7B5CFF; cursor: pointer;
}
.ffield.sigslot {
  background: rgba(242,193,78,.24); border: 1px dashed #B98A18;
  color: #6B4E06; font-size: 11px; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.ffield.sigslot:hover { background: rgba(242,193,78,.42) }
/* the fields belong to the page, so they hide while a drawing tool is live */
body:not([data-tool="select"]) .formlayer { display: none }

/* --- signature modal --- */
.sigmodal {
  position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.sigmodal[hidden] { display: none }
.sigbox {
  width: min(660px, 100%); max-height: calc(100vh - 36px); overflow: auto;
  background: var(--chrome-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6); color: var(--text);
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
}
.sigbox header { display: flex; align-items: center; gap: 8px }
.sigbox header .grow { flex: 1 }
.sigbox .x {
  background: none; border: 0; color: var(--text-dim); font-size: 22px;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.sigbox .x:hover { color: var(--text) }
.sigtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 8px }
.sigtabs button {
  background: none; border: 1px solid transparent; color: var(--text-dim);
  padding: 6px 14px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px;
}
.sigtabs button:hover { color: var(--text) }
.sigtabs button.on { color: var(--text); background: rgba(255,255,255,.08); border-color: var(--line) }
.sigpane { display: flex; flex-direction: column; gap: 9px }
.sigpane[hidden] { display: none }
#sigCanvas {
  width: 100%; height: 200px; background: #FFFFFF; border-radius: 8px;
  border: 1px solid var(--line); touch-action: none; cursor: crosshair;
  background-image: linear-gradient(to right, transparent 0 24px, rgba(0,0,0,.07) 24px 25px, transparent 25px),
                    linear-gradient(to top, transparent 0 46px, rgba(0,0,0,.14) 46px 47px, transparent 47px);
}
.sighint { margin: 0; font-size: 12px; color: var(--text-dim) }
#sigName, #sigFile {
  background: var(--stage); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 10px; font: inherit; width: 100%;
}
#sigName:focus { outline: none; border-color: var(--text-dim) }
.sigfonts { display: flex; gap: 8px; flex-wrap: wrap; color: #1B2A4A }
.sigfonts button {
  flex: 1; min-width: 150px; background: #FFFFFF; color: inherit;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 10px;
  font-size: 26px; cursor: pointer; line-height: 1.1;
}
.sigfonts button.on { box-shadow: 0 0 0 2px var(--marker) }
.sigprev { min-height: 70px; display: flex; align-items: center; justify-content: center }
.sigprev img { max-width: 100%; max-height: 150px; border-radius: 6px; padding: 6px;
  /* a checkerboard, so a see-through background shows as one */
  background: #FFF conic-gradient(#E6E8EC 25%, #FFF 0 50%, #E6E8EC 0 75%, #FFF 0) 0 0 / 14px 14px }
.sigcolors { display: flex; align-items: center; gap: 7px }
.sigcolors .sw {
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 1px solid rgba(255,255,255,.3); cursor: pointer;
}
.sigcolors .sw.on { box-shadow: 0 0 0 2px var(--chrome-2), 0 0 0 4px var(--marker) }
.sigbox footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.sigbox footer .grow { flex: 1 }
.sigsave { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim) }
.sigbox .btn:disabled { opacity: .45; cursor: default }

/* ---------------------------------------------------------------
   Insert: crop-image modal (reuses .sigmodal/.sigbox chrome)
   --------------------------------------------------------------- */
#cropStage { position: relative; max-height: 60vh; overflow: hidden; display: flex;
             align-items: center; justify-content: center; background: #0D0D0D; border-radius: 8px; touch-action: none }
#cropStage img { display: block; max-width: 100%; max-height: 60vh; user-select: none; pointer-events: none }
#cropBox { position: absolute; border: 2px solid var(--marker); box-shadow: 0 0 0 2000px rgba(0,0,0,.55); cursor: move }
#cropBox i { position: absolute; width: 14px; height: 14px; background: var(--marker); border-radius: 3px; display: block }
#cropBox i.tl { left: -7px; top: -7px; cursor: nwse-resize }
#cropBox i.tr { right: -7px; top: -7px; cursor: nesw-resize }
#cropBox i.bl { left: -7px; bottom: -7px; cursor: nesw-resize }
#cropBox i.br { right: -7px; bottom: -7px; cursor: nwse-resize }

/* ---------------------------------------------------------------
   Insert: editable table overlay (mirrors .texted)
   --------------------------------------------------------------- */
.tabled { position: absolute; z-index: 6; box-sizing: border-box }
.tabled table { border-collapse: collapse; width: 100%; table-layout: fixed;
                background: rgba(255,255,255,.96); outline: 2px solid var(--marker); outline-offset: 0 }
.tabled td { border: 1px solid #8A8F98; padding: 0 4px; color: #1C1F24; font-family: Helvetica, Arial, sans-serif;
             white-space: nowrap; overflow: hidden; vertical-align: middle; cursor: text; outline: none }
.tabled td:focus { background: rgba(123,92,255,.10); box-shadow: inset 0 0 0 2px #7B5CFF }
.tabled .tbar { display: flex; gap: 4px; align-items: center; margin-top: 6px; padding: 4px;
                background: var(--chrome); border: 1px solid var(--line); border-radius: 7px;
                box-shadow: 0 6px 18px rgba(0,0,0,.18); width: max-content; min-width: 100% }
.tabled .tbar .grow { flex: 1 }
.tabled .tbar button { height: 26px; padding: 0 9px; border-radius: 5px; border: 1px solid var(--line);
                       background: var(--chrome-2); color: var(--text); font-size: 11.5px; cursor: pointer; white-space: nowrap }
.tabled .tbar .ok { background: var(--pri-bg); color: var(--pri-ink); border-color: transparent; font-weight: 700 }

/* ---------------------------------------------------------------
   Document operations
   --------------------------------------------------------------- */

body[data-tool="redact"] .capture { cursor: crosshair }
.redact-mk { fill: #000; stroke: #E2483D; stroke-width: 1.5; stroke-dasharray: 4 3 }
body[data-tool="select"] .anno .redact-mk { cursor: move }
.wm-mk text { pointer-events: none; user-select: none }

/* --- shared modal for the document jobs --- */
.docmodal {
  position: fixed; inset: 0; z-index: 92; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.docmodal[hidden] { display: none }
.docbox {
  width: min(560px, 100%); max-height: calc(100vh - 36px);
  background: var(--chrome-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6); color: var(--text);
  display: flex; flex-direction: column;
}
.docbox header, .docbox footer {
  display: flex; align-items: center; gap: 9px; padding: 12px 14px;
}
.docbox header { border-bottom: 1px solid var(--line) }
.docbox footer { border-top: 1px solid var(--line); flex-wrap: wrap }
.docbox .grow { flex: 1 }
.docbox .x {
  background: none; border: 0; color: var(--text-dim); font-size: 22px;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.docbox .x:hover { color: var(--text) }
.docbody { padding: 12px 14px; overflow: auto; display: flex; flex-direction: column; gap: 9px }
/* Combine Files, from Explorer (js/desktop.js): the files in the order joined */
.cmbbox .cmbnote { margin: 0; font-size: 13px; color: var(--text-dim) }
.cmbbox .cmblist { margin: 0; padding: 0; list-style: none; counter-reset: cmb; display: flex; flex-direction: column; gap: 4px }
.cmbbox .cmblist li {
  counter-increment: cmb; display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--stage); font-size: 13px
}
.cmbbox .cmblist li::before { content: counter(cmb); width: 22px; flex: none; color: var(--text-dim); font-variant-numeric: tabular-nums }
.cmbbox .cmbname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.cmbbox .cmblist .btn { width: 30px; height: 28px; min-width: 30px; padding: 0; justify-content: center; flex: none }
.drow { display: flex; align-items: center; gap: 10px; font-size: 13px }
.drow > span:first-child { width: 96px; flex: none; color: var(--text-dim) }
.drow input:not([type="checkbox"]):not([type="range"]):not([type="color"]),
.drow select {
  flex: 1; min-width: 0; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font: inherit; font-size: 13px;
}
.drow input:focus, .drow select:focus { outline: none; border-color: var(--text-dim) }
.drow input[type="color"] {
  width: 46px; height: 30px; padding: 2px; background: var(--stage);
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.drow input[type="range"] { flex: 1; accent-color: var(--marker) }
.drow output { width: 44px; text-align: right; font-size: 12px; color: var(--text-dim) }
.dhint { font-size: 12px; color: var(--text-dim); margin: 0 }
.dhint.block { line-height: 1.55; padding: 8px 10px; background: rgba(255,255,255,.04); border-radius: 7px }
.dgrid3 {
  display: grid; grid-template-columns: 96px repeat(3, 1fr); gap: 7px; align-items: center;
}
.dgrid3 .dlab { font-size: 13px; color: var(--text-dim) }
.dgrid3 input {
  min-width: 0; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px; font: inherit; font-size: 12.5px;
}
.dgrid3 input:focus { outline: none; border-color: var(--text-dim) }
.dfacts {
  margin-top: 4px; border-top: 1px solid var(--line); padding-top: 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.dfact { display: flex; gap: 12px; font-size: 12.5px; align-items: baseline }
.dfact > span { width: 96px; flex: none; color: var(--text-dim) }
.dfact > b { flex: 1; font-weight: 500; word-break: break-word }
.docnote { font-size: 12px; color: var(--text-dim) }
.docnote .bad { color: var(--danger) }
.docbox .btn:disabled { opacity: .45; cursor: default }

/* --- loading / fatal splash --- */
.shsplash {
  position: fixed; inset: 0; z-index: 96; background: var(--chrome);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--text); text-align: center; padding: 24px;
}
.shsplash[hidden] { display: none }
.shsplash p { margin: 0; color: var(--text-dim) }
.shspin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--marker);
  animation: shspin 0.9s linear infinite;
}
@keyframes shspin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .shspin { animation-duration: 3s } }
.shfatal { max-width: 420px; display: flex; flex-direction: column; gap: 12px; align-items: center }
.shfatal h2 { margin: 0; font-size: 18px }
.shfatal p { color: var(--text-dim) }

/* --- review rail --- */
.rcbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-dim);
}
.rcbar .grow { flex: 1 }
.rcname {
  width: 108px; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px;
  font: inherit; font-size: 11.5px;
}
.rcview { font-size: 11px; text-transform: uppercase; letter-spacing: .04em }
.rcnew { display: flex; gap: 6px; padding: 9px 10px; border-bottom: 1px solid var(--line) }
.rcnew textarea {
  flex: 1; resize: vertical; background: var(--stage); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 12.5px;
}
.rcnew textarea:focus { outline: none; border-color: var(--text-dim) }
.rclist { display: flex; flex-direction: column }
.rcitem {
  padding: 9px 11px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; gap: 5px;
}
.rcitem:hover { background: rgba(255,255,255,.045) }
.rcitem.done { opacity: .58 }
.rcitem.flash { background: rgba(242,193,78,.18) }
.rcitem header { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim) }
.rcitem .dot { width: 9px; height: 9px; border-radius: 50%; flex: none }
.rcitem .pg { margin-left: auto }
.rcitem blockquote {
  margin: 0; padding: 5px 8px; border-left: 2px solid var(--line);
  font-style: italic; font-size: 11.5px; color: var(--text-dim);
}
.rcitem p { margin: 0; font-size: 12.5px; line-height: 1.45; word-break: break-word }
.rcrep {
  font-size: 11.5px; color: var(--text-dim); padding: 4px 7px;
  background: rgba(255,255,255,.04); border-radius: 6px;
}
.rcitem footer { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--text-dim) }
.rcitem footer .lnk {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 11px; padding: 1px 3px; border-radius: 4px;
}
.rcitem footer .lnk:hover { color: var(--text); background: rgba(255,255,255,.07) }
.rcitem footer .when { margin-left: auto }
.remote-mk.done { opacity: .6 }

/* ---------------------------------------------------------------
   Pan (hand tool)
   --------------------------------------------------------------- */

body[data-tool="pan"] .capture { cursor: grab }
body[data-tool="pan"].panning .capture { cursor: grabbing }
/* the whole window follows, so the cursor does not flicker when a fast drag
   runs off the edge of the page */
body.panning, body.panning * { cursor: grabbing !important }
/* text would otherwise select as the hand sweeps across the page */
body[data-tool="pan"] .textLayer { pointer-events: none; user-select: none }
body[data-tool="pan"] .stage { scroll-behavior: auto }

/* Drag zoom: the box being dragged round the part to enlarge */
body[data-tool="zoombox"] .capture { cursor: zoom-in }
body[data-tool="zoombox"] .textLayer { pointer-events: none; user-select: none }
body[data-tool="zoombox"] .stage { scroll-behavior: auto }
.zoombox {
  position: fixed; z-index: 60; pointer-events: none;
  border: 1.5px dashed #7357FF; background: rgba(115, 87, 255, .12); border-radius: 2px;
}

/* The free float. Panning past the end of the scroller lands here, which is
   what lets the page be dragged anywhere on screen instead of stopping at the
   edge of its own content. A transform does not move offsetTop, so core's
   scroll maths and lazy rendering are untouched by it. */
#stage > .pagebox {
  transform: translate(var(--pan-x, 0px), var(--pan-y, 0px));
}
/* promote only while a drag is actually happening — a compositing layer per
   page would otherwise cost real memory on a long document */
body.panning #stage > .pagebox { will-change: transform }
/* the drag sets the scroll position every move: animated, it trails the hand */
body.panning #stage, body.midpan #stage { scroll-behavior: auto }
/* the journey back is worth animating; the drag itself must not be */
#stage.pan-ease > .pagebox { transition: transform .2s ease-out }
@media (prefers-reduced-motion: reduce) {
  #stage.pan-ease > .pagebox { transition: none }
}
/* Middle-drag pans from any tool, so the grab cursor has to win over
   whatever that tool was showing. */
body.midpan, body.midpan * { cursor: grabbing !important }

/* ---------------------------------------------------------------
   Rulers and guides (js/rulers.js)
   --------------------------------------------------------------- */

/* the page area gives itself a border for the rulers to sit in, so they
   never cover the page */
body.rulers-on #stage { border-top: 18px solid var(--chrome); border-left: 18px solid var(--chrome) }
.ruler, .rcorner { position: fixed; z-index: 30 }
.ruler[hidden], .rcorner[hidden], .rghost[hidden] { display: none }
.ruler.rtop { cursor: row-resize; touch-action: none }
.ruler.rleft { cursor: col-resize; touch-action: none }
.rcorner {
  width: 18px; height: 18px; padding: 0; border: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--chrome); color: var(--text-dim);
  font: 600 8px/1 var(--sans); cursor: crosshair; touch-action: none;
}
.rcorner:hover, .rcorner[aria-expanded="true"] { color: var(--marker-ink) }

/* a guide: a thin line on its page, with a wider strip to catch the pointer */
.guides { position: absolute; inset: 0; z-index: 5; pointer-events: none }
body:not(.rulers-on) .guides { display: none }
.guide { position: absolute; pointer-events: auto }
/* with a drawing tool in hand the guides are for snapping to, not for grabbing */
body:not([data-tool="select"]) .guide { pointer-events: none }
.guide.gh { left: 0; right: 0; height: 7px; margin-top: -3px; cursor: row-resize }
.guide.gv { top: 0; bottom: 0; width: 7px; margin-left: -3px; cursor: col-resize }
.guide::after, .rghost::after { content: ""; position: absolute; background: #00B8D9 }
.guide.gh::after { left: 0; right: 0; top: 3px; height: 1px }
.guide.gv::after { top: 0; bottom: 0; left: 3px; width: 1px }
.guide[hidden] { display: none }

/* the line that follows the pointer while a guide is dragged */
.rghost { position: fixed; z-index: 31; pointer-events: none }
.rghost.gh { height: 1px }
.rghost.gv { width: 1px }
.rghost.gh::after { inset: 0 }
.rghost.gv::after { inset: 0 }
body.rdrag-h, body.rdrag-h * { cursor: row-resize !important }
body.rdrag-v, body.rdrag-v * { cursor: col-resize !important }
body.rdrag-zero, body.rdrag-zero * { cursor: crosshair !important }
body.rdrag { user-select: none; -webkit-user-select: none }

/* the corner's menu: units, the zero point and clearing guides */
.rmenu {
  position: fixed; z-index: 400; min-width: 200px; padding: 4px;
  background: var(--chrome); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-pop, 0 8px 24px rgba(0, 0, 0, .35)); font: 13px/1.2 var(--sans);
}
.rmenu button {
  display: block; width: 100%; padding: 7px 10px 7px 26px; border: 0; border-radius: 5px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; position: relative;
}
.rmenu button:hover:not(:disabled), .rmenu button:focus-visible { background: var(--hover, rgba(127, 127, 127, .12)) }
.rmenu button:disabled { color: var(--text-dim); cursor: default; opacity: .6 }
.rmenu button[aria-checked="true"]::before { content: "\2713"; position: absolute; left: 9px; color: var(--marker-ink) }
.rmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px }

/* ---------------------------------------------------------------
   Toolbar arrangement, touch targets and the phone dock
   --------------------------------------------------------------- */

/* dividers between the tool groups */
.tsep {
  flex: none; align-self: center;
  width: 1px; height: 30px; margin: 0 5px;
  background: var(--line);
}
.ribbon .tsep { height: 34px; margin: 0 7px }

/* --- fingers need bigger targets than a mouse, at every width --- */
@media (pointer: coarse) {
  .btn { min-height: 44px; min-width: 44px }
  .ribbon .btn { min-height: 52px; min-width: 60px }
  .txctl select, .txctl input, .txctl .tg,
  .drow select, .drow input, .cbar select { min-height: 38px }
  .anno-sw .sw, .sigcolors .sw { width: 28px; height: 28px }
  .cthread .lnk, .rcitem footer .lnk { padding: 7px 8px }
  .docbox .btn { min-height: 40px }
  /* hover-only affordances have to be permanently visible on a touch screen */
  .thumb .tools, .ptools, .stampimg .x { opacity: 1 }
  .stampimg .pick { width: 42px; height: 34px }
}

/* --- the phone dock --- */
@media (max-width: 760px) {
  /* It used to divide the width between every tool, which gave 17 of them
     20px each. Scroll instead, and keep each target the size of a fingertip. */
  .dock {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-padding-inline: 12px;
  }
  .dock::-webkit-scrollbar { display: none }

  .dock[data-crowded="yes"] .grp { width: auto; justify-content: flex-start }
  .dock[data-crowded="yes"] .btn {
    flex: 0 0 auto;
    min-width: 58px;
    scroll-snap-align: center;
  }
  .dock[data-crowded="yes"] { scroll-snap-type: x proximity }

  .dock .btn::after {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .dock .tsep { height: 30px; margin: 0 4px }

  /* a hint that there is more to the side. In flow at the foot of the app's
     column, so it must not shrink: a long document squeezed it to a sliver */
  .dock { position: relative; flex: none }
  .dock[data-crowded="yes"]::after {
    content: ''; position: sticky; right: 0; flex: none;
    width: 18px; height: 48px; margin-left: -18px; pointer-events: none;
    background: linear-gradient(to right, transparent, var(--chrome));
  }

  /* The sheet's own two-column list from app.css is the right shape for this,
     so leave it alone — it already scrolls at 80dvh. All that is needed is a
     divider between the groups now that there are far more of them. */
  #moreBody .sep { display: none }
  #moreBody .grp { border-bottom: 1px solid var(--line); padding-bottom: 10px }
  #moreBody .grp:last-child { border-bottom: 0 }

  /* our own overlays must clear the dock and the safe area */
  .cthread { max-width: calc(100vw - 20px) }
  .orgview > header { gap: 6px; padding: 8px 10px }
  .orggrid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px }
}

/* --- tablets: the ribbon stays, but it has to be scrollable and obvious --- */
@media (min-width: 761px) and (max-width: 1100px) {
  .ribbon .btn { min-width: 54px; max-width: 84px; padding: 0 6px }
  .ribbon .btn::after { font-size: 10px }
  .ribbon .sep { margin: 0 5px }
  .ribbon .tsep { margin: 0 5px }
}

/* --- very narrow phones --- */
@media (max-width: 400px) {
  .dock[data-crowded="yes"] .btn { min-width: 54px }
  .dock .btn::after { font-size: 8.5px }
}

/* --- landscape phone: vertical space is the scarce thing --- */
@media (max-width: 900px) and (max-height: 480px) {
  .dock .btn { height: 40px }
  .sigbox, .docbox { max-height: calc(100vh - 20px) }
  #sigCanvas { height: 130px }
}

/* ---------------------------------------------------------------
   Sidebar tabs
   --------------------------------------------------------------- */

/* The strip was built for three tabs and now carries five. Sharing one row
   between them gave each 38px — narrower than the words inside — so the
   labels ran into each other.

   A two-column grid instead. Wrapping with flex was worse: `flex: 1 1 auto`
   makes each item grow to fill its row, so five tabs became four rows. The
   grid is predictable — two per row, always. The usual case is four tabs in
   two rows; Review only appears once a document has been shared. */
.rail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-items: center;
}
.rail-tabs .btn {
  min-width: 0;                   /* let it shrink inside its grid cell */
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;        /* a backstop, so it can never overlap */
}
/* Review is appended last and only appears once a document has been shared,
   which makes it the odd one out in a two-column grid. Let it stretch rather
   than leave a hole beside it. (:last-child does not work here — the close
   button is the real last child, merely hidden.) */
#tabReview { grid-column: 1 / -1 }

/* app.css already hides the close button outside the mobile drawer, so it
   takes no grid cell there. Here it just needs placing. */
@media (max-width: 760px) {
  .rail-tabs { grid-template-columns: 1fr 1fr auto; padding-right: 8px }
  #railClose {
    display: inline-flex;
    grid-column: 3; grid-row: 1;
    width: 38px; min-width: 38px; padding: 0;
  }
  .rail-tabs .btn { min-width: 0 }
}

/* ---------------------------------------------------------------
   Option rows inside a popover
   --------------------------------------------------------------- */

/* app.css styles `.pop label` for its stacked "LABEL / field" forms — mono,
   uppercase, 10px — and `.pop input` for full-width fields, 100% by 34px.
   A radio button picked both up, which is why the Split panel had giant
   circles beside shouting labels. These rows opt out of all of it. */
.optlist { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 2px }

.pop .opt {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  /* undo the stacked-form label styling */
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.pop .opt:hover { background: var(--chrome-2) }
.pop .opt.on { background: var(--chrome-2) }

.pop .opt input[type="radio"] {
  width: 17px; height: 17px;
  min-width: 17px;
  flex: none;
  margin: 0;
  padding: 0;
  accent-color: var(--marker);
  cursor: pointer;
}
.pop .optlabel {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: inherit;
  white-space: nowrap;
}
.pop .optnum {
  width: 54px; height: 28px;
  flex: none;
  padding: 0 6px;
  text-align: center;
  font-family: var(--sans);
  font-size: 13px;
}
.pop .optfield {
  width: 100%; height: 32px;
  margin: 2px 0 0;
  font-family: var(--sans);
  font-size: 13px;
}
/* a field that belongs to an option nobody picked should look inert */
.pop .optnum:disabled, .pop .optfield:disabled {
  opacity: .42;
  cursor: not-allowed;
}
.pop .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px }

@media (pointer: coarse) {
  .pop .opt { padding: 11px 8px }
  .pop .opt input[type="radio"] { width: 20px; height: 20px; min-width: 20px }
  .pop .optnum { height: 34px }
  .pop .optfield { height: 38px }
}

/* Draw has its own Select button so you need not cross back to the Edit tab
   for it. On a phone there are no tabs — both groups sit in one dock — so the
   second one is just a duplicate. */
@media (max-width: 760px) {
  #tDrawSelect { display: none }
}

/* ---------------------------------------------------------------
   Select tool in the photo measurer
   --------------------------------------------------------------- */


@media (pointer: coarse) {
  /* the grips are drawn on the canvas, so the targets that matter here are
     the buttons underneath it */
  #pmtools .btn { min-height: 44px }
  #pmUndo, #pmRedo, #pmClear { min-height: 44px; min-width: 60px }
}

/* ---------- install app ----------
   The same metrics as the Select files button beside it — 40px tall, 14px
   text, a 16px icon — in the secondary treatment, because opening a PDF is
   still the primary thing to do on this panel. The 19px padding plus a 1px
   border gives the same optical inset as the 20px on a button with no border. */
.hdrop .install { height: 40px; padding: 0 19px; display: inline-flex; align-items: center; gap: 8px;
                  background: transparent; color: var(--text); border: 1px solid var(--line);
                  border-radius: 8px; font-size: 14px; font-weight: 650; cursor: pointer }
.hdrop .install:hover { border-color: #777777; background: var(--chrome-2); color: #fff }
.hdrop .install svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2;
                      stroke-linecap: round; stroke-linejoin: round }
/* the hint drops to its own line, so a second button never squeezes the row */
.hdrop .acts .or { flex: 1 0 100%; margin-top: 2px }
@media (max-width: 760px) {
  /* on a phone the two share the width evenly rather than wrapping apart */
  .hdrop .acts .pick, .hdrop .acts .install { flex: 1 1 0; min-width: 0; justify-content: center }
}

/* ---------- install offer ----------
   A card in the corner rather than a modal: the browser will not open its own
   install dialog without a click, so this is what does the asking, and it must
   not stand between anyone and the document they came to read. */
.instpop { position: fixed; right: 18px; bottom: 18px; z-index: 88;
           width: min(360px, calc(100vw - 32px));
           display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; padding: 14px;
           background: var(--chrome); border: 1px solid var(--line); border-radius: 12px;
           box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
           opacity: 0; transform: translateY(10px); transition: opacity .18s, transform .18s;
           /* nothing to click until it is actually on screen: a background tab
              holds back the frame that fades it in, and an invisible card must
              not sit in the corner swallowing clicks */
           pointer-events: none }
.instpop.show { opacity: 1; transform: none; pointer-events: auto }
.instpop[hidden] { display: none }
.instpop .ic { flex: none; width: 48px; height: 48px; border-radius: 10px }
.instpop .txt { flex: 1; min-width: 0 }
.instpop .txt b { display: block; font-size: 14px; font-weight: 650; color: #fff; margin-bottom: 4px }
.instpop .txt p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-dim) }
.instpop .acts { display: flex; gap: 8px; width: 100%; justify-content: flex-end }
.instpop .pick { height: 34px; padding: 0 16px; font-size: 13px }
.instpop .no { height: 34px; padding: 0 12px; background: transparent; color: var(--text-dim);
               border: 1px solid transparent; border-radius: 8px; font-size: 13px; cursor: pointer }
.instpop .no:hover { color: var(--text); border-color: var(--line) }
@media (max-width: 760px) {
  /* a phone gets it across the foot of the screen, clear of the home indicator */
  .instpop { right: 10px; left: 10px; width: auto; bottom: calc(10px + env(safe-area-inset-bottom)) }
}
@media (prefers-reduced-motion: reduce) {
  .instpop { transition: none }
}

/* the module slot on the mark properties popover (js/draw.js fills it for a
   dimension) — lays out in the same rhythm as the built-in fields */
.markpop .mpext { display: flex; align-items: center; gap: 8px; flex: none }
.markpop .mpext[hidden] { display: none }
.markpop .mpscale select { max-width: 78px }
/* the scale row wraps rather than run past a narrow side panel */
.markpop .mpscale { flex-wrap: wrap; row-gap: 6px; min-width: 0; max-width: 100% }
/* a dimension's look (draw.js): its own row under the scale */
.markpop .mpext:has(.mpdim) { flex: 1 1 100%; min-width: 0; max-width: 100% }
.markpop .mpdim { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; max-width: 100% }
.markpop .mplook { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; max-width: 100% }
.markpop .mplook input { width: 58px }
#dlZ { width: 58px }
.markpop .mplook [hidden] { display: none }

/* Pan and Select head every ribbon tab. On a phone the dock already opens
   with the Edit pair, so the Draw copies would only repeat it. */
.dock #tDrawPan, .dock #tDrawSelect { display: none; }

/* Convert: a thin progress bar under the dialog body while pages are read */
.cvprog { height: 3px; margin: 0 14px 10px; background: var(--line); border-radius: 2px; overflow: hidden }
.cvprog[hidden] { display: none }
.cvprog i { display: block; height: 100%; width: 0; background: var(--marker, #7B5CFF); transition: width .2s }

/* Calibrate is a word, not a one-letter toggle: let it size to its label
   instead of spilling out of a 26px square over the scale note. */
.txctl #dimCal { width: auto; padding: 0 10px; white-space: nowrap; flex: none }
.txctl #dimScaleNote { white-space: nowrap; margin-left: 4px }

/* ---------- Books: book view, read-aloud bar, bookmarks ---------- */
.bk {
  position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column;
  background: #2b2d31; color: #e9e9ea;
}
.bk[hidden] { display: none }
.bk[data-theme="sepia"] { background: #3a3128 }
.bk[data-theme="night"] { background: #0d0e10 }
body.bk-on { overflow: hidden }
.bk-top, .bk-foot { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex: none }
.bk-top .grow { flex: 1 }
.bk-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0 }
.bk-b {
  height: 32px; min-width: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06); color: inherit; font: inherit; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.bk-b.ic { padding: 0; width: 32px }
.bk-b svg, .bk-nav svg, .tts-b svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.bk-b:hover { background: rgba(255,255,255,.14) }
.bk-b.on { border-color: #f2c14e; color: #f2c14e }
.bk-stage { flex: 1; min-height: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px; user-select: none; touch-action: pan-y }
.bk-spread { flex: 1; height: 100%; min-width: 0; display: flex; align-items: center; justify-content: center }
.bk-page { display: block; background: #fff; box-shadow: 0 10px 34px rgba(0,0,0,.45) }
.bk-page.l { box-shadow: -8px 10px 30px rgba(0,0,0,.4), inset -18px 0 24px -18px rgba(0,0,0,.35) }
.bk-page.r { box-shadow: 8px 10px 30px rgba(0,0,0,.4) }
.bk[data-theme="sepia"] .bk-page { filter: sepia(.5) saturate(.9) brightness(.96) }
.bk[data-theme="night"] .bk-page { filter: invert(.9) hue-rotate(180deg) brightness(.95) }
.bk-spread.turn-next { animation: bkNext .28s ease-out }
.bk-spread.turn-prev { animation: bkPrev .28s ease-out }
@keyframes bkNext { from { opacity: .35; transform: translateX(26px) } to { opacity: 1; transform: none } }
@keyframes bkPrev { from { opacity: .35; transform: translateX(-26px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { .bk-spread.turn-next, .bk-spread.turn-prev { animation: none } }
.bk-wait { opacity: .7; font-size: 14px }
.bk-nav {
  flex: none; width: 42px; height: 64px; border-radius: 10px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.07); color: inherit; display: flex; align-items: center; justify-content: center;
}
.bk-nav:hover:not(:disabled) { background: rgba(255,255,255,.16) }
.bk-nav:disabled { opacity: .25; cursor: default }
.bk-foot input[type="range"] { flex: 1; accent-color: #f2c14e }
.bk-pg { font-size: 12.5px; opacity: .8; min-width: 78px; text-align: right; font-variant-numeric: tabular-nums }
@media (max-width: 640px) {
  .bk-nav { display: none }
  .bk-top { flex-wrap: wrap }
  .bk-title { flex-basis: 100% }
}

.ttsbar {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: 22px; z-index: 97;
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 999px;
  background: var(--chrome-2); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: calc(100vw - 24px);
}
.ttsbar[hidden] { display: none }
.tts-b {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  color: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none;
}
.tts-b:hover { border-color: var(--text-dim) }
.tts-pg { font-size: 12.5px; white-space: nowrap; color: var(--text-dim) }
.ttsbar select {
  height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--stage); color: var(--text);
  font: inherit; font-size: 12px; padding: 0 6px; max-width: 170px; min-width: 0;
}

.bkpop {
  position: fixed; z-index: 98; width: 300px; max-height: min(70vh, 520px); overflow: auto;
  background: var(--chrome-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45); padding: 6px 0;
}
.bkpop[hidden] { display: none }
.bkpop-h { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); padding: 8px 14px 4px }
.bkpop-empty { font-size: 12.5px; color: var(--text-dim); margin: 2px 14px 8px; line-height: 1.5 }
.bkpop-list { list-style: none; margin: 0; padding: 0 6px 4px }
.bkpop-list li { display: flex; align-items: center; gap: 2px }
.bkpop-go {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; font-size: 13px; padding: 7px 8px; border-radius: 7px; cursor: pointer;
}
.bkpop-go:hover { background: rgba(127,127,127,.14) }
.bkpop-go span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.bkpop-go b { font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 600; min-width: 22px }
.toc .bkpop-go b { text-align: right }
.bkpop-ren, .bkpop-del {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none;
  color: var(--text-dim); cursor: pointer; font-size: 15px;
}
.bkpop-ren:hover, .bkpop-del:hover { color: var(--text); background: rgba(127,127,127,.14) }

/* ---------- the Bookmarks panel in the sidebar (js/books.js), as Acrobat's ---------- */
.bkside { padding: 0 }
.bks-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px 14px }
.bks-title { flex: 1; margin: 0; font-size: 14px; font-weight: 650; color: var(--text) }
.bks-x { width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: none }
.bks-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round }
.bks-tree { padding: 0 6px 8px }
.bks-list, .bks-list ul { list-style: none; margin: 0; padding: 0 }
.bks-list ul { padding-left: 18px; display: none }
.bks-list li.bks-open > ul { display: block }
.bks-row { display: flex; align-items: flex-start; gap: 2px; border-radius: 6px }
.bks-row:hover { background: var(--hover, rgba(127,127,127,.12)) }
.bks-row.on { background: rgba(127,127,127,.18) }
.bks-tw {
  flex: none; width: 24px; height: 30px; padding: 0; border: 0; background: none; color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.bks-tw.none { visibility: hidden; cursor: default }
.bks-tw svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2;
              stroke-linecap: round; stroke-linejoin: round; transition: transform .12s }
.bks-list li.bks-open > .bks-row .bks-tw svg { transform: rotate(90deg) }
.bks-go {
  flex: 1; min-width: 0; padding: 7px 8px 7px 2px; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 13px; line-height: 16px; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.bks-go:disabled { color: var(--text-dim); cursor: default }
.bks-own { border-top: 1px solid var(--line); margin: 4px 8px 0; padding-top: 4px }
.bks-own .bkpop-h { padding-left: 6px }
.bks-own .bkpop-empty { margin-left: 6px }

/* ---------- Drawing Tool tab: the tool's properties inside the ribbon ---------- */
.tabs .tab.ctx { color: var(--marker-ink); }
.tabs .tab.ctx:not(.on) { background: color-mix(in srgb, var(--marker) 12%, transparent); border-radius: 7px }
.tabs .tab.ctx[hidden] { display: none }
#panTool { align-items: center }
#panTool .toolprops { align-items: center; min-width: 0 }
body.props-in-ribbon #modeBar {
  background: transparent; border: 0; padding: 0 4px; gap: 12px;
  flex-wrap: nowrap; z-index: auto; min-height: 50px;
}
body.props-in-ribbon #modeBar:not(.show) { display: none }
body.props-in-ribbon #modeBar > * { flex: none }
/* the ribbon's big stacked buttons are for tools; these are plain controls */
#panTool #modeBar .btn {
  height: 30px; min-width: 0; max-width: none; flex-direction: row; padding: 0 12px; gap: 6px; border-radius: 7px;
}
#panTool #modeBar .btn::after { content: none }
#panTool #modeBar .hint {
  order: 90; max-width: 340px; font-size: 11.5px; line-height: 1.35; white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#panTool #modeBar .grow { order: 91; flex: 1 }
#panTool #modeBar #modeDone { order: 92 }
/* Done finishes the tool the way Save finishes the file: the same grey button */
#modeDone.primary, #panTool #modeBar #modeDone.primary {
  background: var(--pri-bg); border-color: transparent; color: var(--pri-ink); font-weight: 650;
}
#modeDone.primary:hover:not(:disabled), #panTool #modeBar #modeDone.primary:hover:not(:disabled) {
  background: var(--pri-bg-hover); border-color: transparent;
}
#btnToolNow { cursor: pointer }

/* the selected mark's panel, laid into the Drawing Tool tab instead of floating */
body.props-in-ribbon #panTool .markpop {
  position: static !important; left: auto !important; top: auto !important;
  background: transparent; border: 0; box-shadow: none; padding: 0 4px;
  max-width: none; flex-wrap: nowrap; overflow: visible; min-height: 50px; z-index: auto;
}
body.props-in-ribbon #panTool .markpop[hidden] { display: none }
body.props-in-ribbon #panTool .markpop .mtitle,
body.props-in-ribbon #panTool .markpop .mtitle + .mdiv { display: none }
#panTool .toolprops[hidden] { display: none }
/* a mark's own controls (a signature's Change / Ink / Keep proportions, a
   leader's Arrow / Dot, an image's Crop) stack in rows on the floating panel;
   in the ribbon they run in one row, so the tab keeps the height it has for
   every other tool */
body.props-in-ribbon #panTool #mpExt,
body.props-in-ribbon #panTool #mpExt > div,
body.props-in-ribbon #panTool #mpExt .row {
  display: flex; flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 8px;
}
body.props-in-ribbon #panTool #mpExt .btn {
  height: 30px; width: auto !important; flex: none !important; min-width: 0; max-width: none;
  flex-direction: row; padding: 0 12px; border-radius: 7px; white-space: nowrap;
}
#panTool #mpExt .btn::after { content: none }

/* ---------- Illustrator-style cursors ----------
   Thin black lines on a white halo, so they read on light and dark drawings.
   Generated as SVG data URIs; each falls back to the nearest system cursor. */
:root {
  --cur-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='black' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Ccircle cx='12' cy='12' r='.85' fill='black' stroke='white' stroke-width='.8'/%3E%3C/svg%3E") 12 12, crosshair;
  --cur-cross-add: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='black' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Ccircle cx='12' cy='12' r='.85' fill='black' stroke='white' stroke-width='.8'/%3E%3Cpath d='M18.5 16v6M15.5 19h6' stroke='white' stroke-width='3.4000000000000004' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M18.5 16v6M15.5 19h6' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, copy;
  --cur-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M4.5 2.5v16.2l4.1-3.9 2.9 6.2 2.6-1.2-2.9-6.1h5.6z' fill='black' stroke='white' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") 5 3, default;
  --cur-arrow-obj: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M4.5 2.5v16.2l4.1-3.9 2.9 6.2 2.6-1.2-2.9-6.1h5.6z' fill='black' stroke='white' stroke-width='1.2' stroke-linejoin='round'/%3E%3Crect x='16.5' y='17.5' width='5' height='5' fill='black' stroke='white' stroke-width='1'/%3E%3C/svg%3E") 5 3, move;
  --cur-arrow-point: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M4.5 2.5v16.2l4.1-3.9 2.9 6.2 2.6-1.2-2.9-6.1h5.6z' fill='white' stroke='black' stroke-width='1.1' stroke-linejoin='round'/%3E%3Crect x='16.5' y='17.5' width='5' height='5' fill='white' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") 5 3, pointer;
  --cur-nwse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M6 6l12 12M6 6v4.5M6 6h4.5M18 18v-4.5M18 18h-4.5' stroke='white' stroke-width='3.3000000000000003' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M6 6l12 12M6 6v4.5M6 6h4.5M18 18v-4.5M18 18h-4.5' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, nwse-resize;
  --cur-nesw: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M18 6L6 18M18 6v4.5M18 6h-4.5M6 18v-4.5M6 18h4.5' stroke='white' stroke-width='3.3000000000000003' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M18 6L6 18M18 6v4.5M18 6h-4.5M6 18v-4.5M6 18h4.5' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, nesw-resize;
  --cur-rotate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M5 15A10 10 0 0 1 15 5M5 15l-1.8-3.6M5 15l3.8-1.6M15 5l-3.6-1.8M15 5l-1.6 3.8' stroke='white' stroke-width='3.3000000000000003' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M5 15A10 10 0 0 1 15 5M5 15l-1.8-3.6M5 15l3.8-1.6M15 5l-3.6-1.8M15 5l-1.6 3.8' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 10 10, grab;
  --cur-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M3.5 20.5l1.2-4.6L15.6 5a2 2 0 0 1 2.8 0l.6.6a2 2 0 0 1 0 2.8L8.1 19.3z' fill='white' stroke='black' stroke-width='1.1' stroke-linejoin='round'/%3E%3Cpath d='M3.5 20.5l1.2-4.6 3.4 3.4z' fill='black'/%3E%3Cpath d='M14 6.6l3.4 3.4' stroke='black' stroke-width='1.1'/%3E%3C/svg%3E") 4 20, crosshair;
  --cur-type: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Crect x='3.5' y='3.5' width='17' height='17' fill='none' stroke='white' stroke-width='2.4'/%3E%3Crect x='3.5' y='3.5' width='17' height='17' fill='none' stroke='black' stroke-width='1' stroke-dasharray='1.6 1.6'/%3E%3Cpath d='M9.5 7h5M12 7v10M9.5 17h5' stroke='white' stroke-width='3.3000000000000003' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M9.5 7h5M12 7v10M9.5 17h5' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 15, text;
  --cur-crop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M12 4.5V9M12 15V19.5M4.5 12H9M15 12H19.5' stroke='black' stroke-width='1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Ccircle cx='12' cy='12' r='.85' fill='black' stroke='white' stroke-width='.8'/%3E%3Cpath d='M16.5 15v5.5h5.5M15 16.5h5.5V22' stroke='white' stroke-width='3.3000000000000003' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M16.5 15v5.5h5.5M15 16.5h5.5V22' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, crosshair;
  --cur-hand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M9 11V4.6a1.6 1.6 0 0 1 3.2 0V10M12.2 10V3.8a1.6 1.6 0 0 1 3.2 0V10M15.4 10.4V5.6a1.6 1.6 0 0 1 3.2 0V14a7 7 0 0 1-7 7h-1a6 6 0 0 1-4.5-2l-3-3.4a1.7 1.7 0 0 1 2.4-2.4L9 15.4V11' fill='white' stroke='black' stroke-width='1.2' stroke-linejoin='round' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, grab;
  --cur-hand-shut: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M7.2 12.2V11a1.6 1.6 0 0 1 3.2 0v-.6a1.6 1.6 0 0 1 3.2 0v.3a1.6 1.6 0 0 1 3.2 0v.5a1.5 1.5 0 0 1 3 0V15a6 6 0 0 1-6 6h-1.4a5.2 5.2 0 0 1-4.1-2l-1.9-2.6a1.6 1.6 0 0 1 2.4-2z' fill='white' stroke='black' stroke-width='1.2' stroke-linejoin='round'/%3E%3Cpath d='M10.4 11v2.2M13.6 10.7v2.3M16.8 11v2.2' stroke='black' stroke-width='1' fill='none'/%3E%3C/svg%3E") 12 12, grabbing;
  /* a side pulled up and down, or across; a mark picked up to move */
  --cur-ns: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M12 3.5v17M12 3.5l-3.4 3.4M12 3.5l3.4 3.4M12 20.5l-3.4-3.4M12 20.5l3.4-3.4' stroke='white' stroke-width='3.3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M12 3.5v17M12 3.5l-3.4 3.4M12 3.5l3.4 3.4M12 20.5l-3.4-3.4M12 20.5l3.4-3.4' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, ns-resize;
  --cur-ew: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M3.5 12h17M3.5 12l3.4-3.4M3.5 12l3.4 3.4M20.5 12l-3.4-3.4M20.5 12l-3.4 3.4' stroke='white' stroke-width='3.3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M3.5 12h17M3.5 12l3.4-3.4M3.5 12l3.4 3.4M20.5 12l-3.4-3.4M20.5 12l-3.4 3.4' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, ew-resize;
  --cur-move: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Cpath d='M12 3.5v17M12 3.5l-3.4 3.4M12 3.5l3.4 3.4M12 20.5l-3.4-3.4M12 20.5l3.4-3.4M3.5 12h17M3.5 12l3.4-3.4M3.5 12l3.4 3.4M20.5 12l-3.4-3.4M20.5 12l-3.4 3.4' stroke='white' stroke-width='3.3' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3Cpath d='M12 3.5v17M12 3.5l-3.4 3.4M12 3.5l3.4 3.4M12 20.5l-3.4-3.4M12 20.5l3.4-3.4M3.5 12h17M3.5 12l3.4-3.4M3.5 12l3.4 3.4M20.5 12l-3.4-3.4M20.5 12l-3.4 3.4' stroke='black' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") 12 12, move;
  /* a single dot, matching the pin mark itself — no crosshair badge */
  --cur-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='geometricPrecision'%3E%3Ccircle cx='12' cy='12' r='8' fill='%23E03616' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 12 12, pointer;
}
/* drawing: a precise crosshair for every tool that draws on the page */
body:not([data-tool="select"]) .capture { cursor: var(--cur-cross) }
body[data-tool="text"] .capture { cursor: var(--cur-type) }
body[data-tool="ink"] .capture { cursor: var(--cur-pencil) }
body[data-tool="crop"] .capture { cursor: var(--cur-crop) }
body[data-tool="pin"] .capture { cursor: var(--cur-pin) }
body[data-tool="note"] .capture,
body[data-tool="stamp"] .capture { cursor: var(--cur-cross-add) }
body[data-tool="pin"] .anno .pin { cursor: var(--cur-arrow-obj) }

/* selecting and editing */
body[data-tool="select"] .pagebox { cursor: var(--cur-arrow) }
body[data-tool="select"] .anno .sh,
body[data-tool="select"] .anno .tx,
body[data-tool="select"] .anno .patch,
body[data-tool="select"] .anno .redact-mk { cursor: var(--cur-arrow-obj) }
/* the unseen grab strip and reading of a dimension: held only by Select */
.anno .grab { pointer-events: none }
body[data-tool="select"] .anno .grab { pointer-events: all; cursor: var(--cur-arrow-obj) }
/* the Move button (toolbar.js): the same tool as Select underneath, but
   every mark reads as move, not just the one already picked up — one more
   hint than Select's own subtler arrow-obj that this is what it is for */
body.move-mode .anno .sh,
body.move-mode .anno .tx,
body.move-mode .anno .patch,
body.move-mode .anno .redact-mk,
body.move-mode .anno .grab { cursor: var(--cur-move) }
/* an open box or circle (fill: none) only ever caught a click on its own
   stroke — pointer-events: all catches one anywhere inside it too, same
   as a filled one already does, without touching fill itself (so a mark
   that really is filled keeps its own colour, not a forced transparent) */
body.move-mode .anno .sh { pointer-events: all }
/* the empty page too, not just a mark on it — ready to move something
   wherever the pointer sits, the plain way Pan's own cursor covers its
   whole capture area rather than only what is actually under it */
body.move-mode .pagebox { cursor: var(--cur-move) }
.anno .kn { cursor: var(--cur-nwse) }
.anno .kn[data-cur="nesw"] { cursor: var(--cur-nesw) }
.anno .kn[data-cur="point"] { cursor: var(--cur-arrow-point) }
.anno .kn.turn, .anno .kn.turn:active { cursor: var(--cur-rotate) }
.anno .kn[data-cur="ns"] { cursor: var(--cur-ns) }
.anno .kn[data-cur="ew"] { cursor: var(--cur-ew) }
body[data-tool="select"] .anno .picked,
body[data-tool="select"] .anno .picked * { cursor: var(--cur-move) }

/* the grips as Acrobat draws them: a thin violet box, round corners, a pill on
   each side, and the turn grip a violet disc with the turn arrow in it */
.anno .hnd .halo { fill: none; stroke: #7B5CFF; stroke-width: 1; stroke-dasharray: none; opacity: 1 }
.anno .hnd .kn { fill: #FFFFFF; stroke: #7B5CFF; stroke-width: 1.3 }
.anno .hnd .kn:hover { fill: #E4DDFF }
.anno .hnd .kn.turn { fill: #7B5CFF; stroke: #FFFFFF; stroke-width: 1.5 }
.anno .hnd .kn.turn:hover { fill: #6A4BF0 }
.anno .hnd .turnic { fill: none; stroke: #FFFFFF; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none }
.anno .hnd .stem { stroke: #7B5CFF; stroke-width: 1.2; opacity: 1 }

/* the hand */
body[data-tool="pan"] .capture { cursor: var(--cur-hand) }
body[data-tool="pan"].panning .capture { cursor: var(--cur-hand-shut) }
body.panning, body.panning *, body.midpan, body.midpan * { cursor: var(--cur-hand-shut) !important }

/* the photo markup window keeps the same family */
#pmcv { cursor: var(--cur-cross) }
body.pmpan #pmcv { cursor: var(--cur-hand) }
body.pmpan #pmcv:active { cursor: var(--cur-hand-shut) }

/* ---------- object snap ---------- */
.snapmark {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  display: flex; align-items: center; gap: 6px; will-change: transform;
}
.snapmark[hidden] { display: none }
.snapmark svg {
  width: 18px; height: 18px; margin: -9px 0 0 -9px; overflow: visible;
  fill: none; stroke: #7B5CFF; stroke-width: 2; stroke-linejoin: round;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000);
}
.snapmark svg .dot { fill: #7B5CFF; stroke: none }
.snapmark span {
  margin: 14px 0 0 2px; padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  font: 600 10.5px/1.2 Helvetica, Arial, sans-serif; color: #FFFFFF; background: #7B5CFF;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
/* the reading that rides with the pointer while a mark is drawn, and the dot
   on the point it started from */
.drawread {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
  font: 600 11px/1.2 Helvetica, Arial, sans-serif; color: #FFFFFF; background: #2B2B2B;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.drawread[hidden], .drawstart[hidden] { display: none }
.drawstart {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform;
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: #7B5CFF;
  box-shadow: 0 0 0 1px rgba(255,255,255,.7);
}
/* how far a drag has moved a mark so far (core.js), beside the cursor */
.movehud {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
  font: 600 11px/1.2 Helvetica, Arial, sans-serif; color: #FFFFFF; background: #2B2B2B;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.movehud[hidden] { display: none }
/* the gap to a near neighbour (core.js), centred in it rather than beside
   the cursor — the smart guides' own magenta, so the two read as one family */
.disthud { background: #FF2BD6; font-weight: 700; padding: 2px 6px }
/* held at drop, Ctrl/Cmd leaves a copy behind rather than just moving —
   the plain copy cursor while it is held says so during the drag itself */
body.dragdup .anno, body.dragdup .anno * { cursor: copy !important }
.snapbtn {
  height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line); background: transparent;
  color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.snapbtn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2 }
.snapbtn.on { color: var(--on-ink); background: var(--on-bg); border-color: transparent }
.snapbtn.more { padding: 0 6px; margin-left: -4px }
.snappop {
  position: fixed; z-index: 98; width: 230px; padding: 6px 0 8px;
  background: var(--chrome-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.snappop[hidden] { display: none }
.snappop-h { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); padding: 6px 12px 4px }
.snappop label { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer }
.snappop label:hover { background: rgba(127,127,127,.12) }
.snappop input { accent-color: #7B5CFF }
.snappop-note { margin: 6px 12px 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.45 }

/* The guides an acquired point sends out, over the stage: dashed, in the snap
   colour, with a small plus on the point being tracked from. */
.snaptrack { position: fixed; z-index: 59; pointer-events: none; overflow: visible }
.snaptrack[hidden] { display: none }
.snaptrack line {
  stroke: #E8882A; stroke-width: 1.3; stroke-dasharray: 6 4;
  shape-rendering: crispEdges;
}
.snaptrack path { stroke: #E8882A; stroke-width: 2; fill: none }

/* Smart guides, while a mark is dragged (core.js): solid, in Illustrator's
   own magenta, through whatever it has just lined up with — distinct from
   the snap guides above, which only ever run from a point you dwelled on
   while drawing, not while moving something already on the page. */
.smartguide { position: fixed; z-index: 59; pointer-events: none; overflow: visible }
.smartguide line { stroke: #FF2BD6; stroke-width: 1; shape-rendering: crispEdges }

/* The marker is a zero-size anchor at the snap point itself: the symbol is
   centred on it, and the label hangs off to the lower right, so neither can
   push the other out of place. */
.snapmark { display: block; width: 0; height: 0; gap: 0 }
.snapmark svg { position: absolute; left: -9px; top: -9px; margin: 0; display: block }
.snapmark span { position: absolute; left: 12px; top: 10px; margin: 0 }

/* ---------- multi-selection ---------- */
.marquee {
  position: fixed; z-index: 40; pointer-events: none;
  border: 1px dashed #7B5CFF; background: rgba(123,92,255,.08);
}
.marquee[hidden] { display: none }
/* visual only — a translucent fill still catches clicks by default in
   SVG, which was quietly stealing them from whatever is under it (a
   member's own Ctrl+click-to-deselect, among others) before this */
.anno .halo.multi { stroke: #7B5CFF; stroke-width: 1; stroke-dasharray: 4 3; fill: rgba(123,92,255,.04); opacity: 1; pointer-events: none }
/* the whole group's own frame, under the per-member boxes above — its
   own drag handle (core.js), so the gap between two marks moves them
   both the same as grabbing either one already does */
.anno .halo.multi-frame {
  stroke: #7B5CFF; stroke-width: 1.5; stroke-dasharray: none; fill: rgba(123,92,255,.03);
  opacity: 1; pointer-events: all; cursor: var(--cur-move);
}

/* ---------- ribbon: bigger, darker, cleaner ----------
   Larger icons with a firmer line, labels in the main text colour at a
   readable size, and tab names that do not look greyed out — closer to
   WPS / Office than to a thin sketch. */
.ribbon { padding: 6px 12px }
.ribbon .btn {
  height: 60px; min-width: 64px; max-width: 116px; gap: 5px; padding: 0 10px; border-radius: 9px;
  color: var(--text);
}
.ribbon .btn svg { width: 24px; height: 24px; stroke-width: 1.75 }
.ribbon .btn::after {
  font-size: 12.5px; line-height: 1.15; font-weight: 500; color: var(--text); letter-spacing: 0;
}
.ribbon .btn:disabled::after { color: var(--text-dim) }
.ribbon .btn.on::after { color: var(--on-ink); font-weight: 600 }
.ribbon #btnTheme .lbl { font-size: 12.5px; font-weight: 500; color: var(--text) }
.ribbon .sep, .ribbon .tsep { height: 42px }
.ribbon .zoomval { font-size: 13px; font-weight: 600; color: var(--text) }
.tabs .tab { font-size: 14.5px; font-weight: 500; color: var(--text); height: 32px; padding: 0 14px }
.tabs .tab:hover { color: var(--marker-ink) }
.tabs .tab.on { font-weight: 650 }
body[data-ui="light"] .tabs .tab:not(.on):not(.ctx) { color: #2B2F36 }

/* the tool properties inside the ribbon line up with the taller buttons */
body.props-in-ribbon #modeBar, body.props-in-ribbon #panTool .markpop { min-height: 60px }
#panTool #modeBar .hint { font-size: 12px }

/* narrower windows: keep it a little tighter so the row still fits */
@media (min-width: 761px) and (max-width: 1100px) {
  .ribbon .btn { min-width: 56px; max-width: 92px; padding: 0 7px }
  .ribbon .btn svg { width: 22px; height: 22px }
  .ribbon .btn::after { font-size: 11.5px }
  .tabs .tab { font-size: 13.5px; padding: 0 10px }
}

/* ---------- ribbon: crisp, like WPS ----------
   Windows' own interface font at a whole pixel size, and icons drawn with a
   one-device-pixel line in near-black. toolbar.js nudges each icon so its
   straight lines fall exactly on screen pixels instead of between two. */
.ribbon, .tabs .tab {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto;
}
.ribbon .btn { color: #161616 }
.ribbon .btn svg { width: 24px; height: 24px; stroke-width: var(--ico-stroke, 1); display: block; flex: none }
.ribbon .btn::after, .ribbon #btnTheme .lbl {
  font-size: 13px; line-height: 16px; font-weight: 400; color: #1b1b1b;
}
.ribbon .btn.on::after { color: var(--on-ink); font-weight: 600 }
.ribbon .btn:disabled::after { color: #8a8f98 }
.ribbon .zoomval { font-family: inherit; font-size: 13px; font-weight: 600; color: #1b1b1b }
.tabs .tab { font-size: 14px; font-weight: 400; color: #1b1b1b }
.tabs .tab.on { font-weight: 600 }
body[data-ui="light"] .tabs .tab:not(.on):not(.ctx) { color: #1b1b1b }
body[data-ui="dark"] .ribbon .btn, body:not([data-ui="light"]) .ribbon .btn { color: var(--text) }
body:not([data-ui="light"]) .ribbon .btn::after,
body:not([data-ui="light"]) .ribbon #btnTheme .lbl,
body:not([data-ui="light"]) .ribbon .zoomval,
body:not([data-ui="light"]) .tabs .tab:not(.on) { color: var(--text) }
@media (min-width: 761px) and (max-width: 1100px) {
  .ribbon .btn svg { width: 24px; height: 24px }
  .ribbon .btn::after { font-size: 12px }
}

/* ---------- full-contrast text and icons: pure black in light, pure white in dark ----------
   Ribbon, tab names and the top bar. What is switched on keeps its violet, and
   what is disabled stays faded, so both still read at a glance. */
body[data-ui="light"] { --ink: #000000 }
body:not([data-ui="light"]) { --ink: #FFFFFF }

.ribbon .btn,
.ribbon .btn::after,
.ribbon #btnTheme .lbl,
.ribbon .zoomval,
.tabs .tab:not(.on):not(.ctx),
.bar .btn:not(.primary):not(.on),
.bar .pager, .bar .pager input, .bar #pageTotal,
.bar .admark,
#panTool #modeBar, #panTool .markpop { color: var(--ink) }
body[data-ui="light"] .tabs .tab:not(.on):not(.ctx) { color: var(--ink) }
body:not([data-ui="light"]) .ribbon .btn::after,
body:not([data-ui="light"]) .ribbon #btnTheme .lbl,
body:not([data-ui="light"]) .ribbon .zoomval,
body:not([data-ui="light"]) .tabs .tab:not(.on) { color: var(--ink) }

/* keep the live states */
.ribbon .btn.on, .ribbon .btn.on::after { color: var(--on-ink) }
.tabs .tab.on { color: var(--marker-ink) }
.ribbon .btn:disabled, .ribbon .btn:disabled::after, .bar .btn:disabled { color: var(--text-dim) }
body:not([data-ui="light"]) .ribbon .btn:not(.on):not(:disabled) { color: var(--ink) }

/* ---------- colours: square swatches and the full palette ---------- */
.sw, .anno-sw .sw, .sigcolors .sw, #pmswatch button, .swpop button {
  border-radius: 3px !important;
}
.sw {
  width: 20px; height: 20px; border: 1px solid rgba(0,0,0,.28); box-shadow: none; flex: none;
}
.sw.on { outline: 2px solid var(--marker); outline-offset: 2px; border-color: rgba(0,0,0,.28); box-shadow: none }
body[data-ui="light"] .sw, body[data-ui="light"] .sw.on { box-shadow: none }
body:not([data-ui="light"]) .sw { border-color: rgba(255,255,255,.35) }
.swatches { gap: 4px; align-items: center }
.swmore {
  height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 7px 0 5px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink, var(--text));
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.swmore:hover { border-color: var(--text-dim) }
.swmore i { width: 16px; height: 16px; border-radius: 2px; border: 1px solid rgba(0,0,0,.3); display: block }
.swmore b { font-weight: 400; font-size: 10px; color: var(--text-dim) }

.swpop.palette {
  width: auto; display: block; padding: 10px 12px 12px; border-radius: 10px;
  background: var(--chrome); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.35); z-index: 99;
}
.swpop.palette .phead { font-size: 11.5px; color: var(--text-dim); margin: 8px 0 5px }
.swpop.palette .phead:first-child { margin-top: 0 }
.pgrid { display: grid; grid-template-columns: repeat(10, 20px); gap: 4px }
.pgrid.shades { margin-top: 6px; row-gap: 0; column-gap: 4px }
.pgrid .psq {
  width: 20px; height: 20px; padding: 0; margin: 0; cursor: pointer;
  border: 1px solid rgba(0,0,0,.22); border-radius: 2px !important;
}
.pgrid.shades .psq { border-top-width: 0; border-bottom-width: 0; border-radius: 0 !important; height: 17px }
.pgrid.shades .psq:nth-child(-n+10) { border-top-width: 1px }
.pgrid.shades .psq:nth-last-child(-n+10) { border-bottom-width: 1px }
.pgrid .psq:hover { outline: 2px solid var(--text); outline-offset: 0; position: relative; z-index: 1 }
.pgrid .psq.on { outline: 2px solid var(--marker); outline-offset: 1px; position: relative; z-index: 2 }
body:not([data-ui="light"]) .pgrid .psq { border-color: rgba(255,255,255,.25) }
.pcustom { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line) }
.pcustom .plab { font-size: 11.5px; color: var(--text-dim); margin-right: 2px }
.pcustom input[type="color"] { width: 30px; height: 26px; padding: 1px; border: 1px solid var(--line); border-radius: 4px; background: transparent; cursor: pointer }
.pcustom input[type="text"] {
  width: 84px; height: 26px; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px;
  background: var(--stage); color: var(--text); font: 12.5px/1 ui-monospace, Consolas, monospace; text-transform: uppercase;
}
.pcustom input.bad { border-color: var(--danger) }
.swpop.palette .pcustom .peye, .pcustom .peye {
  flex: none; display: grid; place-items: center; width: 28px; height: 26px; padding: 0;
  border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--text); cursor: pointer;
}
.pcustom .peye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8 }
#pmswatch input[type="color"] { width: 28px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer }
#markPop .mpstack svg { fill: none; stroke: currentColor; stroke-width: 1.8 }

/* the Edit colours dialog (js/colordlg.js) */
body.cdpicking, body.cdpicking * { cursor: crosshair !important }
.cdwrap { position: fixed; inset: 0; z-index: 100000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .45) }
.cdwrap[hidden] { display: none }
.cdbox {
  width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box; padding: 22px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--chrome-2); color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .4);
}
.cdbox h2 { margin: 0 0 14px; font-size: 20px; font-weight: 650 }
.cdtop { display: grid; grid-template-columns: minmax(150px, 1fr) 44px 14px 170px; gap: 12px; align-items: stretch }
.cdsv {
  position: relative; min-height: 250px; border-radius: 6px; touch-action: none; cursor: crosshair;
  background: linear-gradient(to top, #FFF, rgba(255, 255, 255, 0)),
    linear-gradient(to right, #F00, #FF0, #0F0, #0FF, #00F, #F0F, #F00);
}
.cdsv i { position: absolute; width: 14px; height: 14px; margin: -7px; border: 2px solid #000; border-radius: 50%; box-shadow: 0 0 0 1px #FFF; pointer-events: none }
.cdnow { border-radius: 6px; border: 1px solid var(--line) }
.cdval { position: relative; border-radius: 7px; touch-action: none; cursor: pointer; background: linear-gradient(to bottom, var(--cd-top, #FFF), #000) }
.cdval i { position: absolute; left: 50%; width: 14px; height: 14px; margin: -7px; border: 3px solid #FFF; border-radius: 50%; background: #111; box-shadow: 0 0 0 1px #000; pointer-events: none }
.cdsv:focus-visible, .cdval:focus-visible { outline: 2px solid var(--btn, var(--marker)); outline-offset: 2px }
.cdfields { display: flex; flex-direction: column; gap: 8px; min-width: 0 }
.cdfields input, .cdfields select {
  box-sizing: border-box; width: 100%; height: 34px; padding: 0 9px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; background: var(--chrome);
}
.cdfields input.bad { border-color: var(--danger) }
.cdnum { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 8px; font-size: 13px }
.cdeye { display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px }
.cdeye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8 }
.cdlists { display: grid; grid-template-columns: 12fr 6fr; gap: 24px; margin-top: 18px }
.cdhd { display: flex; align-items: center; justify-content: space-between; min-height: 28px; margin-bottom: 8px; font-size: 13px }
.cdadd { width: 26px; height: 26px; padding: 0; font-size: 18px; line-height: 1; color: var(--text); border: 1px solid var(--line); border-radius: 5px; background: transparent; cursor: pointer }
.cdgrid { display: grid; gap: 6px; justify-items: center }
.cdbasic { grid-template-columns: repeat(12, 1fr) }
.cdcustom { grid-template-columns: repeat(6, 1fr) }
.cddot { box-sizing: border-box; display: block; width: 22px; height: 22px; padding: 0; border: 1px solid rgba(128, 128, 128, .7); border-radius: 50%; cursor: pointer }
.cddot.empty { border-style: dashed; background: transparent; cursor: default }
.cdfoot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px }
.cdfoot .btn { justify-content: center; height: 36px }
@media (max-width: 560px) {
  .cdtop { grid-template-columns: 1fr 32px 14px }
  .cdsv { min-height: 180px }
  .cdfields { grid-column: 1 / -1 }
  .cdlists { grid-template-columns: 1fr; gap: 12px }
  .cddot { width: 20px; height: 20px }
  .cdbasic { gap: 4px }
}
.pcustom .btn { height: 26px; padding: 0 10px; font-size: 12.5px; border-color: var(--line) }
/* No fill / No outline: a swatch-sized square with the red "no colour" slash,
   named by its tooltip rather than by text that would not fit */
.swpop.palette .pnofill {
  display: block; width: 20px; height: 20px; min-width: 0; margin: 0 0 6px; padding: 0; cursor: pointer;
  border: 1px solid rgba(0,0,0,.3) !important; border-radius: 2px !important;
  background: linear-gradient(45deg, transparent 44%, var(--danger) 44%, var(--danger) 56%, transparent 56%), #fff !important;
}
.swpop.palette .pnofill:hover { outline: 2px solid var(--text); outline-offset: 0 }
.swpop.palette .pnofill.on { outline: 2px solid var(--marker); outline-offset: 1px }
.swpop.palette .pcustom .btn { width: auto; min-width: 44px; border-width: 1px; border-radius: 5px !important }
.swpop.palette .pcustom input[type="color"] { width: 30px; height: 26px }

/* --- layers rail (js/layers.js): Illustrator's panel — one row per mark on
   the page, topmost drawn at the top, an eye to hide it, and on hover the
   actions to duplicate, delete or move it in the stack --- */
.laybar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line) }
.laybar b { font-size: 12.5px; font-weight: 600 }
.laybar .laycount { font-size: 11.5px; color: var(--text-dim) }
.laybar .grow { flex: 1 }
.layrow {
  position: relative; display: flex; align-items: center; gap: 7px; padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.layrow:hover { background: rgba(255,255,255,.045) }
.layrow.sel { background: var(--chrome-2) }
.layrow.hid { opacity: .6 }
/* the column of dots down the left edge: filled shows, hollow hides — one
   per layer and one per mark, so visibility reads as a single column */
.laydot {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: none; background: transparent; cursor: pointer; border-radius: 5px;
}
.laydot:hover { background: rgba(255,255,255,.08) }
.laydot .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text); display: block;
}
.laydot .dot.off { background: transparent; border: 1px solid var(--text-dim) }
/* the lock beside it: open or shut, its own column — a layer and each of
   its marks lock separately, same as they hide separately */
.laylock {
  flex: none; display: grid; place-items: center; width: 22px; height: 26px; padding: 0;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer; border-radius: 5px;
}
.laylock:hover { color: var(--text); background: rgba(255,255,255,.08) }
.laylock.on { color: var(--marker) }
.laylock svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8 }
.layrow.locked { cursor: default }
.layrow.locked .laylabel { color: var(--text-dim) }
.layrow.mrow.locked .laybtns { opacity: 0 !important; pointer-events: none !important }
.layswatch {
  flex: none; width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3);
}
body:not([data-ui="light"]) .layswatch { border-color: rgba(255,255,255,.3) }
.laylabel {
  flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layrow.hid .laylabel { text-decoration: line-through }
/* floats over the label's tail rather than squeezing it on every row —
   only the hovered or selected row needs the room */
.laybtns {
  position: absolute; right: 4px; top: 2px; bottom: 2px; display: flex; align-items: center; gap: 2px;
  padding-left: 10px; border-radius: 6px; background: var(--chrome);
  box-shadow: -10px 0 8px -4px var(--chrome); opacity: 0; pointer-events: none;
}
.layrow:hover .laybtns, .layrow.sel .laybtns { opacity: 1; pointer-events: auto }
.laybtns button {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer; border-radius: 5px;
}
.laybtns button:hover { color: var(--text); background: rgba(255,255,255,.08) }
.laybtns button:disabled { opacity: .3; cursor: default; background: none !important; color: var(--text-dim) !important }
.laybtns button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8 }
.laybtns button.laydel:hover { color: var(--danger) }

/* --- the tools above the tree, acting on the active layer (js/layers.js) --- */
.laytools {
  display: flex; align-items: center; gap: 4px; padding: 5px 8px;
  border-bottom: 1px solid var(--line);
}
.laytools .grow { flex: 1 }
.laytools button {
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0; flex: none;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer; border-radius: 5px;
}
.laytools button:hover { color: var(--text); background: rgba(255,255,255,.08) }
.laytools button:disabled { opacity: .3; cursor: default; background: none !important; color: var(--text-dim) !important }
.laytools button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8 }
.laytools button.laydanger:hover { color: var(--danger) }
/* the one button with a label, not just an icon */
.laytools button.laynew {
  display: flex; align-items: center; width: auto; padding: 0 9px; gap: 6px;
  border: 1px solid var(--line); font-size: 11.5px; white-space: nowrap;
}
.laytools button.laynew svg { width: 14px; height: 14px; flex: none }

/* --- a layer's own row in the tree, and the branch under it --- */
.layrow.layhead { padding-right: 6px }
.layrow.layhead.active { background: var(--chrome-2) }
.layrow.layhead .laylabel { font-weight: 600 }
.layrow.layhead .laylabel { cursor: text }
/* a layer's name, being renamed in place (js/layers.js) */
.layname { flex: 1; min-width: 0; height: 24px; margin: 0; padding: 0 6px; font: inherit; font-weight: 600;
  color: var(--text); background: var(--chrome); border: 1px solid var(--btn, var(--marker)); border-radius: 5px; outline: 0 }
/* the count and pencil make room for the name while it is typed */
.layhead:has(.layname) :is(.laynum, .laypen) { display: none }
.laytwist {
  flex: none; display: grid; place-items: center; width: 18px; height: 22px; padding: 0;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
}
.laytwist svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2 }
.laystrip { flex: none; width: 4px; height: 17px; border-radius: 2px }
.laynum { flex: none; font-size: 11px; color: var(--text-dim) }
.laypen { flex: none; display: grid; place-items: center; width: 16px; color: var(--marker) }
.laypen svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8 }
/* a mark sits under its layer: indented past the layer's own name, with the
   hairline of the branch it belongs to running down beside it */
.layrow.mrow .layswatch { margin-left: 30px }
.layrow.mrow::before {
  content: ''; position: absolute; left: 33px; top: 0; bottom: 0; width: 1px;
  background: var(--line); pointer-events: none;
}
.layrow.laynone {
  padding: 7px 8px 7px 56px; font-size: 11.5px; color: var(--text-dim); cursor: default;
}
/* dragging a mark onto another layer's row, or in front of another mark */
.layrow.dragging { opacity: .4 }
.layrow.over { background: color-mix(in srgb, var(--marker) 18%, transparent) }
.layrow.over::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--marker); border-radius: 3px;
}

/* ---------- colour and width: one dropdown each ---------- */
.swmore { margin-left: 0 }
.wdrop {
  height: 26px; display: inline-flex; align-items: center; gap: 7px; padding: 0 7px 0 8px;
  border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink, var(--text));
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.wdrop:hover { border-color: var(--text-dim) }
.wdrop i { display: block; width: 26px; background: currentColor; border-radius: 1px }
.wdrop b { font-weight: 400; font-size: 10px; color: var(--text-dim) }
.widths { gap: 0 }
.wdmenu {
  position: fixed; z-index: 99; min-width: 150px; padding: 5px;
  background: var(--chrome); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0,0,0,.3);
}
.wdmenu[hidden] { display: none }
.wdmenu button {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 28px; padding: 0 10px;
  border: 0; border-radius: 5px; background: transparent; color: var(--ink, var(--text));
  font: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.wdmenu button:hover { background: rgba(127,127,127,.14) }
.wdmenu button.on { background: rgba(123,92,255,.12); color: var(--marker-ink) }
.wdmenu button i { display: block; width: 54px; background: currentColor; border-radius: 1px; flex: none }

/* The Drawing Tool tab joins the row when a tool or a mark is picked up. The
   tabs close up a little then, so the bar stays on one row and the ribbon
   does not drop down and change size between tools. */
@media (min-width: 761px) and (max-width: 1600px) {
  .tabs:has(.tab.ctx:not([hidden])) .tab { padding: 0 9px }
}

/* ---------- highlight colour dropdowns (Highlight text, Highlight area) ---------- */
.ribbon .btn.ddbtn {
  min-width: 0; width: 18px; padding: 0 0 9px; margin-left: -6px; gap: 4px;
  flex-direction: column; justify-content: flex-end;
}
.ribbon .btn.ddbtn svg { width: 12px; height: 12px; stroke-width: 2 }
/* the colour in use, as a bar under the arrow */
.ribbon .btn.ddbtn::after {
  content: ''; width: 12px; height: 3px; border-radius: 2px; background: var(--dd-c, #F2C14E);
}
@media (max-width: 760px) { .btn.ddbtn { display: none } }
.pop.hlpop { min-width: 0; width: 254px }
.hlpop .hlhd { font-size: 12px; font-weight: 600; color: var(--text); margin: 9px 2px 5px }
.hlpop .hlgrid { display: grid; grid-template-columns: repeat(10, 19px); gap: 4px; padding: 0 2px }
.hlpop .hlshades { gap: 0 4px; margin-top: 4px }
.hlpop .sw {
  width: 19px; height: 19px; padding: 0; border-radius: 2px; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, .14);
}
.hlpop .hlshades .sw { height: 16px; border-radius: 0 }
.hlpop .sw:hover { outline: 2px solid var(--marker); outline-offset: 1px; position: relative; z-index: 1 }
.hlpop .sw.on { outline: 2px solid var(--marker-ink); outline-offset: 1px; position: relative; z-index: 1 }
.hlpop .hlauto {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 4px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font-size: 13px; cursor: pointer; text-align: left;
}
.hlpop .hlauto i { width: 16px; height: 16px; border: 1px solid rgba(0, 0, 0, .14); flex: none }
.hlpop .hlauto:hover, .hlpop .hlmore:hover, .hlpop .hleye:hover { background: var(--chrome-2) }
.hlpop .hlmore {
  position: relative; display: flex; align-items: center; gap: 9px; margin: 0; padding: 7px 6px; border-radius: 6px;
  font-family: inherit; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); cursor: pointer;
}
.hlpop .hlmore input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100% }
.hlpop :is(.hlmore, .hleye) svg {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- the Drawing Tool tab is as tall as every other tab ---------- */
body.props-in-ribbon #modeBar, body.props-in-ribbon #panTool .markpop { min-height: 0 }
/* no Done: work is kept as it is put down, as in Acrobat (js/toolprops.js) */
body.props-in-ribbon #panTool #modeDone { display: none }

/* a tool with many controls (Dimension) keeps the row inside the ribbon:
   the hint gives way first, and is cut to two lines rather than off the edge */
#panTool { min-width: 0; overflow: hidden }
body.props-in-ribbon #panTool #modeBar { min-width: 0; flex: 0 1 auto }
#panTool #modeBar .hint { flex: 0 1 340px; min-width: 120px; -webkit-line-clamp: 3 }

/* ---------- side panel tabs: Pages / Find / Properties / Notes ----------
   Real buttons in a tidy two-by-two grid: the same size, the names centred,
   and the open one plainly different — a grey tile with violet text, the rest outlined. */
body .rail-tabs { gap: 6px; padding: 10px 10px 4px }
body .rail-tabs .btn:not(#railClose) {
  height: 32px; justify-content: center; text-align: center; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--chrome);
  color: var(--text); font-size: 12.5px; font-weight: 500;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
body .rail-tabs .btn:not(#railClose):hover:not(.on) {
  background: var(--chrome-2); border-color: color-mix(in srgb, var(--marker) 45%, var(--line));
}
body .rail-tabs .btn.on:not(#railClose) {
  background: var(--on-bg); border-color: var(--on-bg); color: var(--on-ink);
  font-weight: 650; box-shadow: none;
}
.markpop .mfield[hidden] { display: none }

/* ---------- quick access after Home: open, save, print, undo, save as ---------- */
.bar .grp.quick { gap: 1px; margin-left: 4px }
.bar .grp.quick .btn { width: 32px; min-width: 32px; padding: 0 }
.bar .grp.quick .btn svg { width: 18px; height: 18px }
.bar .grp.quick .btn.qmore { width: 18px; min-width: 18px }
.bar .grp.quick .btn.qmore svg { width: 13px; height: 13px; stroke-width: 2 }
/* phones: the bar has room for little; Save is there already */
@media (max-width: 760px) {
  #btnQOpen, #btnQSave, #btnQPrint { display: none }
}

/* ---- Edit Object (js/editobj.js) ---- */
/* the shape under the pointer, about to be picked */
.anno .eohl { fill: rgba(123, 92, 255, .12); stroke: #7B5CFF; stroke-width: 2; stroke-dasharray: 5 3; pointer-events: none }
body[data-tool="editobj"] .capture { cursor: pointer }


/* ---- performance panel (js/perf.js, Ctrl+Shift+P) ---- */
.perfbox { position: fixed; right: 16px; bottom: 44px; z-index: 250; width: min(380px, calc(100vw - 32px));
  background: var(--chrome); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3); font-size: 12px }
.perfbox[hidden] { display: none }
.perfbox header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line) }
.perfbox header .grow { flex: 1 }
.perfbox header .btn { height: 26px; padding: 0 10px }
.perfbox header .x { border: none; background: none; color: inherit; font-size: 18px; cursor: pointer }
.perfbox .pfrows { padding: 6px 10px 10px; display: grid; gap: 3px }
.perfbox .pfrows div { display: flex; justify-content: space-between; gap: 12px }
.perfbox .pfrows span { color: var(--text-dim) }
.perfbox .pfrows b { font-family: var(--mono); font-weight: 500; text-align: right }

/* ---------------------------------------------------------------
   Phone browsers (the web app at phone width)
   --------------------------------------------------------------- */

/* The phone app (body[data-phone], css/phone.css) has its own top bar and
   document menu, so all of this leaves it alone. Every target is at least
   44px, the size of a fingertip. */
@media (max-width: 760px) {
  /* the top bar: Home, Undo and the page box, then Save and More together at
     the right. Save as… moves into the More sheet, where it has a full-size
     row instead of an 18px arrow */
  body:not([data-phone]) .bar { gap: 6px }
  body:not([data-phone]) .bar .btn { min-width: 44px; height: 44px }
  body:not([data-phone]) .bar .grp.quick { display: contents }
  body:not([data-phone]) .bar .grp.quick .btn { width: 44px; min-width: 44px }
  body:not([data-phone]) .bar .grp.quick .btn.qmore { display: none }
  body:not([data-phone]) #btnQSave { display: inline-flex; order: 1; border-color: transparent;
    background: var(--pri-bg); color: var(--pri-ink) }
  body:not([data-phone]) #btnMore { order: 2 }
  body:not([data-phone]) .pager input { width: 48px; height: 44px; text-align: center; border-radius: 10px }
  body:not([data-phone]) .pager span { font-size: 13px; white-space: nowrap }

  /* the dock sits in the page's column now, so the stage needs no room kept
     clear under it */
  body:not([data-phone]) .stage { padding-bottom: calc(24px + env(safe-area-inset-bottom)) }

  /* the More sheet: two columns of 48px rows, and a Save as… row at the top */
  body:not([data-phone]) .sheet .grp .btn {
    flex: 1 1 calc(50% - 4px); min-width: calc(50% - 4px); height: 48px;
    padding: 0 12px; gap: 10px; font-size: 14px
  }
  body:not([data-phone]) .sheet .grp .btn::after {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap
  }
  body:not([data-phone]) .sheet .grp .btn svg { flex: none }
  body:not([data-phone]) .sheet .tsep { display: none }
  body:not([data-phone]) .sheet .zoomval { font-size: 13px }
  body:not([data-phone]) #moreFile .btn { flex-basis: 100% }
  /* the phone app has Save a copy in its own document menu */
  body[data-phone] #moreFile { display: none }

  /* a tool's options above the page */
  body:not([data-phone]) .modebar { gap: 8px; align-items: center }
  body:not([data-phone]) .modebar .sw,
  body:not([data-phone]) .anno-sw .sw { width: 40px; height: 40px }
  body:not([data-phone]) .modebar :is(.swmore, .wdrop, select) { min-height: 44px }
  body:not([data-phone]) .modebar .btn { min-height: 44px }

  /* the side panel: wider, so Find has room to type, and finger-size buttons */
  body:not([data-phone]) .rail { width: min(90vw, 360px) }
  body:not([data-phone]) #railClose { width: 44px; min-width: 44px; height: 44px }
  body:not([data-phone]) .rail-tabs .btn { height: 44px }
  body:not([data-phone]) .search-wrap .search-in { height: 44px }
  body:not([data-phone]) .search-wrap .findstep { width: 44px; height: 44px }
  body:not([data-phone]) .thumb .tools { gap: 6px }
  body:not([data-phone]) .thumb .tools button { width: 40px; height: 40px }
  body:not([data-phone]) .thumb .tools svg { width: 16px; height: 16px }

  /* the start screen */
  body:not([data-phone]) #hUi { min-height: 44px }
}
