/* ============================================================================
   Undersign — design system
   Editorial-meets-app: Fraunces (display) · Newsreader (document text) ·
   system-ui (crisp UI chrome) · JetBrains Mono (audit / hashes).
   Token-driven; light is :root, dark via prefers-color-scheme.
   ========================================================================== */

:root {
  /* palette — ink on warm paper, teal "ink" accent, terracotta "wax seal" */
  --paper:      #fbfaf8;
  --surface:    #ffffff;
  --surface-2:  #f4f1ea;
  --ink:        #15181f;
  --ink-soft:   #4a4f5a;
  --ink-faint:  #898f9b;
  --line:       #e7e3da;
  --line-soft:  #f0ede6;
  --accent:     #0e7c66;   /* teal ink */
  --accent-ink: #0a5e4d;
  --accent-bg:  #e6f3ef;
  --seal:       #c2410c;   /* wax-seal terracotta — completion moments */
  --seal-bg:    #fbeae0;
  --ok:         #15803d;
  --warn:       #b45309;
  --danger:     #b91c1c;

  --shadow-sm:  0 1px 2px rgba(20,24,31,.06), 0 1px 3px rgba(20,24,31,.05);
  --shadow-md:  0 4px 12px rgba(20,24,31,.08), 0 2px 6px rgba(20,24,31,.05);
  --shadow-lg:  0 18px 50px rgba(20,24,31,.16), 0 6px 18px rgba(20,24,31,.08);

  /* type */
  --font-display: "Fraunces", Georgia, serif;
  --font-text:    "Newsreader", Georgia, serif;
  --font-ui:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* rhythm */
  --r-xs: 6px;  --r-sm: 10px;  --r-md: 14px;  --r-lg: 20px;  --r-full: 999px;
  --pad:  clamp(16px, 4vw, 40px);
  --maxw: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0c0e13;
    --surface:    #14171e;
    --surface-2:  #1b1f28;
    --ink:        #eceef2;
    --ink-soft:   #aab0bb;
    --ink-faint:  #6c7280;
    --line:       #262b35;
    --line-soft:  #1d212a;
    --accent:     #2dd4bf;
    --accent-ink: #5eead4;
    --accent-bg:  #102b27;
    --seal:       #fb923c;
    --seal-bg:    #2a1c12;
    --ok:         #4ade80;
    --warn:       #fbbf24;
    --danger:     #f87171;
    --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
    --shadow-md:  0 4px 14px rgba(0,0,0,.45);
    --shadow-lg:  0 20px 56px rgba(0,0,0,.6), 0 6px 18px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.1; letter-spacing: -.01em; margin: 0; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 12px; }
.pad { padding: var(--pad); }

/* ---- topbar -------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px var(--pad);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-name { font-family: var(--font-display); font-size: 1.32rem; font-weight: 600; letter-spacing: -.02em; }
.brand-name::first-letter { color: var(--accent); }
.topbar-nav { display: flex; align-items: center; gap: 18px; }
.topbar-tag { font-size: .76rem; color: var(--ink-faint); letter-spacing: .02em; }
.topbar-apps { font-size: .82rem; color: var(--ink-soft); text-decoration: none; }
.topbar-apps:hover { color: var(--accent); }
@media (max-width: 620px) { .topbar-tag { display: none; } }

/* ---- app shell ----------------------------------------------------------- */
.app { flex: 1; width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: var(--pad); }

