/* THE SYSTEM (P1-15a tier 1, part one).
 *
 * There was no design to polish: 1,170 lines of CSS declared TWELVE distinct
 * font sizes -- one of them 12.5px -- TWENTY-THREE spacing values including
 * 1, 3, 5, 7 and 9px, ELEVEN border radii, and SIXTY hard-coded colours
 * beside the eleven tokens. Refining that means deciding a system and then
 * applying it, which is two activities, and ROADMAP 5e says the second half
 * waits for the pilot: styling chosen before anybody has driven the product
 * is styling chosen twice.
 *
 * So this is the DECISIONS half and it is deliberately INERT. Every value
 * below is a literal already in the file, and every one was chosen because it
 * was already DOMINANT -- measured, not picked. The first radius scale here
 * was picked rather than counted and covered 17 declarations where the
 * measured one covers 42; it was thrown away.
 *
 * Off-scale values are REPORTED rather than snapped, which is the rule
 * PdfGuard follows: snapping 12.5px to 12px is a visible change on a surface
 * nobody has driven yet, and that worklist belongs to the post-pilot pass.
 * `UiScaleTest` pins the inventory so it can only go DOWN, which is
 * ProductNameTest's shape while the rename is pending.
 */
:root {
  /* TYPE. Body is 14px, set in the `font` shorthand on `body` and inherited,
   * so it is named here and not re-declared. */
  --text-xs: 11px;   /* captions, metadata, the status line */
  --text-sm: 12px;   /* secondary labels */
  --text-md: 13px;   /* the dominant size: controls, list rows, panels */
  --text-base: 14px; /* body, inherited */
  --text-lg: 15px;   /* panel headings */
  --text-xl: 17px;   /* page headings */
  --text-2xl: 20px;  /* the one display size */

  /* SPACE. A 2px rhythm, because the file's four commonest values are
   * 8, 6, 4 and 14 -- an 8-point grid would have made every one of them
   * off-scale, which is a scale nobody adopts. */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-7: 14px;
  --space-8: 16px;
  --space-10: 20px;
  --space-12: 24px;

  /* RADIUS, counted: 4px appears 20 times, 6px 10, 2px 9, 10px 3. */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;   /* a shape rather than a step on the scale */


  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #6b7280;
  --line: #d8dbe0;
  --accent: #1f5fd0;
  --field: rgba(31, 95, 208, 0.10);
  --field-line: rgba(31, 95, 208, 0.55);
  --readonly: rgba(120, 120, 120, 0.12);
  --blocked: rgba(200, 40, 40, 0.14);
  --blocked-line: rgba(200, 40, 40, 0.65);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  display: flex; align-items: center; gap: var(--space-8);
  padding: var(--space-5) var(--space-8); background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 3px; }
.tag { color: var(--muted); font-size: var(--text-sm); }
.spacer { flex: 1; }

.layout {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  height: calc(100vh - 45px);
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: var(--space-7);
}
.panel.right {
  border-right: none; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
#fieldList { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.panel h2 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.8px;
            color: var(--muted); margin: 0 0 var(--space-2); }
.hint { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-5); }

.panel ul, #fieldList { list-style: none; margin: 0; padding: 0; }
.panel .doc-list li {
  padding: 7px 9px; border-radius: var(--radius-md); cursor: pointer;
  font-size: var(--text-md); word-break: break-word;
}
.panel .doc-list li:hover { background: #eef1f6; }
.panel .doc-list li.active { background: var(--accent); color: #fff; }
.panel .doc-list li .cat { display: block; font-size: var(--text-xs); opacity: 0.65; }

#fieldList li {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid #eef0f3; font-size: var(--text-sm);
  display: flex; justify-content: space-between; gap: var(--space-4); cursor: pointer;
}
#fieldList li:hover { background: #f2f5fa; }
#fieldList .fname { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
                    word-break: break-all; }
#fieldList .ftype { color: var(--muted); white-space: nowrap; }

/* No padding here: a sticky child sticks to the scrollport's PADDING box, so
   20px of padding would leave a strip of page showing above the toolbar as it
   scrolled underneath. The padding moves to the things inside instead. */
.stage { overflow: auto; padding: 0; }
.pages { display: flex; flex-direction: column; align-items: center; gap: var(--space-10);
         padding: 0 var(--space-10) var(--space-10); }

.page-wrap {
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  background: #fff;
}
.page-wrap canvas { display: block; }

/* The field layer: real DOM controls positioned over the rendered page. */
.field-layer { position: absolute; inset: 0; }
.field-layer.hidden { display: none; }

.field-layer input[type="text"],
.field-layer textarea,
.field-layer select {
  position: absolute;
  font: inherit;
  padding: 0 var(--space-1);
  border: 1px solid var(--field-line);
  background: var(--field);
  color: #10233f;
  border-radius: var(--radius-xs);
}
/* Checkboxes and radios, drawn rather than left to the platform.
   A widget rect is often tiny -- 7pt on a real government form -- and a native
   control at 7px is invisible against the page and almost impossible to hit.
   Every other viewer fills the widget rect with a tinted box, so the field is
   as visible as a text field is. */
.field-layer input[type="checkbox"],
.field-layer input[type="radio"] {
  position: absolute;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--field);
  border: 1px solid var(--field-line);
  box-sizing: border-box;
  cursor: pointer;
  padding: 0;
}
.field-layer input[type="radio"] { border-radius: 50%; }
.field-layer input[type="checkbox"]:checked,
.field-layer input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
/* The tick is drawn with a border rather than a glyph: at 7px a character is
   unreadable, and two rotated edges stay legible at any size. */
