/*
 * Fill & Sign. The stage is a desk with the pages on it, one under another;
 * everything on a page is sized in page points times --z, the zoom, so a
 * zoom change is one custom property and the fields never drift from the
 * paper under them.
 */

body.qp-app { --ink: #1b1b1b; --text-ink: #141414; --desk: #e4ded3; }

/* ---------- frame ---------- */

.qp-work.fs-work {
  height: calc(100vh - var(--qp-bar-actual, var(--qp-bar-h)));
  height: calc(100dvh - var(--qp-bar-actual, var(--qp-bar-h)));
}

.qp-stage.fs-stage {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: var(--desk);
}

.fs-stage > .fs-drop {
  position: absolute;
  inset: 18px;
  height: auto;
  min-height: 0;
}

.fs-drop.is-busy { cursor: progress; }
.fs-drop.is-busy .drop-icon { animation: fs-bob 1.1s ease-in-out infinite; }
.fs-drop .dropzone-inner { max-width: 440px; }

.fs-sample {
  display: block;
  margin: 16px auto 0;
  padding: 4px 6px;
  border: 0;
  color: color-mix(in srgb, var(--ab-accent) 82%, var(--text));
  background: none;
  cursor: pointer;
  font: 650 .78rem "Inter", system-ui, sans-serif;
}

@media (hover: hover) {
  .fs-sample:hover { text-decoration: underline; text-underline-offset: 3px; }
}

.fs-viewer { position: absolute; inset: 0; }

.fs-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  /* the width a page is fitted to never changes as a scrollbar comes and goes */
  scrollbar-gutter: stable;
}

.fs-pages {
  --z: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: max-content;
  min-width: 100%;
  padding: 26px 28px 132px;
  box-sizing: border-box;
}

.fs-page {
  position: relative;
  flex: none;
  width: calc(var(--pw) * var(--z) * 1px);
  height: calc(var(--ph) * var(--z) * 1px);
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(48, 42, 31, .1), 0 10px 30px rgba(48, 42, 31, .13);
}

.fs-page:not(.is-drawn)::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(228, 222, 211, .55) 50%, transparent 70%) 0 0 / 300% 100%;
  content: "";
  animation: fs-shimmer 1.6s linear infinite;
}

.fs-canvas,
.fs-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.fs-canvas { border-radius: inherit; }

body.is-placing .fs-layer { cursor: crosshair; }
body.is-drawing-box .fs-scroll { touch-action: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- fields ---------- */

.fs-field,
.fs-sel,
.fs-ghost {
  position: absolute;
  left: calc(var(--x) * var(--z) * 1px);
  top: calc(var(--y) * var(--z) * 1px);
  width: calc(var(--w) * var(--z) * 1px);
  height: calc(var(--h) * var(--z) * 1px);
  box-sizing: border-box;
}

.fs-field {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--text-ink);
  background: transparent;
  font: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .16s, box-shadow .16s;
}

button.fs-field { cursor: pointer; }

/* A blank waits in the accent, like a highlighter on the page; once it is
   filled it shows only what will print. */
.fs-field.is-empty:not(.fs-whiteout) {
  background: color-mix(in srgb, var(--ab-accent) 10%, transparent);
  box-shadow: inset 0 -1.5px 0 color-mix(in srgb, var(--ab-accent) 55%, transparent);
}

.fs-field.fs-check.is-empty,
.fs-field.fs-choice.is-empty,
.fs-field.is-empty[data-origin="form"]:not(.fs-signature) {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ab-accent) 45%, transparent);
}

.fs-field[data-origin="form"] {
  border: 1px solid var(--frame, transparent);
  background-color: var(--frame-bg, transparent);
}

.fs-field[data-origin="form"].is-empty { background-color: color-mix(in srgb, var(--ab-accent) 10%, var(--frame-bg, transparent)); }
.fs-field.is-readonly { pointer-events: none; }

