/* Signotika sender app — styles on top of /assets/base.css tokens. */
:root {
  --bg-2: #F1F5F9;
  --hover: rgba(67, 56, 202, .06);
  --ring: rgba(67, 56, 202, .28);
  --c-sent: #2563EB;
  --c-viewed: #D97706;
  --c-signed: #059669;
  --c-declined: #DC2626;
  --c-pending: #9CA3AF;
  --canvas-bg: #E9EDF3;
  --appbar-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-2: #0F172A;
    --hover: rgba(129, 140, 248, .10);
    --ring: rgba(129, 140, 248, .35);
    --c-sent: #60A5FA; --c-viewed: #FBBF24; --c-signed: #34D399; --c-declined: #F87171; --c-pending: #6B7280;
    --canvas-bg: #070B16;
  }
  .wordmark img { filter: none; }
}

[hidden] { display: none !important; }
body { min-height: 100vh; font-size: 15px; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
.ico { display: inline-flex; flex: none; }
.ico svg { display: block; }
button { cursor: pointer; }
.btn { transition: border-color .15s, background .15s, box-shadow .15s, filter .15s; white-space: nowrap; line-height: 1.2; }
.btn:focus-visible, .input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--brand); }
.input:focus { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--brand); }
.btn-sm { padding: .4rem .7rem; font-size: .875rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-icon { padding: .45rem; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); border-color: var(--danger); }
.btn-primary .ico, .btn-danger-solid .ico { color: #fff; }
.btn-lg { padding: .75rem 1.25rem; font-size: 1rem; }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
label { font-weight: 600; font-size: .875rem; }
.form-row { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field-err { color: var(--danger); font-size: .85rem; min-height: 0; }
.field-err:empty { display: none; }
.hint { font-size: .8125rem; color: var(--muted); font-weight: 400; }
.kbd { font: 600 .75rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: .15rem .35rem; background: var(--surface); }

/* ---------- App bar ---------- */
.appbar { position: sticky; top: 0; z-index: 40; height: var(--appbar-h); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.appbar-inner { height: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 16px; }
.appbar.wide .appbar-inner { max-width: none; }
.appbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.appbar-right { display: flex; align-items: center; gap: 10px; }
.wordmark { display: inline-flex; align-items: center; border-radius: 6px; }
.wordmark img { display: block; height: 27px; width: auto; }
.user-menu { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: .5rem; background: none; border: 1px solid transparent; border-radius: 999px; padding: 3px 10px 3px 3px; }
.avatar-btn:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.avatar-name { font-weight: 600; font-size: .9rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; padding: 6px; z-index: 60; }
.menu-head { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .9rem; }
.menu-head span { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.menu-item { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .55rem .65rem; border-radius: 6px; border: 0; background: none; color: var(--ink); text-decoration: none; font-size: .9rem; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.danger { color: var(--danger); }

/* ---------- Layout ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 28px 20px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 1.6rem; }
.page-sub { margin: 4px 0 0; color: var(--muted); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 700; padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { color: var(--muted); background: var(--bg-2); border-color: var(--line); }
.badge-sent { color: var(--c-sent); background: color-mix(in srgb, var(--c-sent) 11%, transparent); }
.badge-completed { color: var(--c-signed); background: color-mix(in srgb, var(--c-signed) 12%, transparent); }
.badge-declined, .badge-voided { color: var(--c-declined); background: color-mix(in srgb, var(--c-declined) 10%, transparent); }
.chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; padding: .15rem .55rem .15rem .45rem; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); max-width: 220px; }
.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c-pending); }
.dot-sent { background: var(--c-sent); }
.dot-viewed { background: var(--c-viewed); }
.dot-signed { background: var(--c-signed); }
.dot-declined { background: var(--c-declined); }
.dot-pending { background: var(--c-pending); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: .6rem; padding: .7rem .7rem .7rem .9rem; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.25); opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; font-size: .9rem; }
.toast.in { opacity: 1; transform: none; }
.toast-msg { flex: 1; }
.toast-success .ico:first-child { color: #34D399; }
.toast-error .ico:first-child { color: #F87171; }
.toast-info .ico:first-child { color: #A5B4FC; }
.toast-x { background: none; border: 0; color: inherit; opacity: .7; padding: 4px; border-radius: 6px; display: inline-flex; }
.toast-x:hover { opacity: 1; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .15s; }
.modal-backdrop.in { opacity: 1; }
.modal { width: min(460px, 100%); padding: 22px 22px 18px; transform: translateY(6px) scale(.98); transition: transform .15s; }
.modal-backdrop.in .modal { transform: none; }
.modal-title { font-size: 1.15rem; margin-bottom: .5rem; }
.modal-body { color: var(--muted); margin-bottom: 1rem; }
.modal-body p { margin: 0 0 .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.busy-card { display: flex; align-items: center; gap: 14px; width: auto; }
.busy-card p { margin: 0; font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: linear-gradient(150deg, #312E81 0%, #4338CA 55%, #0E7490 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content: ""; position: absolute; width: 520px; height: 520px; right: -180px; bottom: -200px; border-radius: 50%; background: radial-gradient(circle, rgba(45,212,191,.35), transparent 65%); }
.auth-aside h2 { font-size: 2.1rem; max-width: 420px; letter-spacing: -.02em; }
.auth-aside p { opacity: .85; max-width: 420px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; }
.auth-points .ico { background: rgba(255,255,255,.14); border-radius: 8px; padding: 6px; }
.auth-points strong { display: block; }
.auth-points span { opacity: .8; font-size: .9rem; }
.auth-aside .wordmark-light { font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; color: #fff; text-decoration: none; display: inline-flex; gap: 10px; align-items: center; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card .wordmark { margin-bottom: 28px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-card .lede { margin: 0 0 1.5rem; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 1.5rem; }
.seg button { border: 0; background: none; padding: .5rem; border-radius: 7px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 4rem; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--brand); font-weight: 600; font-size: .8rem; padding: .3rem .5rem; border-radius: 6px; }
.auth-err { background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; margin-bottom: 1rem; }
.auth-err:empty { display: none; }
.btn-block { width: 100%; justify-content: center; }
.auth-foot { margin-top: 1.5rem; font-size: .8rem; color: var(--muted); text-align: center; }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ---------- Dashboard ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: 1 1 auto; }
.tab { border: 0; background: none; padding: .65rem .8rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: .45rem; align-items: center; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--ink); background: var(--hover); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: .72rem; background: var(--bg-2); color: var(--muted); border-radius: 999px; padding: .05rem .45rem; min-width: 1.4rem; text-align: center; }
.tab[aria-selected="true"] .count { background: var(--brand-soft); color: var(--brand); }
.search { position: relative; width: min(320px, 100%); }
.search .ico { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 2.2rem; }
.env-list { overflow: hidden; }
.env-head, .env-row { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 2fr) 170px 130px 44px; gap: 16px; align-items: center; padding: 14px 18px; }
.env-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; background: var(--bg-2); }
.env-row { border-bottom: 1px solid var(--line); cursor: pointer; position: relative; transition: background .12s; }
.env-row:last-child { border-bottom: 0; }
.env-row:hover { background: var(--hover); }
.env-row:focus-within { background: var(--hover); }
.env-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.env-title .fileico { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.env-title a { color: var(--ink); font-weight: 650; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-title a::after { content: ""; position: absolute; inset: 0; } /* whole row clickable */
.env-title a:focus-visible { outline: none; }
.env-row:has(.env-title a:focus-visible) { box-shadow: inset 0 0 0 2px var(--brand); }
.env-title small { color: var(--muted); font-size: .8rem; display: block; }
.env-rcpts { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.env-date { font-size: .875rem; }
.env-date small { display: block; color: var(--muted); font-size: .75rem; }
.env-actions { position: relative; z-index: 2; display: flex; justify-content: flex-end; }
.empty { text-align: center; padding: 64px 24px; }
.empty-art { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty h2 { font-size: 1.25rem; margin-bottom: .4rem; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 1.25rem; }
.skeleton-row { height: 66px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--hover), transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.dropzone { position: fixed; inset: 0; z-index: 120; background: color-mix(in srgb, var(--brand) 14%, rgba(15,23,42,.35)); display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .12s; }
.dropzone.on { opacity: 1; }
.dropzone-inner { border: 2px dashed #fff; border-radius: 20px; padding: 48px 64px; color: #fff; text-align: center; background: rgba(67,56,202,.55); }
.dropzone-inner h2 { font-size: 1.4rem; margin-top: 10px; }
.drop-hint { margin-top: 14px; text-align: center; font-size: .85rem; color: var(--muted); }
@media (max-width: 900px) {
  .env-head { display: none; }
  .env-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title actions" "rcpts rcpts" "status date"; gap: 10px; }
  .env-row > .env-title { grid-area: title; }
  .env-row > .env-rcpts { grid-area: rcpts; }
  .env-row > .env-status { grid-area: status; }
  .env-row > .env-date { grid-area: date; text-align: right; }
  .env-row > .env-actions { grid-area: actions; }
  .search { width: 100%; }
  .container { padding-top: 20px; }
}
@media (max-width: 560px) { .avatar-name { display: none; } .page-head h1 { font-size: 1.35rem; } }

/* ---------- Editor shell ---------- */
.editor-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-bar { position: relative; flex: none; height: var(--appbar-h); display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); z-index: 30; }
.editor-bar .back { color: var(--muted); }
.doc-title { min-width: 0; display: flex; flex-direction: column; }
.doc-title strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.save-state { font-size: .75rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.save-state.saving::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; }
.save-state.saved::before { content: "✓"; color: var(--ok); font-weight: 700; }
.save-state.error { color: var(--danger); }
.stepper { display: flex; align-items: center; gap: 6px; margin: 0 auto; list-style: none; padding: 0; }
.stepper li { display: flex; align-items: center; gap: 6px; }
.stepper li + li::before { content: ""; width: 28px; height: 2px; background: var(--line); border-radius: 2px; }
.stepper li.done + li::before, .stepper li.done::before { background: var(--brand); }
.step-btn { display: inline-flex; align-items: center; gap: .5rem; border: 0; background: none; padding: .4rem .6rem; border-radius: 8px; font-weight: 600; color: var(--muted); }
.step-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.step-btn:disabled { cursor: not-allowed; opacity: .6; }
.step-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; border: 2px solid var(--line); background: var(--surface); }
.stepper li.current .step-btn { color: var(--ink); }
.stepper li.current .step-num { border-color: var(--brand); color: var(--brand); }
.stepper li.done .step-num { background: var(--brand); border-color: var(--brand); color: #fff; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.editor-main { flex: 1; min-height: 0; display: flex; }
.step-pane { flex: 1; min-height: 0; overflow: auto; }
.step-pane[hidden] { display: none; }
@media (max-width: 980px) { .step-label { display: none; } .doc-title strong { max-width: 160px; } }

/* Step 1: recipients */
.narrow { max-width: 760px; margin: 0 auto; padding: 32px 20px 80px; }
.section { padding: 22px; margin-bottom: 18px; }
.section h2 { font-size: 1.05rem; margin-bottom: .2rem; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.switch { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .9rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }
.rlist { display: grid; gap: 10px; list-style: none; padding: 0; margin: 0 0 12px; }
.rrow { display: grid; grid-template-columns: 26px 30px minmax(0, 1fr) minmax(0, 1.2fr) 158px 36px; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-left: 4px solid var(--rc, var(--line)); border-radius: 10px; background: var(--surface); transition: box-shadow .15s, opacity .15s; }
.rrow.dragging { opacity: .5; }
.rrow.drop-before { box-shadow: 0 -3px 0 var(--brand); }
.rrow.drop-after { box-shadow: 0 3px 0 var(--brand); }
.rrow .grip { cursor: grab; color: var(--muted); border: 0; background: none; padding: 4px 0; border-radius: 6px; display: grid; place-items: center; }
.rrow .grip:active { cursor: grabbing; }
.rrow .order { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; color: #fff; background: var(--rc, var(--muted)); }
.rrow .input { padding: .5rem .65rem; }
.rrow .input.invalid { border-color: var(--danger); }
.rrow .del { color: var(--muted); }
.rrow .del:hover { color: var(--danger); }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.me-btn { font-size: .85rem; }
@media (max-width: 680px) {
  .rrow { grid-template-columns: 26px 30px 1fr 36px; }
  .rrow .r-email { grid-column: 3 / 4; }
  .rrow .r-role { grid-column: 3 / 4; }
}

/* Step 2: fields */
.fields-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 252px minmax(0, 1fr) 272px; }
.side { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 16px 14px; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.side h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 4px 10px; }
.side section + section { margin-top: 22px; }
.rsel { display: grid; gap: 4px; }
.rsel-btn { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; border: 1px solid transparent; background: none; text-align: left; width: 100%; }
.rsel-btn:hover { background: var(--hover); }
.rsel-btn[aria-checked="true"] { border-color: var(--rc); background: color-mix(in srgb, var(--rc) 9%, transparent); }
.rsel-btn .sw { width: 12px; height: 12px; border-radius: 4px; background: var(--rc); flex: none; }
.rsel-btn .nm { font-weight: 600; font-size: .88rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsel-btn .em { font-size: .75rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsel-btn .meta { min-width: 0; flex: 1; }
.rsel-btn .cnt { font-size: .72rem; color: var(--muted); background: var(--bg-2); border-radius: 999px; padding: .05rem .45rem; }
.palette { display: grid; gap: 6px; }
.pal-item { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .9rem; text-align: left; cursor: grab; user-select: none; touch-action: none; transition: border-color .12s, box-shadow .12s, transform .12s; }
.pal-item:hover { border-color: var(--rc, var(--brand)); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pal-item .pi { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: color-mix(in srgb, var(--rc, var(--brand)) 13%, transparent); color: var(--rc, var(--brand)); }
.pal-item.armed { border-color: var(--rc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 25%, transparent); }
.side-tip { font-size: .8rem; color: var(--muted); margin: 12px 4px 0; line-height: 1.45; }
.viewer-wrap { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--canvas-bg); }
.viewer { flex: 1; overflow: auto; padding: 24px 24px 80px; position: relative; }
.viewer.placing { cursor: crosshair; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 6px 20px rgba(0,0,0,.08); border-radius: 2px; flex: none; }
.pdf-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 2px; }
.pdf-ph { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, transparent 0 22px, rgba(0,0,0,.035) 22px 30px); background-clip: content-box; padding: 8% 10%; }
.pdf-layer { position: absolute; inset: 0; }
.page-num { position: absolute; left: 100%; top: 0; margin-left: 8px; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.zoombar { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; }
.zoombar .btn { padding: .35rem; border: 0; }
.zoombar .zl { min-width: 52px; text-align: center; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.zoombar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.zoombar .pg { font-size: .8rem; color: var(--muted); padding: 0 8px; font-variant-numeric: tabular-nums; }

/* Fields on the page */
.fld { position: absolute; border: 1.5px solid var(--rc); background: color-mix(in srgb, var(--rc) 14%, rgba(255,255,255,.55)); border-radius: 4px; color: color-mix(in srgb, var(--rc) 80%, #000); display: flex; align-items: center; gap: 4px; padding: 0 6px; font: 600 12px/1.1 var(--font); cursor: move; user-select: none; touch-action: none; overflow: hidden; container-type: size; }
.fld:hover { background: color-mix(in srgb, var(--rc) 22%, rgba(255,255,255,.55)); }
.fld:focus-visible { outline: none; }
.fld.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--rc); z-index: 3; overflow: visible; }
.fld .fl-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; pointer-events: none; }
.fld .fl-req { color: var(--danger); pointer-events: none; }
.fld .ico { pointer-events: none; opacity: .85; }
.fld.t-checkbox { justify-content: center; padding: 0; }
.fld.t-checkbox .fl-txt, .fld.t-checkbox .fl-req { display: none; }
.fld.ro { cursor: default; }
@container (max-height: 15px) { .fld .ico { display: none; } }
@container (max-width: 70px) { .fld .fl-txt { display: none; } }
.fld .rz { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: #fff; border: 2px solid var(--rc); cursor: nwse-resize; display: none; }
.fld.sel .rz { display: block; }
.fld-tools { position: absolute; z-index: 10; display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); transform: translateY(-100%); margin-top: -8px; }
.fld-tools .btn { padding: .3rem; border: 0; }
.ghost { position: fixed; z-index: 100; pointer-events: none; opacity: .9; box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.empty-props { text-align: center; padding: 26px 8px; color: var(--muted); font-size: .88rem; }
.empty-props .ico { margin: 0 auto 10px; color: var(--line); }
.props .form-row { margin-bottom: .9rem; }
.props .ptype { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; font-weight: 700; }
.props .ptype .pi { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--rc) 14%, transparent); color: var(--rc); }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 600; font-size: .9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.prop-actions { display: flex; gap: 6px; margin-top: 6px; }
.prop-actions .btn { flex: 1; justify-content: center; }
.shortcuts { margin-top: 22px; font-size: .78rem; color: var(--muted); display: grid; gap: 6px; }
.shortcuts div { display: flex; justify-content: space-between; gap: 8px; }
.summary-list { display: grid; gap: 6px; font-size: .85rem; }
.summary-list div { display: flex; align-items: center; gap: .5rem; }
.summary-list .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--rc); }
.summary-list .n { margin-left: auto; color: var(--muted); }
.no-rcpt { padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--ink); font-size: .85rem; }
@media (max-width: 1180px) { .fields-layout { grid-template-columns: 220px minmax(0, 1fr) 240px; } }
@media (max-width: 920px) {
  .fields-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  .side { border: 0; border-bottom: 1px solid var(--line); max-height: 34vh; }
  .side.right { border-top: 1px solid var(--line); max-height: 30vh; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* Step 3: review */
.review-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.warn-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.warn { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border-radius: 10px; font-size: .9rem; }
.warn.block { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.warn.block .ico { color: var(--danger); }
.warn.soft { background: color-mix(in srgb, var(--warn) 10%, transparent); }
.warn.soft .ico { color: var(--warn); }
.warn.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.warn.ok .ico { color: var(--ok); }
.warn button.linkish { margin-left: auto; white-space: nowrap; }
.linkish { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.rv-rcpt { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rv-rcpt:last-child { border-bottom: 0; }
.rv-rcpt .avatar { background: var(--rc); }
.rv-rcpt .who { flex: 1; min-width: 0; }
.rv-rcpt .who strong, .rv-rcpt .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-rcpt .who span { color: var(--muted); font-size: .85rem; }
.pill { font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 6px; background: var(--bg-2); color: var(--muted); white-space: nowrap; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.msg-preview { white-space: pre-wrap; background: var(--bg-2); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.send-card { position: sticky; top: 20px; }
@media (max-width: 860px) { .review-grid { grid-template-columns: 1fr; } }

/* ---------- Envelope status page ---------- */
.env-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
.env-hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 22px; }
.env-hero h1 { font-size: 1.55rem; overflow-wrap: anywhere; }
.env-hero .meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: .9rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.backlink { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .875rem; margin-bottom: 12px; }
.backlink:hover { color: var(--brand); }
.progress { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin: 6px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: inherit; transition: width .4s; }
.rcard { padding: 16px 0; border-bottom: 1px solid var(--line); }
.rcard:last-child { border-bottom: 0; padding-bottom: 4px; }
.rcard-top { display: flex; gap: 12px; align-items: center; }
.rcard-top .avatar { background: var(--rc); }
.rcard-top .who { flex: 1; min-width: 0; }
.rcard-top .who strong, .rcard-top .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcard-top .who span { color: var(--muted); font-size: .85rem; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 0 44px; }
.steps .st { font-size: .78rem; color: var(--muted); border-top: 3px solid var(--line); padding-top: 6px; }
.steps .st strong { display: block; font-size: .8rem; color: var(--muted); }
.steps .st.on { border-top-color: var(--c-signed); }
.steps .st.on strong { color: var(--ink); }
.steps .st.bad { border-top-color: var(--c-declined); }
.steps .st.bad strong { color: var(--c-declined); }
.rnote { margin: 8px 0 0 44px; font-size: .85rem; color: var(--c-declined); }
.log { list-style: none; margin: 0; padding: 0; position: relative; }
.log li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 0 0 16px; position: relative; }
.log li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.log li:last-child::before { display: none; }
.log .lic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); color: var(--muted); }
.log .lic.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.log .lic.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.log .lic.br { background: var(--brand-soft); color: var(--brand); }
.log .ltxt { font-size: .9rem; padding-top: 3px; }
.log .ltxt time { display: block; color: var(--muted); font-size: .78rem; }
.preview { padding: 0; overflow: hidden; }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.preview-head h2 { font-size: 1rem; }
.preview .viewer { height: min(78vh, 1000px); padding: 18px 18px 40px; background: var(--canvas-bg); }
.env-layout .section { margin-bottom: 18px; }
.callout { display: flex; gap: .7rem; padding: .8rem 1rem; border-radius: 10px; margin-bottom: 18px; font-size: .92rem; align-items: flex-start; }
.callout.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.callout.ok .ico { color: var(--ok); }
.callout.bad { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.callout.bad .ico { color: var(--danger); }
.callout.info { background: var(--brand-soft); }
.callout.info .ico { color: var(--brand); }
.hash { font: .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 960px) { .env-layout { grid-template-columns: 1fr; } }

.loading-full { display: grid; place-items: center; min-height: 50vh; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; } }