.field-layer input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 32%; top: 8%;
  width: 26%; height: 58%;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.field-layer input[type="radio"]:checked::after {
  content: ''; position: absolute; inset: 22%;
  border-radius: 50%; background: #fff;
}
.field-layer input[type="checkbox"]:disabled,
.field-layer input[type="radio"]:disabled { cursor: default; opacity: 0.6; }
.field-layer input:focus, .field-layer textarea:focus, .field-layer select:focus {
  outline: 2px solid var(--accent); outline-offset: 0; background: #fff;
}
.field-layer [data-readonly="true"] { background: var(--readonly); border-style: dashed; }
.field-layer .blocked {
  position: absolute; background: var(--blocked);
  border: 1px dashed var(--blocked-line); border-radius: var(--radius-xs);
}
/* A signature field is an invitation, not a refusal.
   It used to be drawn in `.blocked` red alongside UNSUPPORTED and BUTTON, so
   the one field on the page somebody is meant to act on looked like the one
   thing this viewer could not handle. Accent-coloured and dashed: dashed
   because it is empty and waiting, accent because it is the same colour as
   every other thing here that can be used. */
.field-layer .signature-field {
  position: absolute; font: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--field-line); border-radius: var(--radius-xs);
  background: var(--field); color: var(--accent);
  letter-spacing: 0.4px; padding: 0 var(--space-1); overflow: hidden; white-space: nowrap;
}
.field-layer .signature-field:hover:not(:disabled) {
  background: rgba(31, 95, 208, 0.18); border-style: solid;
}
.field-layer .signature-field:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
/* Signed, and therefore finished: a PAdES signature covers a byte range, so
   there is nothing further to do here (ADR 11). Solid and calm rather than
   red -- this is a completed thing, not a rejected one. */
.field-layer .signature-field.signed {
  border-style: solid; border-color: #1c7a3e; color: #1c7a3e;
  background: rgba(28, 122, 62, 0.10); cursor: default;
}
/* Sealed, but nothing was signed HERE. Muted rather than red: the document
   being finished is not an error, and the field standing empty is a fact
   about the form rather than a fault. What it must not do is look like the
   green one above, which is what it used to do. */
.field-layer .signature-field.locked {
  border-style: dashed; border-color: #8b93a1; color: #6b7280;
  background: rgba(107, 114, 128, 0.07); cursor: default;
}