@media (hover: hover) {
  .fs-field:hover:not(.is-selected) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ab-accent) 60%, transparent); }
  .fs-field.is-empty:hover:not(.is-selected) { background: color-mix(in srgb, var(--ab-accent) 16%, transparent); }
}

.fs-field.is-hover { box-shadow: inset 0 0 0 1.5px var(--ab-accent); }

.fs-field.is-pulse { animation: fs-pulse .9s ease-out; }

/* Text, set the way pdf-lib will set it: Helvetica metrics (Arial is drawn
   to them), at --fs points, its baseline --bl points from the top. */
.fs-input,
.fs-line,
.fs-cell {
  color: var(--text-ink);
  font-family: Arial, Helvetica, "Liberation Sans", "Nimbus Sans", sans-serif;
  font-size: calc(var(--fs) * var(--z) * 1px);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
}

body.__accessbox-tool .fs-field .fs-input {
  position: absolute;
  left: calc(var(--pad) * var(--z) * 1px);
  right: calc(var(--pad) * var(--z) * 1px);
  top: calc((var(--bl) - .9715 * var(--fs)) * var(--z) * 1px);
  width: auto;
  height: calc(1.25 * var(--fs) * var(--z) * 1px);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none !important;
  background: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

body.__accessbox-tool .fs-field .fs-input:focus,
body.__accessbox-tool .fs-field .fs-input:focus-visible { outline: none !important; box-shadow: none; }

.fs-field[data-align="center"] .fs-input { text-align: center; }
.fs-field[data-align="right"] .fs-input { text-align: right; }

body.__accessbox-tool .fs-field .fs-area {
  top: calc(var(--pad) * var(--z) * 1px);
  bottom: calc(var(--pad) * var(--z) * 1px);
  height: auto;
  overflow: hidden;
  line-height: 1.2;
  resize: none;
  white-space: pre-wrap;
}

body.__accessbox-tool .fs-field .fs-select {
  cursor: pointer;
  text-overflow: ellipsis;
}

.fs-cells { position: absolute; inset: 0; pointer-events: none; }

.fs-cell {
  position: absolute;
  left: calc(var(--cx) * var(--z) * 1px);
  width: calc(var(--cw) * var(--z) * 1px);
  top: calc((var(--bl) - .9715 * var(--fs)) * var(--z) * 1px);
  height: calc(1.25 * var(--fs) * var(--z) * 1px);
  border-radius: 2px;
  text-align: center;
}

.fs-cell.is-active { background: color-mix(in srgb, var(--ab-accent) 16%, transparent); box-shadow: inset 0 -2px 0 var(--ab-accent); }

body.__accessbox-tool .fs-field .fs-comb-input {
  inset: 0;
  top: 0;
  width: 100%;
  height: 100%;
  color: transparent;
  caret-color: transparent;
  cursor: text;
}

body.__accessbox-tool .fs-field .fs-comb-input::selection { background: transparent; }

.fs-static { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.fs-line {
  position: absolute;
  left: calc(var(--lx) * var(--z) * 1px);
  top: calc((var(--ly) - .9715 * var(--fs)) * var(--z) * 1px);
  white-space: pre;
}

/* Signatures and initials */
.fs-sig-ink {
  position: absolute;
  inset: calc(1px * var(--z));
  color: var(--ink);
  pointer-events: none;
}

.fs-ink-svg { display: block; width: 100%; height: 100%; overflow: visible; }

.fs-ink-img {
  display: block;
  height: 100%;
  max-width: 100%;
  background: currentColor;
  -webkit-mask: var(--ink-src) left bottom / contain no-repeat;
  mask: var(--ink-src) left bottom / contain no-repeat;
}

.fs-flag {
  position: absolute;
  top: 50%;
  left: calc(3px * var(--z));
  display: inline-flex;
  align-items: center;
  gap: .35em;
  max-height: calc(100% - 2px);
  padding: .32em .7em .32em .55em;
  border-radius: 999px;
  color: #fff;
  background: var(--ab-accent);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--ab-accent) 35%, transparent);
  font: 750 clamp(9px, calc(var(--h) * var(--z) * .3px), 13px)/1 "Inter", system-ui, sans-serif;
  letter-spacing: .01em;
  white-space: nowrap;
  transform: translateY(-50%);
  pointer-events: none;
}