.appfoot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px var(--pad); border-top: 1px solid var(--line);
  font-family: var(--font-text); font-size: .86rem; color: var(--ink-soft);
}
.appfoot .sig { color: var(--ink-faint); white-space: nowrap; }
@media (max-width: 560px) { .appfoot { flex-direction: column; align-items: flex-start; gap: 6px; } }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 18px; border-radius: var(--r-full); font-size: .92rem; font-weight: 500;
  text-decoration: none; transition: transform .12s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-seal { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---- pills / badges ------------------------------------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-ui);
  font-size: .72rem; font-weight: 500; letter-spacing: .02em; text-transform: uppercase;
  padding: 3px 10px; border-radius: var(--r-full); background: var(--surface-2); color: var(--ink-soft);
}
.pill.is-draft    { background: var(--surface-2); color: var(--ink-soft); }
.pill.is-sent     { background: var(--accent-bg); color: var(--accent-ink); }
.pill.is-awaiting { background: var(--seal-bg); color: var(--seal); }
.pill.is-done     { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ============================================================================
   LANDING / DASHBOARD
   ========================================================================== */
.hero { text-align: center; padding: clamp(40px, 9vw, 92px) var(--pad) clamp(28px, 5vw, 52px); }
.hero .kicker {
  font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  font-weight: 500; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.4rem, 6.5vw, 4rem); font-weight: 500; max-width: 16ch; margin: 0 auto; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lede {
  font-family: var(--font-text); font-size: clamp(1.05rem, 2.4vw, 1.32rem);
  color: var(--ink-soft); max-width: 52ch; margin: 22px auto 0; line-height: 1.5;
}

/* dropzone */
.dropzone {
  max-width: 720px; margin: clamp(28px, 5vw, 44px) auto 0;
  border: 1.5px dashed var(--line); border-radius: var(--r-lg);
  background: var(--surface); padding: clamp(28px, 5vw, 48px);
  text-align: center; transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-bg); transform: scale(1.006); }
.dropzone .dz-icon { color: var(--accent); margin-bottom: 14px; }
.dropzone h2 { font-size: 1.35rem; margin-bottom: 6px; }
.dropzone p { color: var(--ink-soft); font-family: var(--font-text); margin: 0 0 20px; }
.dz-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.dz-or { color: var(--ink-faint); font-size: .82rem; margin: 18px 0 8px; }
.dz-samples { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dz-sample {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-full); padding: 7px 14px;
  font-size: .85rem; color: var(--ink-soft); text-decoration: none; transition: all .14s ease;
}
.dz-sample:hover { color: var(--accent); border-color: var(--accent); }

/* feature row */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; max-width: 880px; margin: clamp(40px,7vw,72px) auto 0; }
.feature { text-align: left; }
.feature .f-ic { color: var(--accent); margin-bottom: 10px; }
.feature h3 { font-family: var(--font-display); font-size: 1.06rem; margin-bottom: 4px; }
.feature p { font-family: var(--font-text); color: var(--ink-soft); font-size: .95rem; margin: 0; }
@media (max-width: 720px) { .features { grid-template-columns: 1fr; gap: 22px; max-width: 420px; } }

/* document library */
.library { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad) clamp(40px,7vw,72px); }
.lib-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 18px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.lib-head h2 { font-size: 1.5rem; }
.lib-head .count { color: var(--ink-faint); font-size: .85rem; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.doc-card {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px; box-shadow: var(--shadow-sm); transition: transform .14s ease, box-shadow .16s ease, border-color .16s ease;
  cursor: pointer; width: 100%; font: inherit; color: inherit;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.doc-card .dc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc-card .dc-ic { color: var(--accent); }
.doc-card .dc-name { font-family: var(--font-display); font-size: 1.06rem; font-weight: 500; line-height: 1.25; }
.doc-card .dc-meta { font-size: .8rem; color: var(--ink-faint); display: flex; gap: 10px; flex-wrap: wrap; }
.doc-card .dc-recips { display: flex; gap: -4px; margin-top: 2px; }
.empty-lib { text-align: center; color: var(--ink-faint); font-family: var(--font-text); padding: 28px; }

/* avatar chips for recipients */
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 600; color: #fff; border: 2px solid var(--surface); margin-left: -6px; }
.avatar:first-child { margin-left: 0; }

/* fade-in */
.fade-in { opacity: 0; transform: translateY(10px); animation: fade .6s ease forwards; }
.fade-in.d1 { animation-delay: .05s; } .fade-in.d2 { animation-delay: .13s; }
.fade-in.d3 { animation-delay: .22s; } .fade-in.d4 { animation-delay: .32s; }
@keyframes fade { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; opacity: 1; transform: none; } * { scroll-behavior: auto !important; } }

/* toast */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--r-full); font-size: .88rem; box-shadow: var(--shadow-lg); animation: fade .3s ease; }
.toast.is-seal { background: var(--seal); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }

