/* SignFlow — design tokens & app styles
   Palette: cool paper neutrals + fountain-pen ink (primary) + wax-seal red (secondary/recipient)
   Type: Fraunces (display) / IBM Plex Sans (UI) / IBM Plex Mono (data, tokens, timestamps)
*/

:root {
  --ink: #1c2333;
  --muted: #5b6472;
  --faint: #8891a0;
  --paper: #f3f4f7;
  --paper-raised: #ffffff;
  --line: #dde1e8;
  --line-strong: #c6cbd6;
  --pen: #2f3fa6;
  --pen-strong: #232f85;
  --pen-tint: #e8eaf9;
  --seal: #b33a2e;
  --seal-strong: #8f2e24;
  --seal-tint: #f7e6e3;
  --good: #1f7a52;
  --good-tint: #e3f3ea;
  --warn: #9a6b00;
  --warn-tint: #fbf0d6;
  --shadow: 0 1px 2px rgba(28, 35, 51, 0.06), 0 8px 24px -12px rgba(28, 35, 51, 0.18);
  --radius: 10px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7e9ee;
    --muted: #9aa3b2;
    --faint: #6b7382;
    --paper: #14161f;
    --paper-raised: #1c202b;
    --line: #2b303c;
    --line-strong: #383f4d;
    --pen: #8b98ff;
    --pen-strong: #aab4ff;
    --pen-tint: #232a52;
    --seal: #e58579;
    --seal-strong: #f0a89e;
    --seal-tint: #402521;
    --good: #59c48c;
    --good-tint: #142a20;
    --warn: #e0b64a;
    --warn-tint: #332708;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --ink: #e7e9ee;
  --muted: #9aa3b2;
  --faint: #6b7382;
  --paper: #14161f;
  --paper-raised: #1c202b;
  --line: #2b303c;
  --line-strong: #383f4d;
  --pen: #8b98ff;
  --pen-strong: #aab4ff;
  --pen-tint: #232a52;
  --seal: #e58579;
  --seal-strong: #f0a89e;
  --seal-tint: #402521;
  --good: #59c48c;
  --good-tint: #142a20;
  --warn: #e0b64a;
  --warn-tint: #332708;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: var(--pen); }
button { font-family: inherit; }
::selection { background: var(--pen-tint); }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

.sf-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- shell / topbar ---------- */

.sf-shell { min-height: 100%; display: flex; flex-direction: column; }

.sf-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  position: sticky; top: 0; z-index: 20;
}
.sf-brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; min-width: 0; }
.sf-brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--pen);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 15px; flex: none;
}
.sf-brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; color: var(--ink); }
.sf-brand-sub { font-size: 12px; color: var(--faint); font-family: var(--font-mono); letter-spacing: 0.02em; }
.sf-topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }

.sf-main {
  flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 28px 24px 64px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-bottom: max(64px, calc(env(safe-area-inset-bottom) + 24px));
}

/* Phones: the "Bateman IT Solutions" subtitle and full download-button
   label are the first things to go — the icon + "SignFlow" and a short
   button label are enough, and it keeps everything on one row instead of
   wrapping awkwardly at ~360px wide. */
@media (max-width: 480px) {
  .sf-topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .sf-brand-sub { display: none; }
  .sf-brand-name { font-size: 17px; }
  .sf-main { padding-left: 16px; padding-right: 16px; }
}

/* ---------- buttons ---------- */