.fs-flag svg { width: 1.25em; height: 1.25em; flex: none; }

/* A narrow blank (initials on a short line) gets the pen alone, so the flag
   stays on the page instead of running off its edge. */
.fs-signature.is-empty,
.fs-initials.is-empty { container-type: inline-size; }

@container (max-width: 64px) {
  .fs-flag { left: 50%; gap: 0; padding: .36em; transform: translate(-50%, -50%); }
  .fs-flag-word { display: none; }
}

@media (hover: hover) {
  .fs-signature.is-empty:hover .fs-flag,
  .fs-initials.is-empty:hover .fs-flag { filter: brightness(1.08); scale: 1.05; }
}

/* Ticks */
.fs-check { display: grid; place-items: center; }
.fs-check.is-round { border-radius: 50%; }
.fs-mark-svg { width: 86%; height: 86%; }
.fs-check[data-origin="added"] { color: var(--ink); }

/* Whiteout */
.fs-whiteout { border-radius: 0; background: #fff; }
.fs-whiteout.is-selected,
.fs-whiteout:focus-visible { box-shadow: inset 0 0 0 1px rgba(25, 25, 24, .18); outline: none; }
.fs-whiteout.is-draft { outline: 1.5px dashed var(--ab-accent); outline-offset: 0; }

/* ---------- selection ---------- */

.fs-sel {
  z-index: 6;
  margin: -3px;
  width: calc(var(--w) * var(--z) * 1px + 6px);
  height: calc(var(--h) * var(--z) * 1px + 6px);
  border: 2px solid var(--ab-accent);
  border-radius: 6px;
  pointer-events: none;
}

.fs-sel[data-kind="whiteout"] { border-style: dashed; }

.fs-grip {
  position: absolute;
  top: 50%;
  left: -19px;
  display: grid;
  width: 14px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(25, 25, 24, .14);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transform: translateY(-50%);
}

.fs-grip svg { width: 10px; height: 14px; fill: currentColor; }
.fs-sel:not(.is-text) .fs-grip { display: none; }

.fs-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ab-accent);
  border-radius: 50%;
  background: #fff;
  pointer-events: auto;
  touch-action: none;
}

.fs-handle.is-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.fs-handle.is-e { top: 50%; right: -8px; cursor: ew-resize; transform: translateY(-50%); }
.fs-sel:not(.is-text) .fs-handle.is-e,
.fs-sel[data-kind="choice"] .fs-handle,
.fs-sel.is-fixed .fs-handle,
.fs-sel.is-fixed .fs-grip { display: none; }

/* A finger moves every field by its grip, and gets bigger targets. */
@media (hover: none) {
  .fs-sel:not(.is-fixed) .fs-grip { display: grid; left: -34px; width: 26px; height: 34px; }
  .fs-handle { width: 18px; height: 18px; }
  .fs-handle.is-se { right: -11px; bottom: -11px; }
  .fs-handle.is-e { right: -11px; }
}

.fs-mini {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  color: #f4f0e8;
  background: #191918;
  box-shadow: 0 10px 26px rgba(25, 25, 24, .28);
  pointer-events: auto;
  transform: translateX(-50%);
  white-space: nowrap;
}

.fs-sel.is-below .fs-mini { top: calc(100% + 9px); bottom: auto; }