/* ============================================================================
   EDITOR (Prepare / Sign) — bar + stage + side panel
   ========================================================================== */
.editor { display: flex; flex-direction: column; min-height: calc(100dvh - 56px); }
.editor-bar {
  display: flex; align-items: center; gap: 14px; padding: 10px var(--pad);
  border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 57px; z-index: 30;
}
.editor-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.editor-title .et-ic { color: var(--accent); flex: none; }
.editor-title .et-name { font-family: var(--font-display); font-size: 1.05rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-bar-right { display: flex; align-items: center; gap: 8px; flex: none; }

.editor-body { display: flex; flex: 1; align-items: flex-start; }
.editor-stage {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center;
  gap: 22px; padding: 28px var(--pad); background: var(--surface-2);
  min-height: calc(100dvh - 120px);
}
.stage-loading { color: var(--ink-faint); font-family: var(--font-text); padding: 40px; }

/* page column */
.pg-col { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.pg {
  position: relative; background: var(--surface); box-shadow: var(--shadow-md);
  border-radius: 3px; flex: none;
}
.pg-canvas { display: block; border-radius: 3px; }
.pg-overlay { position: absolute; inset: 0; z-index: 2; }
.pg-num {
  position: absolute; bottom: -22px; right: 2px; font-family: var(--font-mono);
  font-size: .72rem; color: var(--ink-faint);
}

/* side panel */
.editor-side {
  width: 320px; flex: none; align-self: stretch; border-left: 1px solid var(--line);
  background: var(--surface); padding: 20px; position: sticky; top: 114px;
  max-height: calc(100dvh - 114px); overflow: auto;
}
.side-sec { margin-bottom: 22px; }
.side-h { font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 8px; }
.side-note { font-family: var(--font-text); color: var(--ink-soft); font-size: .92rem; margin: 0; }

@media (max-width: 880px) {
  .editor-body { flex-direction: column; }
  .editor-side { width: 100%; border-left: none; border-top: 1px solid var(--line); position: static; max-height: none; }
  .editor-stage { padding: 18px 8px; }
}

/* ============================================================================
   FIELD EDITOR — palette, recipients, placeable fields
   ========================================================================== */
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pal-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .88rem;
  transition: all .14s ease; text-align: left;
}
.pal-item .pi-ic { color: var(--accent); display: inline-flex; }
.pal-item:hover { border-color: var(--accent); background: var(--accent-bg); }
.pal-item.armed { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.pal-item.armed .pi-ic { color: #fff; }

.recip-list { display: flex; flex-direction: column; gap: 6px; }
.recip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; width: 100%;
  transition: all .14s ease;
}
.recip:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.recip.sel { border-color: var(--accent); background: var(--accent-bg); }
.recip-name { flex: 1; font-size: .9rem; }
.recip-tick { color: var(--accent); font-weight: 700; }
.recip-email { display: block; font-size: .76rem; color: var(--ink-faint); }

.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.side-foot .count { font-size: .85rem; color: var(--ink-faint); }

/* overlay in edit mode */
.pg-overlay.is-edit { cursor: copy; }

/* placeable field */
.field {
  position: absolute; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  gap: 6px; border: 1.5px dashed var(--fc); border-radius: 6px;
  background: color-mix(in srgb, var(--fc) 12%, transparent);
  color: var(--fc); cursor: grab; touch-action: none; user-select: none;
  font-size: .8rem; font-weight: 500; overflow: hidden; transition: box-shadow .12s ease;
}
.field:hover { background: color-mix(in srgb, var(--fc) 18%, transparent); }
.field.sel { border-style: solid; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc) 35%, transparent); z-index: 5; }
.field.dragging { cursor: grabbing; box-shadow: var(--shadow-md); z-index: 6; }
.field-ic { display: inline-flex; opacity: .9; flex: none; }
.field-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field.f-checkbox .field-label, .field.f-checkbox .field-ic { display: none; }
.field.f-checkbox::after { content: ''; }
.field-del {
  position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff; font-size: 14px; line-height: 1;
  display: none; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.field.sel .field-del, .field:hover .field-del { display: flex; }
.field-resize {
  position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px; border-radius: 3px;
  background: var(--fc); border: 2px solid var(--surface); cursor: nwse-resize; display: none;
}
.field.sel .field-resize, .field:hover .field-resize { display: block; }
.field.f-checkbox .field-resize { display: none; }

/* ============================================================================
   MODAL + SIGNATURE PAD
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(15,18,24,.5); backdrop-filter: blur(3px); animation: fade .2s ease;
}
.modal {
  width: 100%; max-width: 600px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-family: var(--font-display); font-size: 1.2rem; }
.modal-x { border: none; background: none; font-size: 1.6rem; line-height: 1; color: var(--ink-faint); width: 32px; height: 32px; border-radius: 50%; }
.modal-x:hover { background: var(--surface-2); color: var(--ink); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-actions { display: flex; gap: 8px; }

.sig-tabs { display: flex; gap: 4px; padding: 10px 20px 0; }
.sig-tab { border: none; background: none; padding: 9px 16px; border-radius: var(--r-sm) var(--r-sm) 0 0; color: var(--ink-soft); font-size: .9rem; font-weight: 500; border-bottom: 2px solid transparent; }
.sig-tab.sel { color: var(--accent); border-bottom-color: var(--accent); }
.sig-tab:hover { color: var(--ink); }

.sig-tools { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ink-swatches { display: flex; gap: 6px; }
.ink { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.ink.sel { box-shadow: 0 0 0 2px var(--accent); }

.sig-pad { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); background: repeating-linear-gradient(var(--surface), var(--surface)); overflow: hidden; }
.sig-canvas { display: block; background: transparent; }
.sig-baseline { position: absolute; left: 24px; right: 24px; bottom: 38px; border-bottom: 1.5px dashed var(--line); pointer-events: none; }
.sig-x { position: absolute; left: 24px; bottom: 30px; color: var(--ink-faint); font-size: .9rem; pointer-events: none; }
.sig-hint { text-align: center; color: var(--ink-faint); font-family: var(--font-text); font-size: .9rem; margin: 10px 0 0; }

.sig-type-input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); font-size: 1rem; margin-bottom: 12px; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sig-font { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 10px; font-size: 1.5rem; color: var(--ink); }
.sig-font.sel { border-color: var(--accent); background: var(--accent-bg); }

.sig-saved { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.sig-saved-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.sig-thumb { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); padding: 4px; height: 44px; }
.sig-thumb:hover { border-color: var(--accent); }
.sig-thumb img { height: 100%; max-width: 110px; object-fit: contain; }
.sig-savechk { font-size: .85rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }

@media (max-width: 560px) { .sig-fonts { grid-template-columns: 1fr; } .modal-foot { flex-direction: column; align-items: stretch; } .modal-actions { justify-content: flex-end; } }

.sig-preview { margin-top: 14px; display: flex; justify-content: center; }

/* ============================================================================
   SIGNING — fields in the sign view, role list, progress
   ========================================================================== */
.recip { position: relative; }
.recip-pick { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; color: inherit; text-align: left; padding: 2px; }
.recip-meta { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.recip-meta .recip-name { font-size: .9rem; }
.recip-fc { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint); background: var(--surface-2); border-radius: var(--r-full); padding: 1px 8px; }
.recip-del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--ink-faint); font-size: 1.1rem; width: 22px; height: 22px; border-radius: 50%; }
.recip-del:hover { background: var(--surface-2); color: var(--danger); }
.recip-add { width: 100%; border: 1px dashed var(--line); background: none; color: var(--ink-soft); border-radius: var(--r-sm); padding: 9px; font-size: .86rem; margin-top: 4px; }
.recip-add:hover { border-color: var(--accent); color: var(--accent); }