.sf-btn-primary, .sf-btn-ghost, .sf-btn-danger {
  border-radius: 8px; padding: 12px 18px; min-height: 44px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: transform .04s ease, background .15s ease, border-color .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.sf-btn-primary { background: var(--pen); color: #fff; }
.sf-btn-primary:hover { background: var(--pen-strong); }
.sf-btn-primary:active { transform: translateY(1px); }
.sf-btn-primary:disabled { background: var(--line-strong); color: var(--faint); cursor: not-allowed; }
.sf-btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.sf-btn-ghost:hover { background: var(--paper); border-color: var(--muted); }
.sf-btn-danger { background: transparent; color: var(--seal); border-color: var(--seal); }
.sf-btn-danger:hover { background: var(--seal-tint); }
.sf-btn-sm { padding: 9px 14px; min-height: 38px; font-size: 13px; }
.sf-btn-shake { animation: sf-shake .35s; }
@keyframes sf-shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

.sf-icon-btn {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--paper-raised); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.sf-icon-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- cards / panels ---------- */

.sf-card {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sf-panel-pad { padding: 22px; }

/* ---------- dashboard (index) ---------- */

.sf-hero { display: flex; flex-direction: column; gap: 6px; margin-bottom: 28px; }
.sf-hero h1 { font-size: 30px; }
.sf-hero p { color: var(--muted); max-width: 60ch; }

.sf-dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; background: var(--paper-raised);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.sf-dropzone:hover, .sf-dropzone.sf-drag-over { border-color: var(--pen); background: var(--pen-tint); }
.sf-dropzone h3 { font-size: 18px; margin-bottom: 6px; }
.sf-dropzone p { color: var(--muted); font-size: 13.5px; }
.sf-dropzone-icon { font-size: 30px; margin-bottom: 10px; }

.sf-doclist { margin-top: 40px; }
.sf-doclist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sf-doclist-head h2 { margin-bottom: 0; }
.sf-doclist h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 14px; font-family: var(--font-body); font-weight: 600; }

/* Documents are grouped under a date heading (Today / Yesterday / the
   actual date) so a growing list stays scannable at a glance. */
.sf-date-group-heading {
  font-size: 12.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em;
  margin: 22px 0 8px; padding-top: 4px; border-top: 1px solid var(--line);
}
.sf-date-group-heading:first-child { margin-top: 0; border-top: none; padding-top: 0; }

.sf-doc-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--paper-raised); margin-bottom: 8px;
}
/* A client-uploaded document that hasn't even had fields placed yet needs
   the manager's attention before anything else can happen to it — call
   that out with a left accent instead of burying it as just another row. */
.sf-doc-row-needs-setup { border-color: var(--seal); border-left-width: 4px; background: var(--seal-tint); }
.sf-doc-row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-doc-row-uploader { color: var(--faint); font-size: 12px; }
.sf-doc-row-date { color: var(--faint); font-size: 12.5px; }
.sf-empty { color: var(--faint); font-size: 14px; padding: 18px 4px; }

/* ---------- topbar account area / notification badge ---------- */

.sf-user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  padding: 6px 4px;
}
.sf-user-chip strong { color: var(--ink); font-weight: 600; }
.sf-notify-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 999px; background: var(--seal); color: #fff; font-size: 11.5px;
  font-weight: 700; font-family: var(--font-mono);
}
/* Same trap as the modal overlay above: the explicit `display` here would
   otherwise beat the browser's own `[hidden] { display: none }` rule. */
.sf-notify-badge[hidden] { display: none; }

/* ---------- manage-accounts modal ---------- */

.sf-users-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.sf-user-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper);
}
.sf-user-row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-user-row-meta { color: var(--faint); font-size: 12px; }
.sf-user-role-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; background: var(--pen-tint); color: var(--pen-strong);
}
.sf-user-role-pill.sf-role-client { background: var(--line); color: var(--muted); }

/* Six things (name, status, date, and three buttons) in one row only works
   with room to spare — on a phone the name gets its own line and
   everything else wraps beneath it rather than clipping or forcing a
   horizontal scroll. */
@media (max-width: 640px) {
  .sf-doc-row { flex-wrap: wrap; row-gap: 10px; }
  .sf-doc-row-name { flex-basis: 100%; white-space: normal; }
  .sf-hero h1 { font-size: 24px; }
  .sf-dropzone { padding: 36px 18px; }
}

/* ---------- status pill ---------- */

.sf-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.sf-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sf-pill-draft { background: var(--line); color: var(--muted); }
.sf-pill-needs-setup { background: var(--seal-tint); color: var(--seal-strong); }
.sf-pill-sent { background: var(--warn-tint); color: var(--warn); }
.sf-pill-progress { background: var(--warn-tint); color: var(--warn); }
.sf-pill-completed { background: var(--good-tint); color: var(--good); }

/* ---------- builder: field toolbar ---------- */

.sf-builder-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .sf-builder-layout { grid-template-columns: 1fr; } }