.fs-mini button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.fs-mini button svg { width: 17px; height: 17px; }
.fs-mini button .fs-mark-svg { width: 15px; height: 15px; }
.fs-mini button[aria-pressed="true"] { color: #191918; background: #f4f0e8; }
.fs-mini button.is-danger { color: #ff9a85; }

body.__accessbox-tool .fs-mini .fs-mini-type {
  height: 30px;
  margin: 0 2px;
  padding: 0 24px 0 9px;
  border: 0;
  border-radius: 8px;
  color: #f4f0e8;
  background: rgba(255, 253, 248, .1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%23f4f0e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 6px center / 14px;
  box-shadow: none;
  cursor: pointer;
  font: 650 .74rem "Inter", system-ui, sans-serif;
  -webkit-appearance: none;
  appearance: none;
}

.fs-mini .fs-mini-type option { color: #191918; background: #fffdf8; }

@media (hover: hover) {
  .fs-mini button:hover { background: rgba(255, 253, 248, .12); }
  .fs-mini button[aria-pressed="true"]:hover { background: #f4f0e8; }
}

.fs-ghost {
  z-index: 4;
  display: grid;
  place-items: center start;
  border-radius: 3px;
  color: var(--text-ink);
  background: color-mix(in srgb, var(--ab-accent) 8%, transparent);
  outline: 1.5px dashed var(--ab-accent);
  opacity: .78;
  pointer-events: none;
  font: calc(11 * var(--z) * 1px) / 1 Arial, Helvetica, sans-serif;
}

.fs-ghost > span { padding-left: calc(2px * var(--z)); white-space: nowrap; }
.fs-ghost[data-tool="signature"],
.fs-ghost[data-tool="initials"],
.fs-ghost[data-tool="check"],
.fs-ghost[data-tool="cross"] { place-items: center; color: var(--ink); }
.fs-ghost .fs-ink-svg,
.fs-ghost .fs-mark-svg { width: 100%; height: 100%; }

/* Where a Word file is laid out to be pictured: drawn for real (html2canvas
   needs a laid-out element) but off the screen, and without the page shadow
   and gaps docx-preview gives its pages. */
.fs-docx-host {
  position: fixed;
  top: 0;
  left: -30000px;
  z-index: -1;
  pointer-events: none;
}

.fs-docx-host section.docx {
  margin: 0 !important;
  box-shadow: none !important;
}

/* The system date picker opens from here, over the date being chosen. */
.fs-date-picker {
  position: fixed;
  z-index: -1;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------- floating: hint, dock, zoom ---------- */

.fs-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 9px 15px;
  border-radius: 999px;
  color: #f4f0e8;
  background: #191918;
  box-shadow: 0 10px 28px rgba(25, 25, 24, .25);
  font: 600 .78rem/1.3 "Inter", system-ui, sans-serif;
  transform: translateX(-50%);
  pointer-events: none;
  animation: fs-drop-in .2s ease-out;
}

.fs-float {
  position: absolute;
  bottom: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(48, 42, 31, .16), 0 2px 6px rgba(48, 42, 31, .06);
}

.fs-dock {
  left: 50%;
  gap: 10px;
  padding: 5px 5px 5px 8px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.fs-dock-fields {
  display: none;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  cursor: pointer;
}

.fs-dock-fields svg { width: 19px; height: 19px; }

.fs-ring { display: block; width: 30px; height: 30px; flex: none; transform: rotate(-90deg); }
.fs-ring svg { display: block; width: 100%; height: 100%; }
.fs-ring circle { fill: none; stroke-width: 3.6; }
.fs-ring-track { stroke: color-mix(in srgb, var(--text) 10%, transparent); }
.fs-ring-fill { stroke: var(--ab-accent); stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; transition: stroke-dashoffset .4s cubic-bezier(.2, .8, .2, 1); }
.fs-dock.is-done .fs-ring-fill { stroke: #2d9b63; }

.fs-dock-text {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font: 650 .8rem "Inter", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-dock-next {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 1px 14px 0 16px;
  border: 0;
  border-radius: 999px;
  color: var(--bg);
  background: var(--text);
  cursor: pointer;
  font: 700 .8rem "Inter", system-ui, sans-serif;
}

.fs-dock-next svg { width: 16px; height: 16px; margin-top: -1px; }
.fs-dock-next.is-done { background: var(--ab-accent); color: #fff; }

@media (hover: hover) {
  .fs-dock-next:hover { background: var(--ab-accent); color: #fff; }
  .fs-dock-next.is-done:hover { filter: brightness(1.08); }
}

.fs-zoom {
  right: 18px;
  gap: 1px;
  height: 40px;
  padding: 0 4px;
  border-radius: 12px;
}

.fs-zoom button {
  display: grid;
  min-width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.fs-zoom button svg { width: 16px; height: 16px; }
.fs-zoom .fs-zoom-value { min-width: 50px; font: 600 .72rem "DM Mono", ui-monospace, monospace; }
.fs-zoom-page { padding: 0 8px 0 6px; border-left: 1px solid var(--border); color: var(--muted); font: 500 .7rem "DM Mono", ui-monospace, monospace; white-space: nowrap; }
.fs-zoom-page:empty { display: none; }

@media (hover: hover) {
  .fs-zoom button:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
}

/* ---------- the side panel ---------- */

.fs-side { padding-bottom: 40px; }

.fs-note {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.5;
}

.fs-rows { display: grid; gap: 2px; margin: 0 -8px; }

.fs-rows-page {
  margin: 10px 8px 4px;
  color: var(--muted);
  font: 600 .6rem "DM Mono", ui-monospace, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.fs-rows-page:first-child { margin-top: 0; }

.fs-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 10px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 7px 10px 7px 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.fs-row-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.fs-row-icon svg { width: 17px; height: 17px; }
.fs-row.is-sign .fs-row-icon { color: var(--ab-accent); background: color-mix(in srgb, var(--ab-accent) 12%, transparent); }
.fs-row-text { display: grid; min-width: 0; gap: 1px; }
.fs-row-label, .fs-row-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-row-label { font-size: .76rem; font-weight: 650; }
.fs-row-value { color: var(--muted); font-size: .7rem; }
.fs-row.is-filled .fs-row-value { color: var(--text-secondary); }

.fs-row-dot {
  width: 9px;
  height: 9px;
  border: 1.5px solid color-mix(in srgb, var(--ab-accent) 60%, var(--border));
  border-radius: 50%;
  box-sizing: border-box;
}

.fs-row.is-filled .fs-row-dot { border-color: #2d9b63; background: #2d9b63; }
.fs-row.is-selected { border-color: color-mix(in srgb, var(--ab-accent) 35%, transparent); background: color-mix(in srgb, var(--ab-accent) 8%, var(--surface)); }

@media (hover: hover) {
  .fs-row:hover:not(.is-selected) { background: color-mix(in srgb, var(--text) 5%, transparent); }
}

.fs-marks {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.fs-mark {
  position: relative;
  display: grid;
  height: 84px;
  padding: 10px 10px 24px;
  border: 1.5px dashed var(--line2);
  border-radius: 13px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.fs-mark.is-set { border-style: solid; border-color: var(--border); background: #fff; }
.fs-mark-art { display: grid; min-width: 0; min-height: 0; place-items: center; color: var(--ink); }
.fs-mark-art .fs-ink-svg { width: 100%; height: 100%; }
.fs-mark-art .fs-ink-img { margin: 0 auto; -webkit-mask-position: center; mask-position: center; }
.fs-mark-empty { color: color-mix(in srgb, var(--ab-accent) 85%, var(--text)); font-size: .74rem; font-weight: 650; text-align: center; }

.fs-mark-name {
  position: absolute;
  bottom: 7px;
  left: 10px;
  color: var(--muted);
  font: 600 .58rem "DM Mono", ui-monospace, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

@media (hover: hover) {
  .fs-mark:hover { border-color: var(--ab-accent); }
}

.fs-ink-pick { grid-template-columns: repeat(2, 1fr); }
.fs-ink-pick button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }

.fs-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.fs-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 10px;
}

.fs-field-row { display: grid; gap: 5px; min-width: 0; }
.fs-field-row.span-2 { grid-column: 1 / -1; }

.qp-sec .fs-field-row > span {
  color: var(--text-secondary);
  font: 650 .7rem/1.3 "Inter", system-ui, sans-serif;
}

.fs-field-row .media-input,
.fs-field-row .media-select { min-height: 38px; font-size: .78rem; }

.fs-forget {
  margin-top: 14px;
  color: #b4432f;
}

.fs-file { margin-bottom: 12px; }
.fs-name-row { margin-bottom: 12px; }
.fs-flatten { margin: 2px 0 10px; line-height: 1.4; }

.fs-receipt {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #2d9b63 30%, var(--border));
  border-radius: 13px;
  background: color-mix(in srgb, #2d9b63 6%, var(--surface));
}

.fs-receipt-row { display: flex; align-items: center; gap: 10px; }

.fs-receipt-tick {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #2d9b63;
}

.fs-receipt-tick svg { width: 16px; height: 16px; }
.fs-receipt-copy { min-width: 0; }
.fs-receipt-name { margin: 0; overflow: hidden; font-size: .76rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.fs-receipt-meta { margin: 2px 0 0; color: var(--muted); font-size: .68rem; }
.fs-receipt-actions { display: flex; gap: 8px; margin-top: 10px; }
.fs-receipt-actions .btn { flex: 1; min-height: 36px; font-size: .74rem; }

#downloadBtn.is-busy { cursor: progress; opacity: .7; }
#downloadBtn.is-busy svg { animation: fs-bob .9s ease-in-out infinite; }

/* ---------- typing on a phone ---------- */

.fs-editbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 80;
  padding: 9px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 -12px 34px rgba(48, 42, 31, .14);
}

.fs-editbar-head { display: flex; justify-content: space-between; gap: 12px; margin: 0 4px 7px; }
.fs-editbar-label { overflow: hidden; color: var(--text-secondary); font-size: .74rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.fs-editbar-pos { flex: none; color: var(--muted); font: 500 .68rem "DM Mono", ui-monospace, monospace; }
.fs-editbar-row { display: flex; align-items: flex-end; gap: 6px; }

body.__accessbox-tool .fs-editbar-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--ab-accent);
  border-radius: 12px;
  background: #fff;
  font: 400 16px/1.35 "Inter", system-ui, sans-serif;
  resize: none;
}

.fs-editbar-nav,
.fs-editbar-done {
  display: grid;
  height: 44px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.fs-editbar-nav { width: 40px; }
.fs-editbar-nav svg { width: 18px; height: 18px; }
.fs-editbar-done { padding: 0 14px; border-color: var(--text); color: var(--bg); background: var(--text); font: 700 .82rem "Inter", system-ui, sans-serif; }

body.is-editing .fs-dock,
body.is-editing .fs-zoom,
body.is-editing .fs-sel > :not(.fs-mini),
body.is-editing .fs-mini { visibility: hidden; }

/* ---------- making a signature ---------- */

.qp-sheet.fs-ink { width: min(600px, 100%); }

.fs-ink-target { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }

.fs-ink-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.fs-ink-tabs button {
  position: relative;
  padding: 9px 12px 11px;
  border: 0;
  color: var(--muted);
  background: none;
  cursor: pointer;
  font: 650 .8rem "Inter", system-ui, sans-serif;
}

.fs-ink-tabs button[aria-selected="true"] { color: var(--text); }

.fs-ink-tabs button[aria-selected="true"]::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--ab-accent);
  content: "";
}

.fs-ink-names {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.fs-ink .fs-field-row > span { color: var(--text-secondary); font: 650 .7rem/1.3 "Inter", system-ui, sans-serif; }

.fs-styles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.fs-ink.is-initials .fs-styles { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

.fs-style {
  display: grid;
  height: 74px;
  place-items: center;
  overflow: hidden;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.fs-style[aria-checked="true"] {
  border-color: var(--ab-accent);
  background: color-mix(in srgb, var(--ab-accent) 5%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ab-accent) 16%, transparent);
}

.fs-style:disabled { cursor: not-allowed; opacity: .35; }
.fs-styles.is-empty .fs-style { color: color-mix(in srgb, var(--ink) 35%, transparent); }

.fs-style-text {
  max-width: 100%;
  overflow: hidden;
  font-size: 34px;
  line-height: 1.7;
  white-space: nowrap;
}

@media (hover: hover) {
  .fs-style:hover:not(:disabled):not([aria-checked="true"]) { border-color: var(--border-hover); }
}

.fs-pad,
.fs-upload {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2.6 / 1;
  overflow: hidden;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.fs-ink.is-initials .fs-pad { aspect-ratio: 2 / 1; max-width: 380px; margin: 0 auto; }

#padCanvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.fs-pad-line {
  position: absolute;
  right: 7%;
  bottom: 27%;
  left: 7%;
  border-bottom: 1.5px dashed color-mix(in srgb, var(--text) 22%, transparent);
}

.fs-pad-x {
  position: absolute;
  bottom: calc(27% + 6px);
  left: 7%;
  color: color-mix(in srgb, var(--text) 30%, transparent);
  font: 400 1.2rem/1 "Inter", system-ui, sans-serif;
}

.fs-pad-hint {
  position: absolute;
  top: 34%;
  left: 50%;
  color: color-mix(in srgb, var(--text) 32%, transparent);
  font: 600 .86rem "Inter", system-ui, sans-serif;
  transform: translate(-50%, -50%);
  transition: opacity .2s;
  pointer-events: none;
}

.fs-pad.has-ink .fs-pad-hint { opacity: 0; }

.fs-pad-tools { display: flex; justify-content: flex-end; gap: 16px; margin-top: 8px; }

.fs-upload {
  display: grid;
  place-items: center;
  border-style: dashed;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, #f1ede5 25%, transparent 25%), linear-gradient(-45deg, #f1ede5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1ede5 75%), linear-gradient(-45deg, transparent 75%, #f1ede5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.fs-upload-empty { display: grid; gap: 4px; padding: 0 20px; color: var(--text-secondary); font-size: .8rem; text-align: center; }
.fs-upload-empty span { color: var(--muted); font-size: .72rem; }
.fs-upload-tune { margin-top: 12px; }
.fs-upload-tune label { color: var(--text-secondary); font-size: .74rem; font-weight: 650; }
.fs-upload-tune input[type="range"] { accent-color: var(--ab-accent); }

.fs-ink-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.fs-ink-colors { display: flex; gap: 6px; }

.fs-ink-colors button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.fs-ink-colors .fs-swatch { width: 20px; height: 20px; }
.fs-ink-colors button[aria-checked="true"] { border-color: var(--text); }
.fs-ink-remember { flex: 1; min-width: 160px; }
.fs-ink-foot .btn-primary { min-width: 160px; }

/* ---------- dialogs, toast, drop cover ---------- */

.fs-modal,
.fs-password {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 19, 17, .38);
  animation: fs-fade .15s ease-out;
}

.fs-modal-card {
  width: min(410px, 100%);
  padding: 22px 22px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(25, 25, 24, .3);
}

.fs-modal-card h2 { margin: 0 0 8px; font: 800 1.05rem/1.25 "Manrope", "Inter", system-ui, sans-serif; letter-spacing: -.02em; }
.fs-modal-card p { margin: 0 0 16px; color: var(--text-secondary); font-size: .82rem; line-height: 1.55; }
.fs-modal-card p.is-error { color: #b4432f; }
.fs-modal-card .media-input { margin-bottom: 16px; }
.fs-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.fs-toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(520px, calc(100vw - 24px));
  padding: 11px 12px 11px 16px;
  border-radius: 14px;
  color: #f4f0e8;
  background: #191918;
  box-shadow: 0 14px 40px rgba(25, 25, 24, .3);
  font: 550 .8rem/1.4 "Inter", system-ui, sans-serif;
  transform: translateX(-50%);
}

.fs-toast.is-in { animation: fs-toast-in .22s cubic-bezier(.2, .8, .2, 1); }

/* Over the middle of the stage, where the dock is, not of the window. */
@media (min-width: 841px) {
  body:has(.fs-viewer:not([hidden])) .fs-toast { left: calc((100% - var(--qp-side-w)) / 2); }
}

.fs-sheet-count {
  margin-left: 4px;
  color: var(--muted);
  font: 500 .8rem "DM Mono", ui-monospace, monospace;
  letter-spacing: 0;
}

.fs-toast-action {
  flex: none;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 253, 248, .14);
  cursor: pointer;
  font: 700 .76rem "Inter", system-ui, sans-serif;
}

.fs-dropcover {
  position: fixed;
  inset: 10px;
  z-index: 100;
  display: grid;
  place-items: center;
  border: 2px dashed var(--ab-accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--ab-accent) 10%, rgba(244, 240, 232, .85));
  pointer-events: none;
}

.fs-dropcover span {
  padding: 12px 20px;
  border-radius: 999px;
  color: #fff;
  background: var(--ab-accent);
  font: 700 .9rem "Inter", system-ui, sans-serif;
}

.fs-help-keys { margin-top: 4px; }
@media (hover: none) { .fs-help-keys { display: none; } }

/* ---------- narrow windows and phones ---------- */

@media (max-width: 840px) {
  .qp-work.fs-work { display: block; }
  .qp-stage.fs-stage { height: 100%; overflow: hidden; }
  .fs-side { display: none; }
  .fs-dock-fields { display: grid; }
  .fs-pages { padding: 16px 12px 120px; gap: 14px; }
  .fs-stage > .fs-drop { inset: 12px; }

  .fs-dock {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    padding-left: 5px;
    transform: none;
  }

  .fs-dock-text { flex: 1; }
  .fs-zoom { display: none; }
  .fs-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  #panelSheet .qp-sheet-body { padding-top: 0; }
  #panelSheet .fs-panel > .qp-sec:first-child { padding-top: 6px; }
  /* the sheet's own title already says Fields, with the count */
  #panelSheet .fs-fields-sec > .qp-sec-title { justify-content: flex-end; margin-bottom: 6px; }
  #panelSheet .fs-fields-sec > .qp-sec-title > span { display: none; }
  #panelSheet .fs-fields-sec > .qp-sec-title:not(:has(.qp-link:not([hidden]))) { display: none; }
}

@media (max-width: 520px) {
  .fs-tools .qp-btn:not(.is-icon) span { font-size: .74rem; }
  .fs-styles { grid-template-columns: 1fr; }
  .fs-ink.is-initials .fs-styles { grid-template-columns: repeat(2, 1fr); }
  .fs-style { height: 66px; }
  .fs-ink-foot .btn-primary { flex: 1 0 100%; }
  .fs-details { grid-template-columns: 1fr; }
  .fs-field-row.span-2 { grid-column: auto; }
}

/* ---------- motion ---------- */

@keyframes fs-shimmer { to { background-position: -300% 0; } }
@keyframes fs-bob { 50% { transform: translateY(-3px) rotate(-3deg); } }
@keyframes fs-fade { from { opacity: 0; } }
@keyframes fs-drop-in { from { opacity: 0; transform: translate(-50%, -6px); } }
@keyframes fs-toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes fs-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ab-accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .fs-page:not(.is-drawn)::before,
  .fs-drop.is-busy .drop-icon,
  #downloadBtn.is-busy svg { animation: none; }
}