.sign-progress .sp-bar { height: 7px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.sign-progress .sp-fill { height: 100%; background: var(--accent); border-radius: var(--r-full); transition: width .35s cubic-bezier(.3,.9,.3,1); }

/* signing fields */
.sfield {
  position: absolute; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: .82rem; font-weight: 500; overflow: hidden; text-align: center;
}
.sfield.todo.mine {
  border: 1.5px dashed var(--fc); background: color-mix(in srgb, var(--fc) 14%, transparent); color: var(--fc);
  cursor: pointer; animation: pulse 2.2s ease-in-out infinite;
}
.sfield.todo.mine:hover { background: color-mix(in srgb, var(--fc) 22%, transparent); }
.sfield.todo.other { border: 1.4px dashed var(--line); background: color-mix(in srgb, var(--ink-faint) 8%, transparent); color: var(--ink-faint); opacity: .8; }
.sfield.done { border: none; }
.sfield.clickable:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fc) 40%, transparent); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--fc) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .sfield.todo.mine { animation: none; } }

.sfield-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sfield-check { color: var(--accent); font-size: 1.3rem; font-weight: 700; }
.sfield-val { font-family: var(--font-text); color: var(--ink); font-size: .9rem; white-space: nowrap; overflow: hidden; }
.sfield-cta { pointer-events: none; padding: 0 4px; }
.sfield.f-checkbox .sfield-cta { font-size: 0; }