.sf-toolbar-group { margin-bottom: 18px; }
.sf-toolbar-group h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint);
  margin: 0 0 8px; font-weight: 600;
}
.sf-tool-btn {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper-raised);
  cursor: pointer; margin-bottom: 6px; font-size: 13.5px; color: var(--ink); font-weight: 500;
}
.sf-tool-btn:hover { border-color: var(--muted); }
.sf-tool-btn.sf-tool-active { border-color: var(--pen); background: var(--pen-tint); color: var(--pen-strong); }
.sf-tool-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sf-tool-dot-owner { background: var(--pen); }
.sf-tool-dot-recipient { background: var(--seal); }

.sf-armed-hint {
  font-size: 12.5px; color: var(--pen-strong); background: var(--pen-tint); border-radius: 7px;
  padding: 8px 10px; margin-top: 6px; display: none;
}
.sf-armed-hint.sf-show { display: block; }

.sf-side-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Phones: the doc viewer comes first in the layout, so without help the
   Create/Start over buttons would sit below the entire document — often a
   long scroll away. Pin them to the bottom of the viewport instead, like a
   normal mobile app's primary action bar, so they're always one tap away
   regardless of how far you've scrolled into the document. */
@media (max-width: 860px) {
  #screenBuilder { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  /* Fields default to the bottom ~20% of the last page (see
     SF.placeSignatureBlock). A short document fits inside the viewport with
     no scrolling at all, which puts that field at the same screen position
     the action bar would occupy — so the bar can't be `position: fixed`
     (always pinned to the viewport, regardless of what's underneath it) or
     it permanently covers/blocks taps on any field that happens to land in
     that band. `position: sticky` keeps the "always reachable without a
     long scroll" behavior for tall documents (it sticks once its natural
     flow position would scroll out of view) while staying in normal flow —
     and therefore never overlapping earlier content, fields included — for
     short ones. */
  .sf-side-actions {
    position: sticky; left: 0; right: 0; bottom: 0; z-index: 25;
    flex-direction: row; margin-top: 20px; padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--paper-raised); border-top: 1px solid var(--line);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -6px 20px -8px rgba(28, 35, 51, 0.18);
  }
  .sf-side-actions .sf-btn-primary, .sf-side-actions .sf-btn-ghost { flex: 1; justify-content: center; }
}

