/* GoSignHere signing page (p4a/p6a). gsh.css loads first and supplies the tokens; the page is forced light (data-theme="light").
   This file only holds the signing layout and a small alias layer onto those tokens. */

/* Names this page used before the design system rebuild, redirected to the tokens. */
:root {
  --header-height: 56px;
  --sidebar-width: 300px;
  /* The dark header is the one deliberate dark region on this forced-light page; literals are the dark-theme surface/text values. */
  --bg-header: #1C1F26;
  --header-text: #EDEFF3;
  --header-text-dim: rgba(237, 239, 243, 0.6);
  --header-text-dimmer: rgba(237, 239, 243, 0.4);
  --header-border: rgba(237, 239, 243, 0.12);
  --bg-sidebar: var(--surface-1);
  --bg-field: var(--attention-soft);
  --bg-field-active: color-mix(in srgb, var(--attention) 18%, transparent);
  --bg-field-complete: var(--success-soft);
  --bg-progress: color-mix(in srgb, var(--border) 60%, transparent);
  --border-light: color-mix(in srgb, var(--border) 60%, transparent);
  --accent-bg: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 25%, transparent);
  --accent-light: color-mix(in srgb, var(--accent) 12%, transparent);
  --success-bg: var(--success-soft);
  --success-border: color-mix(in srgb, var(--success) 25%, transparent);
  --warning: var(--attention);
  --warning-ink: var(--attention-ink);
  --warning-bg: var(--attention-soft);
  --warning-border: color-mix(in srgb, var(--attention) 30%, transparent);
  --danger-bg-hover: color-mix(in srgb, var(--danger) 6%, transparent);
  --danger-border-hover: color-mix(in srgb, var(--danger) 30%, transparent);
  --signer-color: var(--signer-1);
  --signer-color-bg: var(--signer-1-soft);
  --signer-color-border: var(--signer-1-border);
  /* Pad canvas */
  --canvas-bg: var(--surface-0);
  --ink-color: var(--text-primary);
  --guide-color: color-mix(in srgb, var(--accent) 12%, transparent);
  /* Ink swatches offered to the signer: literal pen colours (Black/Navy/Indigo), not theme chrome. */
  --ink-black: #1A1C23;
  --ink-navy: #1E3A6E;
  --ink-indigo: #4A2D80;
}

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: var(--font-ui);
    background: var(--surface-0);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
  }

  /* ============================================ LAYOUT ============================================ */
  .signing-layout {
    display: grid;
    grid-template-rows: var(--header-height) 1fr auto;
    grid-template-columns: 1fr var(--sidebar-width);
    grid-template-areas: "header header" "document sidebar" "footer footer";
    height: 100vh;
  }
  .signing-layout.hidden { display: none; }

  /* ============================================ HEADER ============================================ */
  .signing-header {
    grid-area: header;
    background: var(--bg-header);
    display: flex; align-items: center;
    padding: 0 20px; gap: 14px;
    z-index: 100;
  }
  .sh-logo { display: flex; align-items: center; gap: 8px; color: var(--header-text); font-weight: 700; font-size: 15px; letter-spacing: -0.3px; }
  .sh-logo .logo-icon {
    width: 24px; height: 24px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; color: var(--accent-contrast);
  }
  .sh-divider { width: 1px; height: 24px; background: var(--header-border); }
  .sh-context { display: flex; flex-direction: column; gap: 0; min-width: 0; }
  .sh-package-name { font-size: 13px; color: var(--header-text-dim); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-spacer { flex: 1; }
  .sh-security { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--header-text-dimmer); padding: 4px 10px; border: 1px solid var(--header-border); border-radius: var(--radius-sm); }
  .sh-security .lock-icon { font-size: 12px; }
  .sh-help-btn { background: rgba(237, 239, 243, 0.08); border: 1px solid var(--header-border); color: var(--header-text-dim); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
  .sh-help-btn:hover { background: rgba(237, 239, 243, 0.12); color: var(--header-text); }

  /* ============================================ DOCUMENT AREA ============================================ */
  .document-area { grid-area: document; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 24px; scroll-behavior: smooth; }

  .start-bar {
    width: 760px; max-width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
    box-shadow: 0 1px 6px rgb(0 0 0 / 0.05);
  }
  .start-bar.hidden { display: none; }
  .start-bar-text { flex: 1; font-size: 13px; color: var(--text-secondary); }
  .start-bar-text strong { color: var(--text-primary); }
  .start-btn {
    background: var(--success-ink); border: none; color: var(--accent-contrast);
    padding: 9px 18px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; font-family: inherit;
  }
  .start-btn:hover { filter: brightness(1.05); }

  .doc-page-scale-wrap { width: 760px; max-width: 100%; margin: 0 auto 20px; flex-shrink: 0; }
  /* GSH M (card 181): wrapper holds the JS-computed scaled box (syncDocScale()) so .doc-page
     itself can stay a fixed 760px logical box -- CSS transform:scale() is purely visual and
     never changes offsetWidth/offsetHeight or the % math child fields use, so field overlays
     positioned at x_pct/y_pct always land on the same text regardless of viewport width. */
.doc-content {
    padding: 60px 50px; color: var(--doc-ink);
    font-family: var(--font-doc);
    font-size: 13px; line-height: 1.7;
    /* Non-interactive layer: this renders the document's real body_html underneath the fields;
       it must never intercept clicks/drops meant for the page or the fields above it. */
    pointer-events: none;
  }
  .doc-content h2 { font-size: 17px; margin-bottom: 16px; color: var(--doc-ink); }
  .doc-content p { margin-bottom: 12px; color: var(--doc-ink); }
  .doc-content .clause { margin-bottom: 16px; }
  .doc-content .clause-num { font-weight: 700; color: var(--doc-ink); }

  /* ============================================ SIGNING FIELDS ============================================ */
  .signing-field { position: absolute; border: 2px solid var(--warning-border); background: var(--bg-field); border-radius: var(--radius-sm); transition: all 0.2s var(--ease-out); display: flex; align-items: center; font-family: var(--font-ui); font-size: 13px; overflow: visible; }
  .signing-field:hover { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-bg); }
  .signing-field.active { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 3px var(--accent-bg), 0 2px 8px rgb(0 0 0 / 0.1); z-index: 10; }
  .signing-field.completed { border-color: var(--success-border); background: var(--bg-field-complete); }
  .signing-field.invalid { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
  .signing-field.next-up::after { content: ''; position: absolute; inset: -6px; border: 2px solid var(--accent); border-radius: var(--radius-md); animation: pulse 2s ease-in-out infinite; pointer-events: none; }
  @keyframes pulse { 0%, 100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.02); } }

  .sf-number { position: absolute; top: -10px; left: -10px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); z-index: 2; }
  .signing-field.completed .sf-number { background: var(--success-ink); }
  .signing-field.invalid .sf-number { background: var(--danger); }
  .sf-info-badge { position: absolute; top: -10px; left: -10px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-secondary); color: var(--accent-contrast); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

  /* Capture-type (signature/initials) box content */
  .sf-capture-btn { all: unset; box-sizing: border-box; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 4px 10px; border-radius: var(--radius-sm); }
  .sf-capture-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .sf-capture-btn .sf-icon { font-size: 15px; opacity: 0.7; }
  .sf-capture-btn .sf-label { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
  .signing-field.completed .sf-capture-btn .sf-label { display: none; }
  .sf-capture-img { max-width: 100%; max-height: 100%; object-fit: contain; }

  /* Native inputs living inside a field box */
  .sf-input, .sf-select, .sf-textarea {
    width: 100%; height: 100%; border: none; background: transparent; outline: none;
    font-family: var(--font-ui); font-size: 13px; color: var(--text-primary);
    padding: 4px 10px;
  }
  .sf-textarea { resize: none; padding-top: 6px; line-height: 1.3; }
  .sf-select { cursor: pointer; }
  .sf-select[data-readonly-locked="true"] { pointer-events: none; }
  .sf-input[readonly] { cursor: not-allowed; }
  .signing-field.field-readonly { background: color-mix(in srgb, var(--border) 40%, transparent); }
  .signing-field.field-readonly .sf-input,
  .signing-field.field-readonly .sf-select { cursor: not-allowed; color: var(--text-secondary); }

  /* F2 fix (per F1 verification note): the label used to render INSIDE the field box and wrap
     vertically in a 4%-wide field. Field boxes have overflow:visible (see .signing-field above),
     so the label is now an absolutely-positioned bubble to the RIGHT of the box instead -- the
     checkbox input itself still fills the box, click target unchanged (label stays inside the
     same <label> element, so clicking the bubble still toggles the box). */
  .sf-checkbox-wrap { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; cursor: pointer; }
  .sf-checkbox-wrap input { width: min(20px, 80%); height: min(20px, 80%); flex-shrink: 0; accent-color: var(--accent); }
  .sf-checkbox-label { position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); width: max-content; max-width: 220px; white-space: normal; font-size: 12px; color: var(--text-secondary); line-height: 1.3; background: var(--surface-1); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 3px 8px; box-shadow: 0 1px 4px rgb(0 0 0 / 0.06); }

  .sf-label-static { padding: 4px 10px; font-size: 12px; color: var(--text-secondary); font-style: italic; line-height: 1.3; }
  .signing-field.field-static { cursor: default; background: var(--accent-soft); border-style: dashed; }

  .sf-attachment-placeholder { padding: 4px 10px; font-size: 12px; color: var(--text-secondary); }
  .signing-field.field-disabled { cursor: not-allowed; background: color-mix(in srgb, var(--border) 30%, transparent); }

  .sf-field-error { position: absolute; top: 100%; left: 0; margin-top: 4px; font-size: 12px; color: var(--danger-ink); background: var(--surface-1); border: 1px solid var(--danger-border-hover); border-radius: var(--radius-sm); padding: 3px 8px; white-space: nowrap; z-index: 5; }

  /* ============================================ SIDEBAR ============================================ */
  .signing-sidebar { grid-area: sidebar; background: var(--bg-sidebar); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
  .ss-section { padding: 18px 20px; border-bottom: 1px solid var(--border-light); }
  .ss-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); margin-bottom: 12px; }

  .signer-identity { display: flex; align-items: center; gap: 10px; }
  .signer-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--signer-color-bg); border: 2px solid var(--signer-color-border); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--signer-color); flex-shrink: 0; }
  .signer-details { display: flex; flex-direction: column; min-width: 0; }
  .signer-details .sd-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
  .signer-details .sd-email { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .progress-block { display: flex; align-items: center; gap: 16px; }
  .progress-ring-container { width: 64px; height: 64px; position: relative; flex-shrink: 0; }
  .progress-ring { width: 64px; height: 64px; transform: rotate(-90deg); }
  .progress-ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
  .progress-ring .ring-bg { stroke: var(--bg-progress); }
  .progress-ring .ring-fill { stroke: var(--accent); stroke-dasharray: 176; stroke-dashoffset: 176; transition: stroke-dashoffset 0.8s var(--ease-out); }
  .progress-ring .ring-fill.complete { stroke: var(--success); }
  .progress-center-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--text-primary); }
  .progress-stats { display: flex; flex-direction: column; gap: 4px; }
  .progress-stats .ps-label { font-size: 12px; color: var(--text-secondary); }
  .progress-stats .ps-detail { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; }
  .progress-stats .ps-sub { font-size: 12px; color: var(--text-secondary); }

  .field-checklist { display: flex; flex-direction: column; gap: 2px; }
  .fc-item { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all 0.12s; width: 100%; }
  .fc-item:hover { background: var(--surface-0); }
  .fc-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .fc-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
  .fc-item.completed { color: var(--text-secondary); }
  .fc-item.optional .fc-label::after { content: ' (optional)'; font-weight: 400; color: var(--text-secondary); }
  .fc-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; transition: all 0.15s; }
  .fc-item.active .fc-check { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
  .fc-item.completed .fc-check { border-color: var(--success); background: var(--success-ink); color: var(--accent-contrast); }
  .fc-label { flex: 1; text-align: left; }

  .sender-message { background: var(--surface-0); border-radius: var(--radius-md); padding: 12px; font-size: 12px; color: var(--text-secondary); line-height: 1.5; border-left: 3px solid var(--accent-border); }
  .sender-message .sm-from { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

  .ss-spacer { flex: 1; }

  /* ============================================ FOOTER ============================================ */
  .signing-footer { grid-area: footer; background: var(--surface-1); border-top: 1px solid var(--border); display: flex; align-items: center; padding: 10px 24px; gap: 12px; box-shadow: 0 -2px 8px rgb(0 0 0 / 0.04); z-index: 50; flex-wrap: wrap; }
  .sf-field-nav { display: flex; align-items: center; gap: 4px; }
  .sf-nav-btn { background: var(--surface-0); border: 1px solid var(--border); color: var(--text-secondary); padding: 8px 14px; border-radius: var(--radius-md); font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 4px; font-family: inherit; }
  .sf-nav-btn:hover:not(:disabled) { border-color: var(--accent-border); color: var(--accent); background: var(--accent-bg); }
  .sf-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
  .sf-field-indicator { font-size: 12px; color: var(--text-secondary); min-width: 100px; text-align: center; }
  .sf-spacer { flex: 1; }

  .sf-consent { display: flex; align-items: flex-start; gap: 6px; max-width: 300px; }
  .sf-consent input { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
  .sf-consent label { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
  .sf-consent a { color: var(--accent); text-decoration: none; }
  /* GSH M follow-up (real-device report, card 181): the checkbox is a direct child of its own
     <label> now (.sf-consent-wrap) so the ENTIRE row -- not just the ~13-22px input box -- is one
     tap target; cursor:pointer signals the whole row is clickable. */
  .sf-consent-wrap { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
  .sf-consent-text-inline { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
  .sf-consent-text-inline a { color: var(--accent); text-decoration: none; }

  .sf-decline-btn { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 10px 18px; border-radius: var(--radius-md); font-size: 13px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
  .sf-decline-btn:hover { border-color: var(--danger-border-hover); color: var(--danger-ink); background: var(--danger-bg-hover); }

  .sf-submit-btn { background: var(--success-ink); border: none; color: var(--accent-contrast); padding: 10px 28px; border-radius: var(--radius-md); font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 8px color-mix(in srgb, var(--success) 35%, transparent); font-family: inherit; }
  .sf-submit-btn:hover:not(:disabled) { filter: brightness(1.05); }
  .sf-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; }

  .form-banner { width: 100%; order: 10; font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm); display: none; }
  .form-banner.visible { display: block; }
  .form-banner.error { background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger-ink); border: 1px solid var(--danger-border-hover); }

  /* ============================================ COMPLETION / STATE OVERLAYS ============================================ */
  .completion-overlay, .state-overlay { display: none; position: fixed; inset: 0; background: rgb(255 255 255 / 0.95); z-index: 200; align-items: center; justify-content: center; flex-direction: column; gap: 16px; backdrop-filter: blur(8px); text-align: center; padding: 24px; }
  .completion-overlay.visible, .state-overlay.visible { display: flex; }
  .completion-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--success-bg); border: 3px solid var(--success); display: flex; align-items: center; justify-content: center; font-size: 28px; animation: popIn 0.5s var(--ease-spring); }
  .state-icon { width: 72px; height: 72px; border-radius: 50%; background: color-mix(in srgb, var(--border) 50%, transparent); border: 3px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 28px; }
  .state-icon.state-error { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
  @keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }
  .completion-title, .state-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-top: 8px; }
  .completion-subtitle, .state-subtitle { font-size: 15px; color: var(--text-secondary); text-align: center; max-width: 380px; line-height: 1.5; }
  .completion-actions { display: flex; gap: 10px; margin-top: 12px; }
  .completion-btn { padding: 10px 22px; border-radius: var(--radius-md); font-size: 13px; cursor: pointer; transition: all 0.15s; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font-family: inherit; }
  .completion-btn:hover { border-color: var(--accent-border); color: var(--accent); }
  .completion-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
  .completion-btn.primary:hover { filter: brightness(1.05); }

  /* Decline confirm — deliberately low-emphasis (context doc: "the decline button is ugly on
     purpose"); a plain, muted confirm step, not a dramatic red modal. */
  .decline-overlay { display: none; position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); z-index: 200; align-items: center; justify-content: center; }
  .decline-overlay.visible { display: flex; }
  .decline-panel { background: var(--surface-1); border-radius: var(--radius-md); width: 420px; max-width: 92vw; padding: 22px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.2); }
  .decline-panel h3 { font-size: 15px; color: var(--text-primary); margin-bottom: 8px; }
  .decline-panel p { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.5; }
  .decline-reason { width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 10px; font-family: inherit; font-size: 13px; color: var(--text-primary); resize: vertical; margin-bottom: 16px; }
  .decline-actions { display: flex; justify-content: flex-end; gap: 10px; }
  .decline-cancel { padding: 9px 18px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font-size: 13px; cursor: pointer; font-family: inherit; }
  .decline-confirm { padding: 9px 18px; border-radius: var(--radius-md); border: 1px solid var(--danger-border-hover); background: var(--surface-1); color: var(--danger-ink); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
  .decline-confirm:hover { background: var(--danger-bg-hover); }

  /* ============================================ SIGNATURE PAD OVERLAY ============================================ */
  .pad-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 250; display: none; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
  .pad-overlay.visible { display: flex; animation: fadeIn 0.15s var(--ease-out); }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .signing-pad { background: var(--surface-1); border-radius: var(--radius-lg); width: 560px; max-width: 94vw; box-shadow: 0 24px 80px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.15); animation: padSlideUp 0.3s var(--ease-spring); overflow: hidden; max-height: 92vh; overflow-y: auto; }
  @keyframes padSlideUp { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
  .pad-header { padding: 18px 22px 0; display: flex; align-items: center; justify-content: space-between; }
  .pad-title { font-size: 15px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
  .pad-title-icon { width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--accent-bg); display: flex; align-items: center; justify-content: center; font-size: 15px; }
  .pad-close { width: 28px; height: 28px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
  .pad-close:hover { background: var(--surface-0); color: var(--text-primary); }

  .pad-tabs { display: flex; padding: 14px 22px 0; gap: 2px; }
  .pad-tab { flex: 1; padding: 9px 14px; border-radius: var(--radius-md) var(--radius-md) 0 0; background: transparent; border: none; font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; }
  .pad-tab:hover { color: var(--text-secondary); background: var(--surface-0); }
  .pad-tab.active { background: var(--surface-0); color: var(--accent); font-weight: 600; }
  .pad-content { background: var(--surface-0); margin: 0 22px; border-radius: 0 0 12px 12px; overflow: hidden; }
  .tab-panel { display: none; }
  .tab-panel.active { display: block; }

  .draw-panel { padding: 16px; position: relative; }
  .canvas-wrapper { position: relative; background: var(--canvas-bg); border: 2px solid var(--border); border-radius: var(--radius-md); overflow: hidden; cursor: crosshair; transition: border-color 0.2s; }
  .canvas-wrapper:hover { border-color: var(--accent-border); }
  .canvas-wrapper.drawing { border-color: var(--accent); }
  .canvas-wrapper canvas { display: block; width: 100%; touch-action: none; }
  .canvas-guide { position: absolute; bottom: 28px; left: 16px; right: 16px; height: 1px; background: var(--guide-color); pointer-events: none; }
  .canvas-guide-label { position: absolute; right: 0; bottom: 4px; font-size: 12px; color: var(--text-secondary); font-style: italic; pointer-events: none; }
  .canvas-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; flex-wrap: wrap; gap: 8px; }
  .canvas-clear, .canvas-undo { padding: 5px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; transition: all 0.15s; display: flex; align-items: center; gap: 4px; }
  .canvas-clear:hover { border-color: var(--danger-border-hover); color: var(--danger-ink); }
  .canvas-undo:hover { border-color: var(--accent-border); color: var(--accent); }
  .canvas-ink-color { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
  .ink-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; transition: all 0.15s; }
  .ink-swatch:hover { transform: scale(1.15); }
  .ink-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
  .ink-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .type-panel { padding: 16px; }
  .type-input-row { position: relative; margin-bottom: 14px; }
  .type-input { width: 100%; padding: 10px 14px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font-size: 15px; font-family: inherit; outline: none; transition: border-color 0.15s; }
  .type-input:focus { border-color: var(--accent); }
  .font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .font-option { padding: 12px 14px; border-radius: var(--radius-md); border: 2px solid var(--border-light); background: var(--surface-1); cursor: pointer; transition: all 0.15s; text-align: center; position: relative; overflow: hidden; font-family: inherit; }
  .font-option:hover { border-color: var(--accent-border); }
  .font-option.selected { border-color: var(--accent); background: var(--accent-bg); }
  .font-option.selected::after { content: '✓'; position: absolute; top: 4px; right: 6px; font-size: 12px; color: var(--accent); font-weight: 700; }
  .font-preview { font-size: 22px; color: var(--ink-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; min-height: 32px; }
  .font-name { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; font-family: var(--font-ui); margin-top: 2px; }

  .upload-panel { padding: 16px; }
  .upload-drop { border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 28px 20px; text-align: center; cursor: pointer; transition: all 0.2s; background: var(--surface-1); font-family: inherit; width: 100%; }
  .upload-drop:hover { border-color: var(--accent-border); background: var(--accent-bg); }
  .upload-drop.has-image { border-style: solid; border-color: var(--success); background: var(--success-bg); }
  .upload-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.5; }
  .upload-text { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
  .upload-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
  .upload-preview { display: none; flex-direction: column; align-items: center; gap: 8px; }
  .upload-preview.visible { display: flex; }
  .upload-change { font-size: 12px; color: var(--accent); cursor: pointer; background: none; border: none; font-family: inherit; font-weight: 500; }
  .upload-change:hover { text-decoration: underline; }

  .pad-preview-section { padding: 12px 22px 0; }
  .pad-preview-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
  .preview-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: livePulse 1.5s ease-in-out infinite; }
  @keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
  .field-preview-box { height: 44px; border-radius: var(--radius-sm); border: 2px solid var(--accent-border); background: var(--accent-bg); display: flex; align-items: center; justify-content: center; padding: 4px 8px; position: relative; overflow: hidden; }
  .field-preview-box canvas, .field-preview-box img { max-width: 100%; max-height: 100%; }
  .field-preview-empty { font-size: 12px; color: var(--text-secondary); font-style: italic; }
  .scale-indicator { font-size: 12px; color: var(--text-secondary); text-align: right; margin-top: 3px; font-family: var(--font-mono); }

  .pad-footer { padding: 14px 22px 18px; display: flex; align-items: center; justify-content: space-between; }
  .pad-cancel { padding: 9px 20px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: all 0.15s; }
  .pad-cancel:hover { border-color: var(--text-secondary); color: var(--text-primary); }
  .pad-apply { padding: 10px 28px; border-radius: var(--radius-md); border: none; background: var(--accent); color: var(--accent-contrast); font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.15s; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 8px var(--accent-bg); }
  .pad-apply:hover:not(:disabled) { filter: brightness(1.05); }
  .pad-apply:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

  .toast { font-weight: 500; max-width: none; position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-header); color: var(--header-text); border-radius: var(--radius-md); padding: 10px 18px; font-size: 13px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.2); z-index: 300; opacity: 0; transition: all 0.25s var(--ease-out); pointer-events: none; }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  .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; }

  /* GSH-SIGN accessibility pass (card 108): a consistent, high-contrast focus ring on every
     remaining focusable control. var(--accent) measures 3.68:1 against white -- passes
     WCAG 1.4.11 non-text contrast (>=3:1) -- and is the exact value the handful of controls above
     that already had their own :focus-visible rule (.sf-capture-btn/.fc-item/.ink-swatch/
     .cert-copy-btn/.completion-btn) already use; this generalizes that same ring to every control
     that was previously relying on an inconsistent (or, for .type-input, explicitly removed with no
     replacement) browser default. Lower-specificity than the per-component rules above, so it never
     changes their existing appearance -- it only fills the gaps. */
  button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
  textarea:focus-visible, [role="tab"]:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
  /* ============================================ RESULT PAGES (terminal states + certificate) ===
     F2 addition: expired/declined/already-signed/invalid-link/could-not-sign/could-not-decline and
     the certificate ("signed") page are separate SSR page loads (not overlays over the app shell,
     since the app shell is never rendered for these states) -- reuses the same header brand strip
     and completion-* / state-* classes from the guided app's overlays, in a static (non-fixed),
     full-viewport centered layout instead of position:fixed. ============================== */
  .result-shell { min-height: calc(100vh - var(--header-height)); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; text-align: center; padding: 24px; background: var(--surface-0); }
  .result-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; max-width: 460px; width: 100%; box-shadow: 0 4px 20px rgb(0 0 0 / 0.06); display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .result-card.cert-card { max-width: 520px; }
  .cert-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--success-bg); color: var(--success); padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
  .cert-eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); margin-top: 10px; }
  .cert-divider { width: 48px; height: 1px; background: var(--border); margin: 12px 0; }
  .cert-timeline { text-align: left; width: 100%; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-light); }
  .cert-timeline-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); margin-bottom: 8px; }
  .cert-timeline-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); padding: 3px 0; }
  .cert-timeline-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
  .cert-timeline-item .who { color: var(--text-primary); flex: 1; }
  .cert-payment { width: 100%; background: var(--warning-bg); border: 2px solid var(--warning); border-radius: var(--radius-md); padding: 16px; margin-bottom: 8px; text-align: left; }
  .cert-payment h3 { font-size: 13px; font-weight: 700; color: var(--warning-ink); margin-bottom: 6px; }
  .cert-payment p { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
  .result-banner { width: 100%; font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger-ink); border: 1px solid var(--danger-border-hover); margin-top: 4px; }
  .completion-btn.disabled-note { position: relative; }
  .completion-btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .completion-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; background: var(--bg-header); color: var(--header-text); font-size: 12px; padding: 4px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
  .gsh-result-body { height: auto; min-height: 100vh; overflow-y: auto; }

  /* GSH G2 (card 95, brief .sdd/briefs/gsh-g-hashing-certificate.md, G2 section) -- certificate
     hash display + public verify page. Tokens only (rule 1), reusing the alias layer above --
     nothing here is a new hardcoded hex. Pasted byte-identical into View: Render, Submit: Render,
     and View: Verify Render (Code nodes can't share code -- G1's canonicalizeForHash precedent). */
  .state-icon.state-success { background: var(--success-bg); border-color: var(--success); }
  .state-icon.state-warning { background: var(--warning-bg); border-color: var(--warning); }
  .state-icon.state-neutral { background: color-mix(in srgb, var(--border) 50%, transparent); border-color: var(--border); }
  .cert-signers, .cert-hashes, .cert-meta { text-align: left; width: 100%; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-light); }
  .cert-signer-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); padding: 4px 0; flex-wrap: wrap; }
  .cert-signer-role { font-weight: 700; color: var(--text-primary); background: var(--accent-bg); border-radius: var(--radius-sm); padding: 1px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
  .cert-signer-name { color: var(--text-primary); font-weight: 600; }
  .cert-signer-time { margin-left: auto; color: var(--text-secondary); font-size: 12px; }
  .cert-signer-time-pending { color: var(--warning-ink); font-style: italic; }
  .cert-hash-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
  .cert-hash-label { font-size: 12px; color: var(--text-secondary); min-width: 130px; }
  .cert-hash-value { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); background: color-mix(in srgb, var(--border) 30%, transparent); border-radius: var(--radius-sm); padding: 2px 6px; word-break: break-all; }
  .cert-hash-value.cert-hash-full { font-size: 12px; }
  .cert-hash-empty { color: var(--text-secondary); font-style: italic; background: none; padding: 0; }
  .cert-copy-btn { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); cursor: pointer; font-family: inherit; }
  .cert-copy-btn:hover { border-color: var(--accent-border); color: var(--accent); }
  .cert-copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .cert-copy-btn.copied { border-color: var(--success); color: var(--success); }
  .cert-status-note { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
  .cert-attestation { font-size: 12px; color: var(--text-secondary); max-width: 400px; margin-top: 14px; line-height: 1.5; }
  .verify-footer { font-size: 12px; color: var(--text-secondary); margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-light); width: 100%; text-align: center; }
  .completion-btn.primary:focus-visible, .completion-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .consent-disclosure .consent-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
  .legal-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 20px; }
  .legal-banner-badge { flex-shrink: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--warning-ink); background: var(--surface-1); border: 1px solid var(--warning-border); border-radius: 999px; padding: 3px 10px; }
  .legal-banner-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
  .result-card.legal-card { max-width: 720px; text-align: left; align-items: stretch; gap: 0; }
  .legal-eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); }
  .legal-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 6px 0 4px; }
  .legal-updated { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
  .legal-section { margin-bottom: 18px; text-align: left; }
  .legal-section h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0 0 6px; }
  .legal-section p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin: 0 0 8px; }
  .legal-section ol, .legal-section ul { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
  .legal-section li { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
  .legal-footer-links { margin-top: 4px; font-size: 12px; }
  .legal-footer-links a { color: var(--accent); }
  .cert-signer-block { width: 100%; padding: 4px 0; border-bottom: 1px dashed var(--border-light); }
  .cert-signer-block:last-child { border-bottom: none; }
  .cert-signer-detail { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); padding: 2px 0 6px 0; width: 100%; }
  .cert-signer-detail-empty { font-style: italic; }
  .cert-verify-howto p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-top: 6px; }
  .cert-verify-link-text { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }


  /* ============================================================
     GSH M (card 181) — mobile/tablet responsive round. Breakpoints per the brief: >=1100px keeps
     the current 3-zone layout untouched (no rule above this block changes); 700-1099px (tablet)
     collapses the sidebar to a compact top strip; <700px (phone) further collapses the footer to a
     sticky consent+Finish+overflow bar and moves field navigation into the top strip. Canonical
     §19's collapse order (nav/sidebar first, secondary columns/actions next, primary action never
     hidden) drives which pieces move into a disclosure/overflow vs. which stay always visible.
     ============================================================ */

  /* Finish is never silently inert (req 4): the native `disabled` attribute suppresses the
     click/submit event entirely, so a tap produced zero feedback -- the actual root cause of
     "Finish does nothing". #submitBtn no longer carries `disabled`; this class is the same visual
     treatment, toggled via aria-disabled by updateProgress(), and the button stays a real
     type=submit that always reaches onSubmit()'s guard (see CLIENT_SCRIPT). */
  .sf-submit-btn.is-disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; }
  .sf-consent.invalid-consent { outline: 2px solid var(--danger); outline-offset: 2px; border-radius: var(--radius-sm); }

  /* Header help button: icon-only past 699px (see phone media block) needs a label to hide without
     losing the accessible name -- the button itself always carries aria-label. */
  .sh-help-label { }

  /* "Fields" disclosure trigger (tablet+phone) and the consent-notice trigger (same breakpoints) --
     hidden at desktop, where the full sidebar (checklist inline, consent disclosure inline) is
     still visible exactly as before this round. */
  .fields-toggle, .sf-consent-notice-btn, .sf-overflow, .mobile-next-btn, .consent-sheet-close { display: none; }
  .fields-toggle { align-items: center; gap: 6px; background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); cursor: pointer; font-family: inherit; white-space: nowrap; }
  .fields-toggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-border); background: var(--accent-bg); }
  .fields-toggle .ft-chevron { transition: transform 0.15s var(--ease-out); }
  .fields-toggle[aria-expanded="true"] .ft-chevron { transform: rotate(180deg); }

  .sf-consent-notice-btn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: underline; cursor: pointer; font-family: inherit; padding: 2px 0; text-align: left; }
  .sf-consent-text { display: flex; flex-direction: column; gap: 2px; }

  .consent-sheet-backdrop { display: none; position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); z-index: 255; }
  .consent-sheet-backdrop.open { display: block; animation: fadeIn 0.15s var(--ease-out); }
  .consent-sheet-close { align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-md); border: none; background: var(--surface-0); color: var(--text-secondary); cursor: pointer; font-size: 15px; }
  .consent-sheet-close:hover { background: var(--border-light); color: var(--text-primary); }

  .sf-overflow { position: relative; }
  .sf-more-btn { width: 40px; height: 40px; min-height: 40px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); font-size: 17px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: inherit; }
  .sf-more-btn:hover, .sf-more-btn[aria-expanded="true"] { border-color: var(--accent-border); color: var(--accent); background: var(--accent-bg); }
  .sf-overflow-menu { display: none; position: absolute; bottom: calc(100% + 8px); left: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; min-width: 170px; z-index: 60; }
  .sf-overflow-menu.open { display: block; }
  .sf-overflow-menu button { all: unset; box-sizing: border-box; display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; color: var(--danger-ink); cursor: pointer; }
  .sf-overflow-menu button:hover { background: var(--danger-bg-hover); }

  .mobile-next-btn { align-items: center; gap: 4px; background: var(--accent); border: none; color: var(--accent-contrast); font-size: 12px; font-weight: 600; border-radius: var(--radius-md); padding: 8px 12px; cursor: pointer; font-family: inherit; white-space: nowrap; flex-shrink: 0; }
  .mobile-next-btn:hover { filter: brightness(1.05); }

  /* ============================================================
     TABLET + PHONE — shared collapse: sidebar becomes a compact top strip, the document goes full
     width and scales down (syncDocScale(), CLIENT_SCRIPT), touch targets grow to 44px, inputs read
     at >=16px to stop iOS Safari's auto-zoom-on-focus.
     ============================================================ */
  @media (max-width: 1099px) {
    .signing-layout {
      grid-template-columns: 1fr;
      grid-template-rows: var(--header-height) auto 1fr auto;
      grid-template-areas: "header" "sidebar" "document" "footer";
    }
    .signing-layout > * { min-width: 0; }

    .signing-sidebar {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: center;
      overflow: visible;
      border-left: none;
      border-bottom: 1px solid var(--border);
      padding: 10px 16px;
      gap: 10px 14px;
      position: relative;
      z-index: 40;
    }
    .signing-sidebar .ss-section { padding: 0; border-bottom: none; flex-shrink: 0; }
    .signing-sidebar .ss-section-title { display: none; }
    .signing-sidebar .sender-message,
    .signing-sidebar .ss-spacer { display: none; }
    .signing-sidebar #checklistSection { display: none; } /* replaced by the floating .fields-toggle panel below */
    #checklistSection.open {
      display: block;
      position: absolute; top: 100%; left: 16px; right: 16px;
      max-height: 60vh; overflow-y: auto;
      background: var(--surface-1); border: 1px solid var(--border); border-radius: 0 0 10px 10px;
      box-shadow: var(--shadow-lg); padding: 12px 14px; z-index: 45;
    }
    #checklistSection.open .ss-section-title { display: block; }

    /* Consent disclosure — same content, same DOM node, repositioned into a bottom sheet instead of
       an inline sidebar column (req 1's "moves into a bottom sheet opened from the checkbox label"). */
    #consentDisclosureSection {
      position: fixed; left: 0; right: 0; bottom: 0; top: auto;
      max-height: 80vh; overflow-y: auto;
      background: var(--surface-1);
      border-top: 1px solid var(--border);
      border-radius: var(--radius-lg) 16px 0 0;
      box-shadow: var(--shadow-lg);
      padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
      z-index: 260;
      display: none;
    }
    #consentDisclosureSection.open { display: block; animation: padSlideUp 0.3s var(--ease-spring); }
    #consentDisclosureSection .ss-section-title { display: block; padding-right: 36px; }
    .consent-sheet-close { display: flex; position: absolute; top: 16px; right: 16px; }
    .sf-consent-notice-btn { display: inline-block; }

    .fields-toggle { display: inline-flex; }
    .progress-block { gap: 10px; }
    .progress-ring-container { width: 38px; height: 38px; }
    .progress-ring { width: 38px; height: 38px; }
    .progress-ring circle { stroke-width: 4; }
    .progress-center-text { font-size: 12px; }
    .progress-stats { flex-direction: row; align-items: center; gap: 6px; }
    .progress-stats .ps-label, .progress-stats .ps-sub { display: none; }
    .progress-stats .ps-detail { font-size: 13px; }
    .signer-details .sd-email { display: none; }
    .signer-avatar { width: 30px; height: 30px; font-size: 12px; }

    /* Document — full width, scaled uniformly by syncDocScale() rather than clipped. */
    .document-area { padding: 16px; }
    .doc-page-scale-wrap { margin-bottom: 12px; }
    .start-bar { width: 100%; }

    /* Touch + input sizing (req 5) */
    .sf-input, .sf-select, .sf-textarea, .type-input { font-size: 15px; }
    .sf-nav-btn, .sf-decline-btn, .sf-submit-btn, .sh-help-btn, .pad-tab, .pad-cancel, .pad-apply,
    .canvas-undo, .canvas-clear, .fc-item, .fields-toggle, .mobile-next-btn, .consent-sheet-close,
    .sf-more-btn, .decline-cancel, .decline-confirm, .start-btn, .fc-item, .sf-consent-notice-btn,
    .pad-close {
      /* GSH-SIGN accessibility pass (card 108): min-width added alongside the existing min-height --
         several of these (.pad-close was 28x28, .consent-sheet-close 32x32, .sf-more-btn 40x40) had
         a fixed `width` from their base (non-media) rule that this block's min-height alone never
         widened, so the tappable box stayed narrower than 44px even though it was tall enough. */
      min-height: 44px;
      min-width: 44px;
    }
    .ink-swatch { width: 30px; height: 30px; }
    .sf-checkbox-wrap input { width: min(24px, 80%); height: min(24px, 80%); }
    #consentCheckbox { width: 24px; height: 24px; margin-top: 0; flex-shrink: 0; }
    .sf-consent { align-items: center; gap: 10px; }
    /* GSH M follow-up (real-device report, card 181): the real 44px target is the WHOLE row
       (.sf-consent-wrap), not the checkbox box alone -- a real thumb has more slop than a
       synthetic test tap, and the un-padded label row was too tight to reliably hit. */
    .sf-consent-wrap { min-height: 44px; align-items: center; padding: 4px 0; }
    .sf-consent-text-inline { font-size: 12px; }

    /* Signature pad — full-screen sheet (req 3), Apply/Cancel pinned via safe-area insets. */
    .pad-overlay { align-items: flex-end; padding: 0; }
    .signing-pad {
      width: 100%; max-width: 100%; height: 100%; max-height: 100%;
      border-radius: 0; display: flex; flex-direction: column; animation: none;
    }
    .pad-header { padding-top: calc(18px + env(safe-area-inset-top)); flex-shrink: 0; }
    .pad-tabs, .pad-preview-section { flex-shrink: 0; }
    .pad-content { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin: 0 16px; }
    .tab-panel { flex: 1 1 auto; min-height: 0; }
    .tab-panel.active { display: flex; flex-direction: column; }
    .draw-panel, .type-panel, .upload-panel { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
    .canvas-wrapper { flex: 1 1 auto; min-height: 180px; }
    .pad-footer {
      flex-shrink: 0; position: sticky; bottom: 0; background: var(--surface-1);
      padding-bottom: calc(18px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--border-light);
    }
  }

  /* ============================================================
     PHONE ONLY (<700px) — footer collapses to consent + Finish + a Decline overflow menu; field
     navigation (Prev/Next) moves out of the footer into the top strip's single "Next" button
     (Prev is reachable via the Fields disclosure list, which supports jumping to any field).
     ============================================================ */
  @media (max-width: 699px) {
    .sh-security { display: none; }
    .sh-help-label { display: none; }
    .sh-help-btn { padding: 0; width: 36px; height: 36px; justify-content: center; }

    .mobile-next-btn { display: inline-flex; }

    .signing-footer {
      flex-wrap: wrap;
      padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
      gap: 8px;
      position: sticky;
      bottom: 0;
    }
    .sf-field-nav { display: none; }
    .sf-spacer { display: none; }
    .sf-consent { order: 1; width: 100%; max-width: none; }
    .sf-decline-btn { display: none; }
    .sf-overflow { display: inline-block; order: 2; }
    .sf-submit-btn { order: 3; flex: 1 1 auto; justify-content: center; }
    .form-banner { order: 10; }
  }