/* ============================================================================
   DONE / FINALIZED
   ========================================================================== */
.done-wrap { max-width: 760px; }
.done-working { text-align: center; color: var(--ink-faint); font-family: var(--font-text); padding: 60px; }
.seal {
  width: 86px; height: 86px; margin: 8px auto 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seal) 80%, #fff 0%), var(--seal));
  box-shadow: var(--shadow-lg), inset 0 2px 6px rgba(255,255,255,.25);
  animation: seal-in .5s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes seal-in { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 26px 0 36px; }

.done-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 640px) { .done-grid { grid-template-columns: 1fr; } }
.done-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; box-shadow: var(--shadow-sm); }
.done-card h3 { font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 12px; }
.party { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .9rem; }
.party > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.hash-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin: 10px 0 4px; }
.hash { display: block; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-soft); word-break: break-all; line-height: 1.5; }
.audit-list { display: flex; flex-direction: column; gap: 8px; }
.audit-row { display: flex; gap: 14px; font-size: .86rem; align-items: baseline; }
.audit-when { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-faint); white-space: nowrap; flex: none; width: 120px; }
.audit-what { color: var(--ink-soft); }
@media (max-width: 540px) { .audit-row { flex-direction: column; gap: 1px; } .audit-when { width: auto; } }

/* doc-card delete + header grouping (Phase 6) */
.doc-card .dc-top { position: relative; }
.doc-card .dc-ic { margin-right: auto; }
.dc-del {
  border: none; background: none; color: var(--ink-faint); font-size: 1.2rem; line-height: 1;
  width: 26px; height: 26px; border-radius: 50%; opacity: 0; transition: opacity .14s ease, background .14s ease, color .14s ease;
}
.doc-card:hover .dc-del, .doc-card:focus-within .dc-del { opacity: 1; }
.dc-del:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
@media (hover: none) { .dc-del { opacity: 1; } }