.sf-field-input-row { display: flex; gap: 8px; margin-bottom: 14px; }
.sf-field-input-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.sf-toggle-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 9px;
  background: var(--paper); border: 1px solid var(--line); margin-bottom: 18px; cursor: pointer;
}
.sf-toggle-row input[type="checkbox"] { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--seal); cursor: pointer; flex: none; }
.sf-toggle-row-text { font-size: 13px; color: var(--ink); }
.sf-toggle-row-text strong { font-weight: 600; }
.sf-toggle-row-hint { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

.sf-toolbar-group-disabled { opacity: 0.45; pointer-events: none; }

.sf-choice-group { margin-bottom: 18px; }
.sf-choice-group h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.sf-choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sf-choice-btn {
  text-align: left; padding: 12px; border-radius: 9px; border: 1.5px solid var(--line-strong);
  background: var(--paper); cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.sf-choice-btn strong { font-size: 13px; color: var(--ink); }
.sf-choice-btn span { font-size: 11.5px; color: var(--faint); line-height: 1.35; }
.sf-choice-btn:hover { border-color: var(--line-strong); background: var(--paper-raised); }
.sf-choice-btn.sf-choice-btn-active { border-color: var(--pen); background: var(--pen-tint); }
.sf-choice-btn.sf-choice-btn-active strong { color: var(--pen-strong); }
.sf-choice-hint { font-size: 12px; color: var(--warn); margin: 8px 0 0; font-weight: 600; }
.sf-choice-hint.sf-choice-hint-ok { color: var(--faint); font-weight: 400; }

/* ---------- document viewer ---------- */

.sf-doc-scroll { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.sf-page {
  position: relative; background: var(--paper-raised); box-shadow: var(--shadow); border-radius: 3px; overflow: hidden;
}
.sf-page-canvas { display: block; }

/* ---------- field overlay boxes ---------- */

.sf-field {
  position: absolute; border-radius: 5px; cursor: pointer; user-select: none;
  border: 1.5px dashed var(--pen); background: rgba(47, 63, 166, 0.06);
  display: flex; align-items: center; justify-content: center; overflow: visible;
}
.sf-field-recipient { border-color: var(--seal); background: rgba(179, 58, 46, 0.07); }
.sf-field-filled { border-style: solid; background: var(--paper-raised); }
.sf-field-editable:hover { filter: brightness(0.97); }
.sf-field-dragging { opacity: 0.75; z-index: 30; }
.sf-field-placeholder {
  font-size: 11px; color: var(--pen); font-weight: 600; text-align: center; padding: 2px 4px;
  font-family: var(--font-body); pointer-events: none; letter-spacing: 0.01em;
}
.sf-field-recipient .sf-field-placeholder { color: var(--seal); }
.sf-field-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 2px; }
.sf-field-content img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sf-field-text-content { font-family: var(--font-body); font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.sf-field-del {
  position: absolute; top: -11px; right: -11px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: var(--paper); border: 2px solid var(--paper); font-size: 14px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.sf-field-auto {
  cursor: default; border-style: dotted; opacity: 0.72;
}
.sf-field-auto .sf-field-placeholder { font-style: italic; font-weight: 500; }
.sf-field-auto.sf-field-filled { opacity: 1; border-style: solid; }
.sf-field-auto .sf-field-text-content { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

/* A signature field + its paired auto date/time field share a blockId and
   get one solid box drawn behind them (see SF.paintBlockFrame), so the pair
   reads as a single "sign here" box rather than a lone signature square
   with an easy-to-miss date hint floating underneath it. */
.sf-field-block {
  position: absolute; border-radius: 8px; pointer-events: none; box-sizing: border-box;
  border: 1.5px solid var(--pen); background: rgba(47, 63, 166, 0.045);
}
.sf-field-block-recipient { border-color: var(--seal); background: rgba(179, 58, 46, 0.05); }
/* Inside a block, the signature + auto date/time fields are sections of one
   box, not two separate boxes — drop their own border/background so the
   frame above is the only outline anyone sees. */
.sf-field-in-block { border: none; background: transparent; }
.sf-field-in-block.sf-field-filled { background: transparent; }

/* ---------- modal ---------- */

.sf-modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 31, 0.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
/* This one lives statically in the page (rather than being created on the
   fly like the field-editor modal) so it can be toggled with the `hidden`
   attribute — but `display: flex` above would otherwise outrank the
   browser's own `[hidden] { display: none }` rule and show it anyway. */
.sf-modal-overlay[hidden] { display: none; }
.sf-modal {
  width: 100%; max-width: 440px; background: var(--paper-raised); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: 90vh;
}
.sf-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 4px; }
.sf-modal-header h3 { font-size: 18px; }
.sf-modal-close {
  background: none; border: none; font-size: 22px; color: var(--faint); cursor: pointer; line-height: 1;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; flex: none;
}
.sf-modal-close:hover { background: var(--paper); color: var(--ink); }
.sf-modal-body { padding: 16px 20px; overflow-y: auto; }
.sf-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 20px 20px; }

.sf-tabs { display: flex; gap: 6px; margin-bottom: 14px; background: var(--paper); padding: 4px; border-radius: 9px; }
.sf-tab { flex: 1; border: none; background: transparent; padding: 10px 8px; min-height: 40px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.sf-tab-active { background: var(--paper-raised); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.sf-pad-wrap { border: 1.5px solid var(--line-strong); border-radius: 8px; background: #fff; }
.sf-pad-canvas { width: 100%; height: clamp(150px, 24vh, 220px); display: block; cursor: crosshair; border-radius: 8px; touch-action: none; }
.sf-pad-tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.sf-chip {
  border: 1px solid var(--line-strong); background: var(--paper-raised); border-radius: 999px; padding: 7px 14px;
  min-height: 34px; font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.sf-chip[data-ink="#1c2333"]::before { content:"●"; color:#1c2333; margin-right:5px; }
.sf-chip[data-ink="#1f3fa6"]::before { content:"●"; color:#1f3fa6; margin-right:5px; }

/* device status row under the draw pad — pointer type + USB pad pickup */
.sf-pad-device {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--paper); font-size: 12px; color: var(--muted);
}
.sf-pad-device-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.sf-pad-device.sf-pad-device-active .sf-pad-device-dot { background: var(--good); }
.sf-pad-device-text { flex: 1; min-width: 140px; }
.sf-pad-device-btn {
  border: 1px solid var(--line-strong); background: var(--paper-raised); border-radius: 999px;
  padding: 4px 11px; font-size: 11.5px; font-weight: 600; color: var(--pen); cursor: pointer;
}
.sf-pad-device-btn:disabled { color: var(--faint); cursor: default; }

/* the "saved signature" tab panel */
.sf-saved-sig {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
}
.sf-saved-sig img { max-width: 100%; max-height: 110px; }
.sf-saved-sig-actions { display: flex; gap: 14px; align-items: center; }
.sf-saved-sig-forget { border: none; background: none; color: var(--faint); font-size: 12px; text-decoration: underline; cursor: pointer; padding: 0; }

.sf-remember-row {
  display: flex; align-items: flex-start; gap: 9px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.sf-remember-row input[type="checkbox"] { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--pen); cursor: pointer; flex: none; }
.sf-remember-row label { font-size: 13px; color: var(--ink); cursor: pointer; }

.sf-input {
  width: 100%; padding: 12px; min-height: 44px; border: 1.5px solid var(--line-strong); border-radius: 8px;
  /* 16px, not 15 — anything smaller makes iOS Safari zoom the whole page in on focus. */
  font-size: 16px; font-family: inherit; background: var(--paper-raised); color: var(--ink);
}
.sf-input:focus { border-color: var(--pen); }
.sf-hint { color: var(--faint); font-size: 12.5px; margin-top: 8px; }

.sf-type-preview {
  margin-top: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  font-size: 34px; text-align: center; color: var(--ink); min-height: 60px; display: flex; align-items: center; justify-content: center;
}
.sf-font-row { display: flex; gap: 8px; margin-top: 10px; }
.sf-font-chip {
  flex: 1; padding: 10px; border: 1.5px solid var(--line-strong); border-radius: 8px; background: var(--paper-raised);
  font-size: 18px; cursor: pointer; color: var(--ink);
}
.sf-font-chip-active { border-color: var(--pen); background: var(--pen-tint); }

.sf-file-input { margin-bottom: 12px; }
.sf-upload-preview {
  min-height: 90px; border: 1px dashed var(--line-strong); border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--faint); font-size: 13px; padding: 10px; background: var(--paper);
}
.sf-upload-preview img { max-width: 100%; max-height: 140px; }

/* ---------- envelope (sign) page ---------- */

.sf-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 10px; margin-bottom: 22px;
  font-size: 14px;
}
.sf-banner-info { background: var(--pen-tint); color: var(--pen-strong); }
.sf-banner-success { background: var(--good-tint); color: var(--good); }
.sf-banner-wait { background: var(--warn-tint); color: var(--warn); }
.sf-progress-track { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sf-progress-fill { height: 100%; background: var(--pen); border-radius: 999px; transition: width .2s ease; }

.sf-share-row {
  display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}
.sf-share-row input { flex: 1; border: none; background: transparent; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }

.sf-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.sf-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sf-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.sf-center-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.sf-center-state h2 { margin-bottom: 8px; }

.sf-login-wrap { max-width: 360px; margin: 80px auto; text-align: center; }
.sf-login-wrap .sf-card { padding: 28px; text-align: left; }

.sf-toast {
  position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; right: auto; max-width: calc(100% - 32px);
  transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; font-size: 13.5px;
  text-align: center;
  transition: opacity .18s ease, transform .18s ease; pointer-events: none; z-index: 200;
}
.sf-toast.sf-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* The builder screen's Create/Start over bar can stick to the bottom of
   the viewport on phones once a document scrolls that far (see
   .sf-side-actions) — lift the toast above where that bar would sit on
   this screen so a message is never hidden behind it. */
@media (max-width: 860px) {
  @supports selector(:has(a)) {
    body:has(#screenBuilder:not([hidden])) .sf-toast {
      bottom: calc(90px + env(safe-area-inset-bottom));
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