.field-layer .flash { animation: flash 1.1s ease-out; }
@keyframes flash { from { background: #ffe680; } to { background: var(--field); } }

.warnings { margin: 0 auto var(--space-8); max-width: 900px; display: grid; gap: var(--space-4);
            padding: 0 var(--space-10); }
.warn {
  padding: 9px var(--space-6); border-radius: var(--radius-md); font-size: var(--text-md);
  border-left: 4px solid; background: #fff;
}
.warn.INFO  { border-color: #7a8598; }
.warn.WARN  { border-color: #d08b1f; background: #fff8ec; }
.warn.BLOCK { border-color: #c62828; background: #fdeeee; }
.warn .code { font-family: ui-monospace, Menlo, monospace; font-size: var(--text-xs);
              color: var(--muted); display: block; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.btn {
  font: inherit; padding: 5px var(--space-6); border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover:not(:disabled) { background: #eef1f6; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1a51b4; }
.btn.dirty { box-shadow: 0 0 0 2px rgba(208, 139, 31, 0.5); }
/* A destructive button is OUTLINED red rather than filled: filled red reads as
   the primary action on the page, and the primary action is never the one that
   destroys something. Same colours as .app-dialog-btn.danger, so the control
   and the dialog it opens agree about what kind of act this is. */
/* A list of records rather than a bulleted list of prose: these rows are
   dated entries, and a bullet in front of each one reads as a point being
   made. */
ul.plain { list-style: none; padding: 0; margin: var(--space-4) 0; }
ul.plain li { padding: var(--space-2) 0; }

.btn.danger { border-color: #c62828; color: #c62828; }
.btn.danger:hover:not(:disabled) { background: #fdeeee; }

.status { font-size: var(--text-sm); color: var(--muted); min-width: 130px; }
.status.ok { color: #1c7a3e; }
.status.err { color: #c62828; }

.blocked-note {
  margin: 0 auto var(--space-8); max-width: 900px; width: calc(100% - 40px);
  padding: 9px var(--space-6); border-radius: var(--radius-md); font-size: var(--text-md);
  border-left: 4px solid #c62828; background: #fdeeee;
}

.upload {
  display: block; text-align: center; cursor: pointer;
  padding: var(--space-7) var(--space-5); margin-bottom: var(--space-5);
  border: 1.5px dashed var(--line); border-radius: 8px;
  transition: background 0.12s, border-color 0.12s;
}
.upload:hover, .upload.over { border-color: var(--accent); background: #f2f6fd; }
.upload-label { display: block; font-weight: 600; font-size: var(--text-md); color: var(--accent); }
.upload-hint { display: block; font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-1); }

.upload-msg {
  font-size: var(--text-sm); padding: var(--space-4) var(--space-5); border-radius: var(--radius-md); margin-bottom: var(--space-5);
  border-left: 3px solid;
}
.upload-msg.ok  { border-color: #1c7a3e; background: #eef8f1; }
.upload-msg.err { border-color: #c62828; background: #fdeeee; }
.upload-msg ul { margin: var(--space-3) 0 0; padding-left: var(--space-8); }

.panel .doc-list li { position: relative; padding-right: 26px; }
.panel .doc-list li .del {
  position: absolute; right: 4px; top: 5px;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: var(--text-lg); line-height: 1; padding: var(--space-1) 5px;
  border-radius: var(--radius-sm); opacity: 0;
}
.panel .doc-list li:hover .del { opacity: 1; }
.panel .doc-list li .del:hover { background: #fdeeee; color: #c62828; }
.panel .doc-list li.active .del { color: #fff; }

/* The trash.

   Its rows are NOT document rows: there is nothing to open, so there is no
   row-open button and no padding reserved for a corner delete control. The two
   actions are always visible rather than revealed on hover, which is the
   opposite of the `.del` above and is deliberate -- somebody is in this list
   because they are looking for a specific thing to put back, and a control
   they have to find by pointing at the right row is one more step in the one
   place the product is apologising for itself. Always visible also means no
   `:focus-within` rule is owed. */
.panel .doc-list li.trash-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "name restore purge" "detail restore purge";
  gap: 0 var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-4);
}
.trash-row .trash-name {
  grid-area: name;
  font-size: var(--text-md);
  /* A long form name must not push the buttons off the row. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trash-row .trash-detail {
  grid-area: detail; font-size: var(--text-xs); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trash-row .trash-restore, .trash-row .trash-purge {
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: var(--text-xs); padding: 3px 7px; border-radius: var(--radius-sm); white-space: nowrap;
}
.trash-row .trash-restore { grid-area: restore; }
.trash-row .trash-purge   { grid-area: purge; color: #c62828; }
.trash-row .trash-restore:hover { background: #eef1f6; }
.trash-row .trash-purge:hover   { background: #fdeeee; }
.trash-row .trash-restore:focus-visible, .trash-row .trash-purge:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* The document toolbar.
   An island centred over the page rather than a bar across the window: it
   belongs to the document under it, which is also what makes the viewer a
   self-contained thing rather than a region of this page. */
.doctools {
  position: sticky; top: 0; z-index: 5;
  padding: var(--space-7) var(--space-10) var(--space-5);
  background: linear-gradient(var(--bg) 78%, rgba(244, 245, 247, 0));
}
.doctools-row {
  display: flex; align-items: stretch; justify-content: center;
  flex-wrap: wrap; gap: var(--space-2);
  width: fit-content; max-width: 100%; margin: 0 auto;
  padding: 5px var(--space-4); border-radius: var(--radius-lg);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.doctools-sep {
  width: 1px; margin: var(--space-2) var(--space-3); background: var(--line); align-self: stretch;
}
.doctools-field {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-sm); color: var(--muted); padding: 0 var(--space-4); white-space: nowrap;
}
.doctools-field select { font: inherit; }
.doctools-field.check { gap: 5px; }
/* Reserved whether or not there is anything to say, so arming a tool does not
   push the page down by a line. */
.doctools .status {
  min-height: 17px; margin: var(--space-3) auto 0; max-width: 620px;
  text-align: center; min-width: 0;
}

.tools { display: inline-flex; gap: var(--space-1); }
/* Icon above caption. The caption is real text on screen AND the string each
   button is named by -- see the comment in index.html for why that is stated
   rather than left to be inferred. */
.tool {
  font: inherit; font-size: var(--text-xs); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-width: 58px; padding: var(--space-3) var(--space-4) 5px;
  border: 1px solid transparent; background: none; color: var(--ink);
  border-radius: 8px;
}
.tool-icon {
  width: 22px; height: 22px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Cover is the one tool whose shape IS its meaning, so it is filled. */
.tool-icon .filled { fill: currentColor; fill-opacity: 0.16; }
.tool-caption { line-height: 1; }
.tool:hover:not(:disabled) { background: #eef1f6; }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.tool:disabled { opacity: 0.4; cursor: not-allowed; }
.tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool.primary:not(:disabled) { color: var(--accent); }
.tool.primary:not(:disabled):hover { background: #eaf1fd; }
/* Unsaved work is the one state worth interrupting the row's calm for. */
.tool.dirty { box-shadow: inset 0 0 0 2px rgba(208, 139, 31, 0.55); }

/* While a tool is armed the page is a drawing surface, so the field layer
   must not swallow the clicks meant for it. That also makes the form's own
   fields stop responding, which is why Fill is a visible mode rather than
   the absence of one -- and why the fields are dimmed while it is not on,
   so the page shows that it is in another mode rather than looking broken. */
.page-wrap.tool-armed .field-layer { pointer-events: none; opacity: 0.45; }
.page-wrap.tool-armed { cursor: crosshair; }

/* The layer spans the whole page so its children can be placed in page
   coordinates, and it is appended after the field layer, so it sits on top.
   Without this it is a lid: every click meant for one of the form's own
   fields landed on an empty div instead, which is exactly what "none of the
   fields are editable" looks like. Only the annotations themselves are
   targets. The drawing gestures listen on the page wrapper rather than on
   this layer, so they still fire from whatever is underneath. */
.annot-layer { position: absolute; inset: 0; pointer-events: none; }
.annot {
  position: absolute; cursor: move; pointer-events: auto;
  border: 1px dashed transparent; border-radius: var(--radius-xs);
}
.annot:hover { border-color: var(--accent); }
.annot:focus { outline: none; }
.annot.selected { border-style: solid; border-color: var(--accent); }
/* While its text is being edited the object itself is hidden, or the editor
   sits on top of a copy of the same words. */
.annot.being-edited { visibility: hidden; }
.annot.text {
  color: #10233f; white-space: pre;
  display: flex; align-items: center;
}
/* The text clips, the BOX does not. `overflow: hidden` on the box clipped the
   resize handles and the remove button out of existence -- they sit a few
   pixels outside it by design, so they were painted nowhere and hit-tested
   nowhere, and dragging a handle silently moved the object instead of
   resizing it. The span clips the words exactly as the renderer clips them. */
.annot-text { overflow: hidden; white-space: pre; max-width: 100%; }
/* A cover is white on white, so in the EDITOR it carries an outline saying
   where it is -- nothing is added to the page, which still has to print
   identically. Without it the only way to find one was to remember. */
.annot.whiteout { background: #fff; border-color: rgba(0,0,0,0.38); }
.page-wrap.preparing .annot.whiteout { border-color: rgba(0,0,0,0.55); }
/* A shape fills its box exactly, because the box IS the shape's geometry --
   the same rectangle the renderer draws into. */
/* A sticker: a preparer's flag, never drawn into the document. Red because
   that is what every tool that does this uses and what somebody scanning a
   form is looking for. */
.annot.sticker {
  display: flex; align-items: center;
  /* No background and no border of its own: the TAB is an SVG behind the
     caption, so the box stays a plain rectangle that the handles and the
     remove button can sit outside of. A border here would draw a second,
     square outline around a shape that is not square. */
  background: none; border-color: transparent; overflow: visible; cursor: move;
}
.annot.sticker .sticker-tab {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; overflow: visible;
}
.annot.sticker .sticker-flag {
  position: relative; z-index: 1;
  /* Padded to the left of the point, so a full twelve characters never run
     into the part of the tab that does the pointing. */
  padding: 0 20% 0 5%;
  font-weight: 700; letter-spacing: 0.3px;
  text-transform: uppercase; color: #fff; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  /* The palette runs from a mid yellow to a dark blue and the caption sits on
     all five, so it is white with a shadow rather than a colour picked per
     hue -- legible on the light ones without being a second thing to keep in
     step with the list. */
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
}
/* The point is the half that says which way the tab aims, so the remove
   button moves off it to the LEFT. On the right it sat exactly on the point
   and hid it. */
.annot.sticker .remove { left: -9px; right: auto; }
/* Answered, so the flag goes rather than being deleted -- it has to come back
   if the field is emptied again.

   `visibility: hidden` and not `opacity: 0`: an element at zero opacity is
   still in the accessibility tree, so a screen reader would go on announcing
   an instruction that no longer applies, and it is still "visible" to
   anything that asks. Not `display: none` either -- the element keeps its box,
   so a re-render does not have to rebuild it. */
.annot.sticker.done { visibility: hidden; pointer-events: none; }

.annot.rectangle svg, .annot.ellipse svg, .annot.line svg,
.annot.arrow svg, .annot.tick svg, .annot.cross svg {
  display: block; width: 100%; height: 100%; overflow: visible;
}
.annot.signature img { width: 100%; height: 100%; object-fit: contain; }
.annot .remove {
  position: absolute; top: -9px; right: -9px; width: 18px; height: 18px;
  border-radius: 50%; border: none; background: #c62828; color: #fff;
  font-size: var(--text-sm); line-height: 1; cursor: pointer; opacity: 0; padding: 0;
  z-index: 2;
}
.annot:hover .remove, .annot:focus-within .remove { opacity: 1; }
/* Hidden while selected: it overlaps the middle-right resize handle on a box
   the height of one line, which is most of them. The property bar carries
   Delete instead. */
.annot.selected .remove { display: none; }

/* Resize handles: item 8. Shown only for the selected object, because eight
   dots on everything under the pointer is a page of confetti. */
.annot .handle { display: none; }
.annot.selected .handle {
  display: block; position: absolute; width: 8px; height: 8px;
  background: #fff; border: 1px solid var(--accent); border-radius: var(--radius-xs);
}
.annot.selected .handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.annot.selected .handle.n  { left: calc(50% - 4px); top: -5px; cursor: ns-resize; }
.annot.selected .handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.annot.selected .handle.e  { right: -5px; top: calc(50% - 4px); cursor: ew-resize; }
.annot.selected .handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.annot.selected .handle.s  { left: calc(50% - 4px); bottom: -5px; cursor: ns-resize; }
.annot.selected .handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.annot.selected .handle.w  { left: -5px; top: calc(50% - 4px); cursor: ew-resize; }

/* The in-place text editor: item 5. Sized and positioned as the finished
   text will be, so placing it looks like typing on the page. */
.annot-editor {
  position: absolute; pointer-events: auto; z-index: 3;
  font-family: inherit; color: #10233f; line-height: 1;
  padding: 0 1px; margin: 0;
  border: 1px solid var(--accent); border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.96);
}
.annot-editor:focus { outline: none; box-shadow: 0 0 0 2px rgba(31,95,208,0.25); }

/* The property bar: attached to the object rather than parked in a panel. */
.annot-props {
  position: absolute; pointer-events: auto; z-index: 3;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 3px 7px; border-radius: var(--radius-md); font-size: var(--text-xs); color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12); white-space: nowrap;
}
.annot-props select { font: inherit; }

/* ---- Prepare Form: laying real fields onto a page (ADR 15) ---- */

.doctools-mode {
  display: flex; justify-content: center; gap: var(--space-2); margin: 0 auto var(--space-3);
  width: fit-content; padding: 3px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
}
.doctools-mode .mode {
  font: inherit; font-size: var(--text-sm); cursor: pointer; padding: var(--space-2) var(--space-6);
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: none; color: var(--ink);
}
.doctools-mode .mode:hover { background: #eef1f6; }
.doctools-mode .mode.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* Its own layer, so the marks and the fields never fight over a click: only
   one of the two is on screen at a time. */
.field-place-layer { position: absolute; inset: 0; pointer-events: none; }
.page-wrap.placing { cursor: crosshair; }
/* While preparing, the form's own fields are not what is being edited: they
   sit above the placement layer, so leaving them clickable means a field
   placed near one lands on it instead. */
.page-wrap.preparing .field-layer { pointer-events: none; opacity: 0.45; }

/* Marks are a different case, because Cover IS offered while preparing --
   covering a printed rule before putting a field over it is the common
   reason to be in this mode at all. Dimming them to 0.45 made a white cover
   on a white page impossible to find, and a cover somebody cannot find is
   one they cannot remove either. So they stay at full strength and stay
   clickable, and give up the next click only while a field tool is armed,
   because then placement is what the click is for. */
.page-wrap.preparing.placing .annot { pointer-events: none; }

.placed-field {
  position: absolute; pointer-events: auto; cursor: move;
  border: 1.5px solid var(--accent); border-radius: var(--radius-xs);
  background: rgba(31, 95, 208, 0.10);
  display: flex; align-items: center; overflow: visible;
}
.placed-field:focus { outline: none; }
.placed-field.selected { box-shadow: 0 0 0 2px rgba(31,95,208,0.35); }
.placed-field.checkbox, .placed-field.radio { border-radius: var(--radius-xs); }
.placed-field.radio { border-radius: 50%; }
.placed-field.signature { border-style: dashed; }

/* The label the prepared form will announce, not the generated name. Clipped
   inside the box so a long one cannot spill over the page. */
.placed-tag {
  font-size: 10px; line-height: 1; color: #10233f; padding: 0 3px;
  overflow: hidden; white-space: nowrap; max-width: 100%;
  pointer-events: none;
}
/* The field's NAME rather than anything it will contain. Set apart from a
   value, because a box reading "Text" in ordinary type looks like something
   somebody typed into it. */
.placed-tag.is-name { opacity: 0.5; font-style: italic; }
/* A tick box is about the size of its own border, so a word inside it would
   be a smudge. Its name is on the property panel and in its accessible name. */
.placed-field.checkbox .placed-tag, .placed-field.radio .placed-tag { display: none; }

.placed-field .handle { display: none; }
.placed-field.selected .handle {
  display: block; position: absolute; width: 8px; height: 8px;
  background: #fff; border: 1px solid var(--accent); border-radius: var(--radius-xs);
}
.placed-field.selected .handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.placed-field.selected .handle.n  { left: calc(50% - 4px); top: -5px; cursor: ns-resize; }
.placed-field.selected .handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.placed-field.selected .handle.e  { right: -5px; top: calc(50% - 4px); cursor: ew-resize; }
.placed-field.selected .handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.placed-field.selected .handle.s  { left: calc(50% - 4px); bottom: -5px; cursor: ns-resize; }
.placed-field.selected .handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.placed-field.selected .handle.w  { left: -5px; top: calc(50% - 4px); cursor: ew-resize; }

/* What the field IS, rather than what it looks like: a placed field has no
   appearance to speak of, and what is expensive to get wrong is its name,
   whether it must be answered and how long it may be. */
.placed-props {
  position: absolute; pointer-events: auto; z-index: 4;
  display: grid; gap: var(--space-3); width: 240px; padding: 9px var(--space-5);
  border-radius: 8px; font-size: var(--text-sm);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0,0,0,0.16);
}
.placed-prop { display: grid; gap: var(--space-1); }
.placed-prop > span { font-size: var(--text-xs); color: var(--muted); }
.placed-prop input[type="text"], .placed-prop input[type="number"],
.placed-prop textarea {
  font: inherit; padding: 3px 5px; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.placed-prop input[type="checkbox"] { justify-self: start; }
.placed-props-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-1);
}
.placed-props-title { font-weight: 600; }
.placed-props-close {
  font: inherit; font-size: var(--text-lg); line-height: 1; cursor: pointer;
  padding: 1px var(--space-3) 3px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; color: var(--muted);
}
.placed-props-close:hover { background: #eef1f6; color: var(--ink); }
.placed-props-actions { display: flex; gap: var(--space-3); justify-content: space-between; margin-top: var(--space-2); }
.placed-props .placed-save {
  font: inherit; cursor: pointer; padding: var(--space-2) var(--space-7); border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.placed-props .placed-save:hover { filter: brightness(1.08); }
.placed-props .placed-save:disabled { opacity: 0.6; cursor: default; }
.placed-props .placed-del {
  font: inherit; cursor: pointer; padding: var(--space-2) var(--space-5); border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: #c62828;
}
.placed-props .placed-del:hover { background: #fdeeee; border-color: #c62828; }
.annot-props input[type="color"] {
  width: 24px; height: 20px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: none;
}
.annot-toggle {
  font: inherit; cursor: pointer; min-width: 22px; padding: 1px 5px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); line-height: 1.3;
}
.annot-toggle:hover { background: #eef1f6; }
.annot-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.annot-toggle.bold { font-weight: 700; }
.annot-toggle.italic { font-style: italic; font-family: Georgia, serif; }
/* The three alignment buttons are one glyph, so the shape has to carry which
   is which: the bars are clipped to the side they align to. */
.annot-toggle.align { letter-spacing: -1px; }
.annot-toggle.align.left   { text-align: left; }
.annot-toggle.align.center { text-align: center; }
.annot-toggle.align.right  { text-align: right; }
.annot-toggle.align.left::after   { content: "\2014"; display: block; font-size: 8px;
                                    line-height: 3px; text-align: left; margin-top: -2px; }
.annot-toggle.align.center::after { content: "\2014"; display: block; font-size: 8px;
                                    line-height: 3px; text-align: center; margin-top: -2px; }
.annot-toggle.align.right::after  { content: "\2014"; display: block; font-size: 8px;
                                    line-height: 3px; text-align: right; margin-top: -2px; }

/* A name for a screen reader on a control whose face is a glyph. Not
   `display: none`, which would take it out of the accessibility tree along
   with everything that points at it. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.annot-props .annot-del {
  font: inherit; cursor: pointer; padding: 1px 7px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: #c62828;
}
.annot-props .annot-del:hover { background: #fdeeee; border-color: #c62828; }

.sign-dialog {
  border: none; border-radius: 12px; padding: 22px var(--space-12); max-width: 580px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.22);
}
.sign-dialog::backdrop { background: rgba(0,0,0,0.35); }
.sign-dialog h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); }
.sign-hint { margin: 0 0 var(--space-6); color: var(--muted); font-size: var(--text-md); }
#signPad {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  touch-action: none; cursor: crosshair; display: block; width: 100%;
}
.sign-actions-row { display: flex; justify-content: flex-end; margin-top: var(--space-3); }
.sign-intent {
  display: flex; gap: 9px; align-items: flex-start; margin: var(--space-7) 0 var(--space-2);
  font-size: var(--text-md); line-height: 1.45;
}
.sign-intent input { margin-top: var(--space-1); flex: none; }
.sign-actions { display: flex; justify-content: flex-end; gap: var(--space-4); margin-top: var(--space-7); }

.whiteout-warning {
  margin: 0 auto var(--space-8); max-width: 900px; padding: 9px var(--space-6); border-radius: var(--radius-md);
  font-size: var(--text-md); border-left: 4px solid #d08b1f; background: #fff8ec;
}

.search { display: block; margin-bottom: var(--space-6); }
.search input {
  width: 100%; font: inherit; font-size: var(--text-md); padding: 7px var(--space-5);
  border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.group-head {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--muted); margin: var(--space-7) 0 var(--space-2); font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
}
.group-head .count { font-weight: 400; letter-spacing: 0; text-transform: none; }

.category { margin-bottom: var(--space-2); }
.category > summary {
  cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--ink);
  padding: 5px var(--space-2); border-radius: 5px; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.category > summary::-webkit-details-marker { display: none; }
.category > summary:hover { background: #eef1f6; }
.category > summary::before {
  content: '\25B8'; margin-right: var(--space-3); color: var(--muted); font-size: 10px;
  transition: transform 0.12s;
}
.category[open] > summary::before { transform: rotate(90deg); }
.category > summary .count { font-weight: 400; color: var(--muted); font-size: var(--text-xs); }
.category ul { margin: 0 0 var(--space-2); padding: 0; list-style: none; }

.show-more {
  display: block; width: 100%; margin: var(--space-1) 0 var(--space-4); padding: 5px;
  font: inherit; font-size: var(--text-sm); cursor: pointer; color: var(--accent);
  background: none; border: 1px dashed var(--line); border-radius: 5px;
}
.show-more:hover { background: #eef1f6; }

/* Attachments panel -- below the field list in the right rail. */
.attach-panel {
  flex: 0 0 auto; max-height: 30%; overflow-y: auto;
  margin-top: var(--space-7); border-top: 1px solid var(--line); padding-top: var(--space-6);
}
.attach-panel .upload { padding: var(--space-6) var(--space-4); }
.attach-list { list-style: none; margin: var(--space-5) 0 0; padding: 0; }
.attach-list li {
  position: relative; padding: var(--space-3) 26px var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-md);
}
.attach-list li:hover { background: #eef1f6; }
.attach-name {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 0; font: inherit; color: var(--accent); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-name:hover { text-decoration: underline; }
.attach-meta { display: block; font-size: var(--text-xs); color: var(--muted); }
/* Files that came with the document read as part of it, not as our own. */
.attach-list li.in-doc .attach-name { color: var(--ink); }
.attach-list li .del {
  position: absolute; top: 5px; right: 4px; border: none; background: none;
  font-size: var(--text-lg); line-height: 1; color: var(--muted); cursor: pointer;
  opacity: 0; border-radius: 3px; padding: 1px 5px;
}
.attach-list li:hover .del { opacity: 1; }
.attach-list li .del:hover { background: #fdeeee; color: #c62828; }

/* Sharing and signing, below attachments in the right rail. */
.share-panel {
  flex: 0 0 auto; max-height: 55%; overflow-y: auto;
  margin-top: var(--space-7); border-top: 1px solid var(--line); padding-top: var(--space-6);
}
.share-panel h2.spaced { margin-top: 18px; }
.share-field { display: block; margin-bottom: var(--space-4); }
.share-field > span { display: block; font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--space-1); }
.share-field input, .share-field select, .share-field textarea {
  width: 100%; padding: 5px var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: var(--text-md); background: #fff; color: var(--ink);
}
.btn.wide { width: 100%; }
.share-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; }
.share-list li {
  position: relative; padding: 5px var(--space-12) 5px var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-md);
}
.share-list li:hover { background: #eef1f6; }
.share-list li .del {
  position: absolute; top: 4px; right: 4px; border: none; background: none;
  font-size: var(--text-lg); line-height: 1; color: var(--muted); cursor: pointer;
  opacity: 0; border-radius: 3px; padding: 1px 5px;
}
.share-list li:hover .del { opacity: 1; }
.share-list li .del:hover { background: #fdeeee; color: #c62828; }

/* A signed document is finished; say so where it cannot be missed. */
.sealed-note {
  border: 1px solid #1c7a3e; background: #eef8f1; border-radius: var(--radius-sm);
  padding: var(--space-4); font-size: var(--text-md); margin-bottom: var(--space-4);
}
.sealed-note .hash {
  display: block; font-family: ui-monospace, Menlo, monospace; font-size: var(--text-xs);
  color: var(--muted);
}
.sealed-note .hint { margin: var(--space-2) 0 0; }

/* A record that could not be READ says so. Muted red rather than a banner:
   the signatures are fine and only this view of them is missing, so it must
   not read as something having gone wrong with the document. */
.hint.err { color: #c62828; }

/* The signature record. Each entry is a fact about a legally operative act,
   so it reads as a record rather than as a list of notifications: the name
   leads, the evidence sits behind a native <details> -- which is focusable,
   keyboard-operable and announced as a disclosure without a line of script,
   the same reason dialog.js is built on <dialog>. */
.sig-record { list-style: none; margin: 0; padding: 0; font-size: var(--text-md); }
.sig-record > li {
  padding: var(--space-4) var(--space-5); margin-bottom: var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfcfe;
}
.sig-head { display: flex; align-items: baseline; gap: var(--space-4); justify-content: space-between; }
.sig-method {
  flex: 0 0 auto; font-size: var(--text-xs); color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1px 7px;
}
.sig-detail { margin-top: var(--space-3); }
.sig-detail summary { font-size: var(--text-sm); color: var(--muted); cursor: pointer; }
.sig-detail summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Quoted, and it must LOOK quoted: these are the words somebody accepted,
   not our description of them. */
.sig-intent {
  margin: var(--space-3) 0; padding: var(--space-3) var(--space-5); font-size: var(--text-sm);
  border-left: 3px solid var(--line); color: #374151; font-style: italic;
}
.sig-facts { margin: var(--space-3) 0 0; font-size: var(--text-xs); }
.sig-facts dt { color: var(--muted); }
.sig-facts dd { margin: 0 0 5px; font-family: ui-monospace, Menlo, monospace; }
/* A user agent is one long unbroken token and will push the panel wide. */
.sig-ua { white-space: normal; overflow-wrap: anywhere; font-size: 10px; }

/* What somebody was asked to do, above the pages they were asked about. */
.approval-bar {
  max-width: 900px; margin: 0 auto var(--space-8); padding: var(--space-6) var(--space-7);
  width: calc(100% - 40px);
  border: 1px solid var(--accent); border-left-width: 4px;
  border-radius: var(--radius-sm); background: #f2f6fd;
}
.approval-bar .ask { font-size: var(--text-base); margin-bottom: var(--space-4); }
.approval-bar .ask em { display: block; margin-top: var(--space-2); color: var(--muted); }
.approval-bar .ask-actions { display: flex; gap: var(--space-4); }
.btn.spaced-top { margin-top: var(--space-4); }

/* A revision that should not be started from, marked where it is chosen. */
.form-status {
  display: inline-block; margin-top: 3px; padding: 1px var(--space-3); border-radius: 9px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
  background: #f0e2c4; color: #6b4e12;
}
.form-status.withdrawn { background: #f6d7d7; color: #8a1f1f; }
.form-status.not_yet_effective { background: #dde6f7; color: #24487f; }
.panel .doc-list li.active .form-status { background: rgba(255,255,255,0.25); color: #fff; }
.warn-action { display: block; margin-top: var(--space-4); }

/* News about forms the user holds, above their document list. */
.notices {
  border: 1px solid #d08b1f; border-left-width: 3px; background: #fff8ec;
  border-radius: var(--radius-sm); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-7);
}
.notices-head {
  font-size: var(--text-sm); font-weight: 600; color: #6b4e12; margin-bottom: var(--space-3);
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4);
}
.notices .link {
  border: none; background: none; padding: 0; font: inherit; font-weight: 400;
  font-size: var(--text-xs); color: var(--accent); cursor: pointer; text-decoration: underline;
}
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-list li { position: relative; padding: var(--space-2) 22px var(--space-2) 0; }
.notice-open {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 0; font: inherit; font-size: var(--text-md); color: var(--accent); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notice-open:hover { text-decoration: underline; }
.notice-detail { display: block; font-size: var(--text-xs); color: var(--muted); }
.notice-list li .del {
  position: absolute; top: 2px; right: 0; border: none; background: none;
  font-size: var(--text-lg); line-height: 1; color: var(--muted); cursor: pointer;
  border-radius: 3px; padding: 0 var(--space-2);
}
.notice-list li .del:hover { background: #fdeeee; color: #c62828; }

/* Operations view. */
.ops-body { background: var(--bg); color: var(--ink); }
.ops { max-width: 880px; margin: var(--space-12) auto; padding: 0 var(--space-8); }
.ops h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-2); }
.ops-scope {
  border: 1px solid #d08b1f; border-left-width: 3px; background: #fff8ec;
  border-radius: var(--radius-sm); padding: var(--space-4) var(--space-5); font-size: var(--text-md); margin: var(--space-6) 0;
}
.ops-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: var(--space-7); margin-top: var(--space-7);
}
.ops-card h2 { font-size: var(--text-lg); margin: 0 0 var(--space-1); text-transform: none; letter-spacing: 0; }
.ops-counts { display: flex; gap: var(--space-10); margin: var(--space-5) 0; font-size: var(--text-md); }
.ops-counts strong { font-size: var(--text-xl); display: block; }
.ops-holders { width: 100%; border-collapse: collapse; margin-top: var(--space-5); font-size: var(--text-md); }
.ops-holders th, .ops-holders td {
  text-align: left; padding: 5px var(--space-4); border-bottom: 1px solid var(--line);
}
.ops-holders th { font-size: var(--text-xs); text-transform: uppercase; color: var(--muted); }
.ops-email { display: block; font-size: var(--text-xs); color: var(--muted); }

/* Organisation administration. */
.ops h2.spaced { margin-top: 22px; font-size: var(--text-sm); }
.invite-row { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.invite-row input, .invite-row select {
  padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: var(--text-md); background: #fff; color: var(--ink);
}
.invite-row input { min-width: 240px; }
.ops-holders .link {
  border: none; background: none; padding: 0 var(--space-3) 0 0; font: inherit; font-size: var(--text-sm);
  color: var(--accent); cursor: pointer; text-decoration: underline;
}
.publish-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 var(--space-7); max-width: 760px;
}

/* How much of its allowance an organisation has used. */
.usage { margin: var(--space-5) 0 var(--space-7); }
.usage-line { font-size: var(--text-md); margin-bottom: 5px; }
.usage-bar {
  height: 6px; background: #e6e9ef; border-radius: 3px; overflow: hidden; max-width: 420px;
}
.usage-bar span { display: block; height: 100%; background: var(--accent); }
.usage .link {
  border: none; background: none; padding: 0; font: inherit; font-size: var(--text-sm);
  color: var(--accent); cursor: pointer; text-decoration: underline; margin-top: var(--space-3);
}
.notice-title { display: block; font-size: var(--text-md); }

/* Rows that are actions.
   A clickable <li> cannot be tabbed to, activated with Enter, or announced as
   something to press, so the row's content is a real button. It has to look
   like nothing: the <li> keeps the padding, background and active state it
   always had, and this only makes the same area operable. */
.row-open {
  display: block;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  word-break: break-word;
}
#fieldList .row-open {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: baseline;
}

/* Hover was the only way to see the row was interactive, which a keyboard
   never produces. */
.panel .doc-list li:focus-within { background: #eef1f6; }
.panel .doc-list li.active:focus-within { background: var(--accent); }
#fieldList li:focus-within { background: #f2f5fa; }

/* The focus ring goes on the row, not on an invisible full-width button whose
   outline would trace the whole panel edge. */
.row-open:focus { outline: none; }
.row-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px;
                          border-radius: var(--radius-sm); }

/* A delete control that only appears on hover is, for a keyboard, a control
   that is focusable and invisible -- the focus vanishes into nothing. */
.panel .doc-list li .del:focus-visible,
.attach-list li .del:focus-visible,
.share-list li .del:focus-visible { opacity: 1; outline: 2px solid var(--accent); }
.panel .doc-list li:focus-within .del,
.attach-list li:focus-within .del,
.share-list li:focus-within .del { opacity: 1; }

/* A comb field: one character per cell, with the dividers drawn.
   The page used to paint these as part of the widget's appearance; it no
   longer paints any of it, so the cells belong to the field layer now. */
.field-layer input.comb {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding-left: 0;
  padding-right: 0;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(100% / var(--comb-cells) - 1px),
    var(--field-line) calc(100% / var(--comb-cells) - 1px),
    var(--field-line) calc(100% / var(--comb-cells))
  );
}

/* ------------------------------------------------------------------ dialogs
   The application's own alert, confirm and prompt. Native <dialog>, so the
   backdrop, the focus trap and Escape are the browser's; only the look is
   ours. */
.app-dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 18px var(--space-7); min-width: 300px; max-width: min(440px, 92vw);
  background: var(--panel); color: var(--ink);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22);
}
.app-dialog::backdrop { background: rgba(20, 22, 26, 0.38); }
.app-dialog-title { margin: 0 0 var(--space-4); font-size: var(--text-lg); font-weight: 600; }
.app-dialog-body {
  margin: 0 0 var(--space-7); font-size: var(--text-md); line-height: 1.5; color: var(--ink);
  /* These messages are written as paragraphs with blank lines between them. */
  white-space: pre-wrap;
}
.app-dialog-field { display: grid; gap: var(--space-2); margin: 0 0 var(--space-7); }
.app-dialog-field > span { font-size: var(--text-sm); color: var(--muted); }
.app-dialog-field input {
  font: inherit; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line); border-radius: 5px;
}
.app-dialog-field select {
  font: inherit; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line); border-radius: 5px; background: #fff;
}
.app-dialog-field input:focus-visible,
.app-dialog-field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Says what the limit is while there is still time to stay inside it. */
.app-dialog-hint { font-size: var(--text-xs); color: var(--muted); }
.app-dialog-actions { display: flex; gap: var(--space-4); justify-content: flex-end; }
.app-dialog-btn {
  font: inherit; cursor: pointer; padding: var(--space-3) var(--space-7); border-radius: 5px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.app-dialog-btn:hover { background: #eef1f6; }
.app-dialog-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.app-dialog-btn.primary:hover { filter: brightness(1.08); }
.app-dialog-btn.danger { border-color: #c62828; color: #c62828; }
.app-dialog-btn.danger:hover { background: #fdeeee; }


/* ---------------------------------------------------------- signing tiers
   Two tabs, and they are NOT flavours of one thing (ADR 17): one records a
   mark, the other is cryptography. The wording carries that; these styles
   only have to keep the two apart and not make them look interchangeable. */
.sign-tabs { display: flex; gap: var(--space-2); margin: 0 0 var(--space-2); border-bottom: 1px solid var(--line); }
.sign-tab {
  font: inherit; cursor: pointer; padding: 7px var(--space-7); border: none; background: none;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sign-tab:hover { color: var(--ink); }
.sign-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.sign-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* What this signature proves, said where the choice is made. */
.sign-tier { margin: var(--space-4) 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.sign-tier.warn { color: #8c4b00; }

.sign-methods { display: flex; gap: var(--space-3); margin: var(--space-5) 0 var(--space-3); }
.sign-method {
  font: inherit; font-size: var(--text-md); cursor: pointer; padding: var(--space-2) var(--space-6);
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: #fff; color: var(--ink);
}
.sign-method:hover { background: #eef1f6; }
.sign-method.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sign-method:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sign-field { display: grid; gap: var(--space-2); margin: 0 0 var(--space-5); font-size: var(--text-md); }
.sign-field > span { color: var(--muted); font-size: var(--text-sm); }
.sign-field input[type="text"], .sign-field select {
  font: inherit; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: 5px;
}
#typedPreview, #uploadPreview {
  width: 100%; border: 1px dashed var(--line); border-radius: var(--radius-md); background: #fff;
}

/* ---------------------------------------------------------------- prose page
 *
 * limitations.html, and anything else that is text somebody reads rather than
 * a surface they drive. Measured width rather than full-bleed: a legal
 * explanation at 1600px is one nobody finishes a paragraph of.
 */
.doc-body { background: var(--bg); }
.doc {
  max-width: 760px; margin: 0 auto; padding: 28px var(--space-10) 64px;
  background: var(--panel); border: 1px solid var(--line);
  border-top: none;
}
.doc h2 {
  margin: 34px 0 var(--space-5); padding-bottom: var(--space-3); font-size: 19px;
  border-bottom: 1px solid var(--line);
}
.doc h3 { margin: 22px 0 var(--space-3); font-size: var(--text-lg); }
.doc p { margin: 0 0 var(--space-5); }
.doc-lead { font-size: var(--text-lg); color: var(--ink); }
/* A sidenote, not a warning: the page is full of real warnings and a box that
 * looked like one here would compete with them. */
.doc-note {
  color: var(--muted); font-size: var(--text-md);
  border-left: 3px solid var(--line); padding: var(--space-1) 0 var(--space-1) var(--space-6);
}
/* The link a warning carries to its own section. Not a button: it navigates,
 * and the banner already has one real action in `.warn-action`. */
.warn-why {
  display: inline-block; margin-top: var(--space-3); font-size: var(--text-sm);
  color: var(--accent);
}