/* ============================================ p4a additions ============================================ */
@font-face { font-family: 'GshInter'; src: url(/assets/fonts/InterVariable.woff2) format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
body { font-family: var(--font-ui); }
.canvas-btns { display: flex; gap: 6px; }
.ink-black { background: var(--ink-black); }
.ink-navy { background: var(--ink-navy); }
.ink-indigo { background: var(--ink-indigo); }
.type-sample { font-family: 'GshInter', sans-serif; font-weight: 500; font-style: italic; font-size: 28px; text-align: center; color: var(--ink-black); padding: 10px 0 4px; min-height: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad-all { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.pad-all input { width: 16px; height: 16px; accent-color: var(--accent); }
.pad-all.is-hidden { display: none; }
.consent-pending { font-size: 12px; font-weight: 700; color: var(--warning-ink); background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 10px; }
.decline-error { color: var(--danger-ink); font-size: 12px; min-height: 0; margin-top: 6px; }
.done-overlay { display: none; position: fixed; inset: 0; z-index: 300; background: var(--surface-0); align-items: center; justify-content: center; padding: 24px; }
.done-overlay.visible { display: flex; }
.done-overlay .result-card { align-items: center; text-align: center; }
.state-icon.state-success { background: var(--success-bg); border-color: var(--success); }
.field-preview-box canvas, .field-preview-box img { max-width: 100%; max-height: 100%; }

/* stacked page images; the 760 px logical page is scaled to fit by sign.js */
.doc-page { width: 760px; min-height: 0; position: relative; transform-origin: top left; background: transparent; box-shadow: none; border-radius: 0; }
.sp-page { position: relative; width: 760px; margin: 0 0 14px; background: var(--surface-1); box-shadow: 0 1px 8px rgb(0 0 0 / 0.08); border-radius: var(--radius-sm); }
.sp-page > img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.sp-pn { position: absolute; right: 8px; bottom: -12px; font-size: 12px; color: var(--text-secondary); }
.signing-field.field-locked { background: transparent; border-color: transparent; pointer-events: none; }
.signing-field.field-locked:hover { box-shadow: none; }
.signing-field.field-other { background: color-mix(in srgb, var(--border) 25%, transparent); border: 1px dashed var(--border); pointer-events: none; }
.sf-role-tag { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 600; color: var(--text-secondary); max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-ro-text { display: block; width: 100%; height: 100%; padding: 0 6px; font-size: 12px; line-height: 1.2; color: var(--text-primary); white-space: pre-wrap; overflow: hidden; display: flex; align-items: center; }
.sf-ro-img { width: 100%; height: 100%; object-fit: contain; }
.signing-field.field-static { background: transparent; border: none; }
.signing-field.field-static .sf-label-static { font-style: normal; color: var(--text-primary); padding: 0 2px; }
@media print { .signing-sidebar, .signing-footer, .signing-header { display: none !important; } }
.doc-page-scale-wrap { overflow: hidden; }
/* p6b: sender identity always visible; the data link in the footer */
.sh-sender { display: block; font-weight: 700; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-data-link { font-size: 12px; color: var(--accent-ink); font-weight: 600; white-space: nowrap; }

/* p4c: several documents in one package - the switcher, the per-document headings, the done list */
.doc-switcher { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ds-item { width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); color: var(--text-primary); font: inherit; font-size: 13px; cursor: pointer; }
.ds-item:hover { background: var(--accent-soft); }
.ds-item.current { border-color: var(--accent); background: var(--accent-soft); }
.ds-num { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2-shade); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
.ds-item.completed .ds-num { background: var(--success-soft); color: var(--success-ink); }
.ds-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ds-prog { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.sp-doc-head { width: 760px; max-width: 100%; margin: 18px auto 8px; padding: 10px 14px; font-size: 22px; border-left: 4px solid var(--accent); background: var(--surface-1); font-weight: 700; font-size: 14px; border-radius: var(--radius-sm); }
.done-docs { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; color: var(--text-secondary); }
.done-docs:empty { display: none; }
.consent-disclosure .consent-more { margin: 10px 0 0; font-size: 12px; }
