:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #941c45;
  --accent-hover: #7a1639;
  --accent-soft: #fbeef3;
  --accent-ring: rgba(148, 28, 69, .25);
  --gold: #f7a701;
  --gold-hover: #df9600;
  --gold-ink: #3d2600;
  --gold-soft: #fff7e0;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  height: 58px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 16px; }
.brand strong { color: var(--accent); }
.brand .wordmark { display: block; height: 26px; width: auto; }
.auth-card .brand .wordmark { height: 44px; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* --- buttons & inputs --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--accent-ring);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input::placeholder { color: #94a3b8; }

/* --- layout --- */
.page { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* --- auth --- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-card .brand { justify-content: center; margin-bottom: 6px; font-size: 19px; }
.auth-card .lede { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; margin-bottom: 20px; }
.tab {
  flex: 1; height: 34px; border: 0; border-radius: 6px; background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .1); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 14px; }

/* --- documents --- */
.dropzone {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; margin-bottom: 20px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); flex: none; }
.dropzone strong { color: var(--text); }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border);
}
.doc-row:first-child { border-top: 0; }
.doc-row:hover { background: var(--surface-2); }
.doc-name { font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.doc-name:hover { color: var(--accent); }
.doc-meta { font-size: 13px; color: var(--muted); }
.doc-actions { display: flex; gap: 6px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.pill.draft { background: var(--warn-soft); color: var(--warn); }
.pill.signed { background: var(--ok-soft); color: var(--ok); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }

/* --- signature management --- */
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.sig-section { padding: 22px; margin-bottom: 18px; }
.sig-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sig-card { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.sig-card.default { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.sig-paper {
  height: 110px; display: grid; place-items: center; padding: 12px;
  background: #fff linear-gradient(transparent calc(100% - 26px), #e2e8f0 calc(100% - 26px), #e2e8f0 calc(100% - 25px), transparent calc(100% - 25px));
}
.sig-paper img { max-width: 100%; max-height: 80px; }
.sig-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--muted); }
.sig-foot .badge { color: var(--accent); font-weight: 700; }
.sig-empty { border: 2px dashed var(--border); border-radius: 9px; padding: 26px; text-align: center; color: var(--muted); }

/* --- modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; z-index: 60; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pad-wrap { position: relative; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; }
.pad { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; border-radius: 9px; }
.pad-line { position: absolute; left: 24px; right: 24px; bottom: 52px; border-bottom: 1px solid #cbd5e1; pointer-events: none; }
.pad-x { position: absolute; left: 24px; bottom: 56px; color: #94a3b8; font-size: 18px; pointer-events: none; }
.pad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; pointer-events: none; font-size: 14px; }
.pad-tools { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.font-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 12px; }
.font-option {
  height: 86px; border: 1px solid var(--border); border-radius: 9px; background: #fff; cursor: pointer;
  display: grid; place-items: center; overflow: hidden; padding: 0 12px; font-size: 32px; color: #111;
  white-space: nowrap; text-overflow: ellipsis;
}
.font-option.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.upload-preview { margin-top: 12px; min-height: 120px; border: 1px solid var(--border); border-radius: 9px; display: grid; place-items: center; background: #fff; padding: 12px; color: var(--muted); font-size: 14px; }
.upload-preview img { max-width: 100%; max-height: 140px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- signer --- */
.signer {
  display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: auto 1fr;
  grid-template-areas: "side head" "side main"; min-height: calc(100vh - 58px);
}
.signer > .palette { grid-area: side; }
.signer > .doc-head { grid-area: head; padding: 18px 24px 0; width: 100%; max-width: 948px; justify-self: center; margin-bottom: 0; }
.signer > .doc-area { grid-area: main; padding-top: 16px; }
.palette {
  position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px); overflow: auto;
  padding: 18px 16px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 14px;
}
.palette h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tool {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left;
}
.tool:hover { border-color: var(--accent); }
.tool.armed { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tool .ico { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: 14px; flex: none; }
.tool .preview { margin-left: auto; max-width: 70px; max-height: 24px; }
.palette .hint { font-size: 13px; color: var(--muted); margin: 0; }
.palette .spacer { flex: 1; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { margin-top: 3px; }

.doc-area { padding: 18px 24px 80px; overflow-x: clip; } /* clip, not hidden: hidden would stop the guide bar sticking */
.doc-head { display: flex; align-items: center; gap: 12px; margin: 0 auto 16px; max-width: 900px; flex-wrap: wrap; min-width: 0; }
.doc-head h1 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.doc-head .grow { flex: 1; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.page-wrap { position: relative; width: 100%; max-width: 900px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 6px 24px rgba(15, 23, 42, .08); }
.page-wrap img.page-img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.page-wrap.placing { cursor: copy; outline: 2px dashed var(--accent); outline-offset: 3px; }
.page-num { position: absolute; top: 100%; right: 0; margin-top: 4px; font-size: 12px; color: var(--muted); }

.f {
  position: absolute; touch-action: none; cursor: move;
  border: 1.5px dashed rgba(148, 28, 69, .55); background: rgba(251, 238, 243, .35); border-radius: 3px;
}
.f:hover, .f.sel { border-style: solid; border-color: var(--accent); }
.f.sel { background: rgba(251, 238, 243, .5); }
.f img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.f input {
  width: 100%; height: 100%; border: 0; background: transparent; padding: 0 3px;
  font-family: Helvetica, Arial, sans-serif; color: #0d0d1a; outline: none; cursor: text;
}
.f .tag { position: absolute; left: -1px; bottom: 100%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px 3px 0 0; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; opacity: 0; pointer-events: none; }
.f:hover .tag, .f.sel .tag { opacity: 1; }
.f .x, .f .grip { position: absolute; display: none; }
.f:hover .x, .f.sel .x, .f:hover .grip, .f.sel .grip { display: grid; }
.f .x {
  right: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--danger); color: #fff; place-items: center; cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}
.f .grip { right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; }

.signed-banner { max-width: 900px; margin: 0 auto 16px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; border-radius: var(--radius); font-size: 14px; }
.audit { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.audit li { padding: 8px 0; border-top: 1px solid var(--border); }
.audit li:first-child { border-top: 0; }
.audit .ev { font-weight: 650; text-transform: capitalize; color: var(--text); }
.audit .det { color: var(--muted); word-break: break-all; }
.hash { font-family: Consolas, "SFMono-Regular", monospace; font-size: 11px; word-break: break-all; color: var(--muted); }

/* --- guided signing: detected spots --- */
.guide {
  position: sticky; top: 66px; z-index: 20;
  max-width: 900px; margin: 0 auto 16px; padding: 10px 12px 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--gold-soft); border: 1px solid #fcd885; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 14px;
}
.guide .guide-text { flex: 1; min-width: 200px; }
.guide .guide-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); flex: none; }
.guide .guide-btn { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.guide .guide-btn:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.guide.done { background: var(--ok-soft); border-color: #a7f3d0; }
.guide.done .guide-dot { background: var(--ok); }
.guide.done .guide-btn { background: var(--ok); border-color: var(--ok); }
.guide.none { background: var(--surface); border-color: var(--border); position: static; box-shadow: none; }
.guide.none .guide-dot { background: var(--border-strong); }

.f.spot {
  cursor: pointer; border: 2px dashed var(--gold); background: rgba(255, 247, 224, .75);
  display: grid; place-items: center; transition: background .15s, box-shadow .15s;
}
.f.spot:hover, .f.spot:focus-visible { background: rgba(252, 216, 133, .85); outline: none; }
.f.spot .spot-tag {
  font-size: 11px; font-weight: 700; color: var(--gold-ink); text-transform: uppercase; letter-spacing: .05em;
  pointer-events: none; white-space: nowrap; overflow: hidden; max-width: 100%; padding: 0 4px;
}
.pointer {
  position: absolute; left: 0; transform: translateY(-50%); z-index: 3;
  padding: 4px 16px 4px 10px; background: var(--gold); color: var(--gold-ink);
  font-size: 12px; font-weight: 700; white-space: nowrap; pointer-events: none;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.pointer.right {
  left: auto; right: 0; padding: 4px 10px 4px 16px;
  clip-path: polygon(9px 0, 100% 0, 100% 100%, 9px 100%, 0 50%);
}
.f.spot.current { box-shadow: 0 0 0 4px rgba(247, 167, 1, .35); animation: nudge 1.4s ease-in-out infinite; }
.f.spot:hover .x, .f.spot.current .x, .f.spot:focus .x { display: grid; }
.f.spot .grip { display: none !important; }
.f.from-spot { border-color: rgba(4, 120, 87, .55); background: rgba(236, 253, 245, .25); }
@keyframes nudge { 50% { box-shadow: 0 0 0 8px rgba(247, 167, 1, .14); } }
.btn.ready { animation: ready 1.6s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 6px var(--accent-ring); } }

/* --- sign in --- */
.btn.ms { background: #2f2f2f; border-color: #2f2f2f; margin-bottom: 10px; }
.btn.ms:hover { background: #1f1f1f; border-color: #1f1f1f; }
.ms-logo { display: grid; grid-template-columns: 8px 8px; gap: 2px; }
.ms-logo i { width: 8px; height: 8px; display: block; }
.ms-logo i:nth-child(1) { background: #f25022; } .ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; } .ms-logo i:nth-child(4) { background: #ffb900; }
.auth-card .fine { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* --- document list tools --- */
.list-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.list-tools .search { flex: 1; min-width: 180px; max-width: 320px; margin-left: auto; height: 36px; }
.segmented .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); font-size: 11px; color: var(--muted); }
.segmented button.active .count { background: #fff; color: var(--accent); }
input[type=search] { width: 100%; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

/* --- sending & routing --- */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: 11px; font-weight: 700; vertical-align: 1px;
}
.pill.mine { background: #fdebb3; color: var(--gold-ink); }
.pill.out { background: var(--accent-soft); color: var(--accent); }
.pill.declined { background: var(--danger-soft); color: var(--danger); }
.pill.voided { background: var(--surface-2); color: var(--muted); }

.segmented.block { display: flex; width: 100%; }
.segmented.block button { flex: 1; padding: 8px 6px; }

.palette .from { font-size: 14px; }
blockquote.note {
  margin: 0; padding: 10px 12px; border-left: 3px solid var(--border-strong); background: var(--surface-2);
  border-radius: 0 8px 8px 0; font-size: 13px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.timeline .dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--c); border: 2px solid var(--c); background: var(--surface);
}
.timeline .t-signed .dot { background: var(--c); color: #fff; }
.timeline .t-current .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.timeline .t-declined .dot { border-color: var(--danger); color: var(--danger); }
.timeline .t-name { font-weight: 600; overflow-wrap: anywhere; }
.timeline .t-state { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.palette.send { gap: 12px; }
.signer:has(.palette.send) { grid-template-columns: 300px minmax(0, 1fr); }
.palette { overflow-x: hidden; }
.recips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recips-empty { font-size: 13px; color: var(--muted); padding: 10px; border: 1px dashed var(--border-strong); border-radius: 8px; }
.recip {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 8px; align-items: center;
  padding: 8px; border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 13px;
}
.recip.active { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 22%, transparent); }
.recip .num { width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; }
.recip .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recip .em { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recip .ops { display: flex; gap: 2px; }
.recip .ops button { width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.recip .ops button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.recip .ops button:disabled { opacity: .3; cursor: default; }
.recip select.role { grid-column: 2 / 4; height: 30px; font-size: 12px; padding: 0 8px; }

.search-wrap { position: relative; }
.search-wrap input { height: 36px; font-size: 14px; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: 260px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow);
}
.results .result {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0;
  background: transparent; font: inherit; font-size: 13px; text-align: left; cursor: pointer; color: var(--text);
}
.results .result:hover, .results .result:focus-visible { background: var(--accent-soft); outline: none; }
.results .result .muted { font-size: 12px; }
.results .result.none { color: var(--muted); cursor: default; }
.add-me { align-self: flex-start; }

.roles { display: flex; flex-direction: column; gap: 6px; }
.chip { font-size: 12px; padding: 6px 8px; border-radius: 7px; border-left: 3px solid var(--c); background: var(--surface-2); }
.chip.open { border-left-color: var(--gold); background: var(--gold-soft); }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tool.small { width: auto; padding: 5px 9px; gap: 6px; font-size: 13px; }
.tool.small .ico { width: 20px; height: 20px; font-size: 11px; }
textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; resize: vertical;
}

.f.assign {
  cursor: pointer; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  display: grid; place-items: center;
}
.f.assign.unassigned { border-style: dashed; }
.f.assign .lbl, .f.ghost .lbl {
  font-size: 11px; font-weight: 700; color: color-mix(in srgb, var(--c) 80%, #000); white-space: nowrap;
  overflow: hidden; max-width: 100%; padding: 0 4px; pointer-events: none;
}
.f.assign:hover .x, .f.assign:focus .x, .f.assign:hover .grip, .f.assign:focus .grip { display: grid; }
.f.ghost {
  pointer-events: none; border: 1.5px dashed var(--c); background: color-mix(in srgb, var(--c) 8%, transparent);
  display: grid; place-items: center; opacity: .8;
}
.f.fixed { cursor: default; }

.banner { max-width: 900px; margin: 0 auto 16px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; border-radius: var(--radius); font-size: 14px; border: 1px solid; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.banner.info { background: var(--accent-soft); color: var(--accent); border-color: #efc6d4; }
.banner.bad { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.banner.muted-banner { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.auth-card .btn.dev { margin-bottom: 8px; }

/* --- toasts --- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 14px; box-shadow: var(--shadow); max-width: 92vw; animation: pop .18s ease-out; }
.toast.error { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.secondary .spinner { border-color: var(--border); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand .wordmark { height: 22px; }
  .topbar .who #who-name { display: none; }
  .signer, .signer:has(.palette.send) { grid-template-columns: 1fr; grid-template-areas: "head" "side" "main"; }
  .signer > .doc-head { padding: 12px 12px 0; }
  .palette { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .palette .tool:not(.small) { width: 100%; }
  .palette .spacer { display: none; }
  .doc-area, .signer > .doc-area { padding: 14px 12px 60px; }
  .menu-item { min-height: 44px; }
  .doc-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .guide { top: 58px; }
  .list-tools .search { max-width: none; margin-left: 0; }
}
.toast .spinner { display: inline-block; vertical-align: -4px; margin-right: 4px; }

/* --- menus (who fills a spot, clear/remove) --- */
.menu {
  position: fixed; z-index: 70; min-width: 220px; max-width: min(320px, calc(100vw - 16px));
  padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18); animation: pop .12s ease-out;
}
.menu-title { padding: 6px 10px 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-note { padding: 6px 10px; font-size: 13px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 14px;
  text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.menu-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .hint { color: var(--muted); font-size: 12px; white-space: nowrap; }
.menu-item .tick { color: var(--accent); font-weight: 700; }
.menu-item.checked { font-weight: 600; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger-soft); }

/* --- reaching the x: keyboard, touch, and boxes that overlap --- */
.f:focus-within .x, .f:focus-within .grip { display: grid; }
.f:hover, .f.sel, .f:focus-within, .f.current { z-index: 5; }
.f .x::before { content: ""; position: absolute; inset: -6px; }   /* a bigger target than it looks */
.f.spot { touch-action: manipulation; cursor: pointer; }          /* spots don't move: let a finger scroll */
.f.fixed { touch-action: manipulation; }
.f:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
@media (hover: none) {
  /* No hover on a touch screen: the remove buttons are simply always there. */
  .f .x, .f.assign .x { display: grid; width: 26px; height: 26px; right: -13px; top: -13px; }
  .f.assign .grip, .f.sel .grip { display: grid; width: 16px; height: 16px; }
}

/* --- send screen: the people list --- */
.recip-who { min-width: 0; }
.recip:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
.recip .ops button:focus-visible { outline: 2px solid var(--accent); }

/* --- toasts with an action (Undo) --- */
.toast { display: flex; align-items: center; gap: 12px; }
.toast.has-action { pointer-events: auto; }
.toast-action {
  border: 0; background: transparent; color: var(--gold); font: inherit; font-weight: 700; cursor: pointer;
  padding: 2px 4px; border-radius: 5px;
}
.toast-action:hover, .toast-action:focus-visible { background: rgba(255, 255, 255, .12); outline: none; }

/* --- dialogs --- */
.modal.narrow { max-width: 460px; }
.modal-foot.spread { justify-content: space-between; align-items: center; }
.btn-row { display: flex; gap: 8px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { background: #991b1b; border-color: #991b1b; }
.mode-hint { margin-top: -4px; }
.palette .sender-head { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Packages: the upload dialog's document list, and where each document starts. */
.pkg-list { list-style: none; margin: 14px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.pkg-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 0; }
.pkg-list .pkg-n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.pkg-list .pkg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pkg-list .row-btns { display: flex; gap: 2px; flex: none; }
.pkg-list .row-btns button { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.pkg-list .row-btns button:hover:not(:disabled) { background: var(--surface-2); color: var(--text, inherit); }
.pkg-list .row-btns button:disabled { opacity: .3; cursor: default; }
.modal .segmented + .muted { margin: 10px 0 12px; }
.part-head { width: 100%; max-width: 900px; display: flex; align-items: baseline; gap: 10px; padding: 10px 2px 0; border-top: 2px solid var(--accent); scroll-margin-top: 16px; min-width: 0; }
.part-head:first-child { border-top: 0; padding-top: 0; }
.part-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.part-head .part-n { flex: none; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.part-jump { max-width: 260px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font: inherit; font-size: 13px; color: inherit; }
@media (max-width: 720px) { .part-jump { max-width: 100%; flex: 1 1 100%; } }

/* People outside Bridge Tower: email-code sign-in, the consent step, the send-screen tag. */
.auth-card .or { display: flex; align-items: center; gap: 10px; margin: 22px 0 14px; color: var(--muted); font-size: 12px; }
.auth-card .or::before, .auth-card .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-card .fine.left { text-align: left; margin: 0 0 12px; font-size: 13px; }
.auth-card h2.center { text-align: center; font-size: 18px; margin: 4px 0 8px; }
.code-form .field { margin-bottom: 12px; }
.code-form .btn-row.center { justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.code-input { font-size: 22px; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.consent { font-size: 14px; line-height: 1.55; }
.consent ul { margin: 8px 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.outside-tag { display: inline-block; margin-top: 3px; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 600;
  background: var(--gold-soft, #fff4d6); color: var(--gold-ink, #3d2600); vertical-align: 1px; }
/* Outside signers: their own account, and the terms page. */
.account-form .field { margin-bottom: 12px; }
.account-form .field small { display: block; margin-top: 4px; font-size: 12px; line-height: 1.4; }
.account-form .check { margin: 2px 0 14px; font-size: 13px; }
.account-form .btn.ghost { margin-top: 6px; }
.auth-card.terms { max-width: 600px; }
.auth-card.terms .modal-foot { margin-top: 10px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.account-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-form h3.step { margin: 0 0 6px; font-size: 16px; }
@media (max-width: 420px) { .account-form .two { grid-template-columns: 1fr; } }
