/*
 * sign layout, skinned with the 2222 theme pack (/theme/theme.css, copied from
 * apps/2222/app/static/theme). Burnt-orange grain, cream ink, Crimson Pro.
 * The page frame, buttons, fields, lists, the action bar and dialogs are send's (apps/send), so the
 * apps read as siblings. Below that: the document view, the sheets and the signature pad.
 */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-size: 16px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, textarea { font: inherit; }
textarea { resize: vertical; line-height: 1.35; }
button, a { -webkit-tap-highlight-color: transparent; }
html { touch-action: manipulation; }
.hidden { display: none !important; }

header, main { width: min(var(--suite-content-width), calc(100% - 2 * var(--suite-page-gutter))); margin: 0 auto; }
header { height: 60px; display: flex; align-items: center; border-bottom: 1px solid var(--veil-2); }
.wordmark { color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 600; letter-spacing: -.3px; font-style: italic; }
main { min-height: 60vh; padding-top: var(--suite-page-top); padding-bottom: 40px; }
/* Every screen's heading and its words are centred; lists, forms and the privacy page aren't. */
main > h1, main > .muted, main > .eyebrow, main > .checked, main > .error, main > .fine, .share-head { text-align: center; }
main > .muted { max-width: 30em; margin-left: auto; margin-right: auto; }
/* Screens that are just a few words (the first screen, waiting, can't connect, ended) sit in the
   middle of what's left between the header and the bar. */
main.center { display: flex; flex-direction: column; justify-content: center; min-height: calc(100dvh - 60px - env(safe-area-inset-top)); }
main.center > * { flex: none; }

h1 { font-size: 32px; line-height: 1.15; font-weight: 400; letter-spacing: -.5px; margin: 0 0 6px; overflow-wrap: anywhere; }
h2 { font-size: 22px; line-height: 1.3; font-weight: 500; letter-spacing: -.3px; margin: 0 0 8px; }
p { margin: 0 0 12px; }

/* ---------- buttons ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; background: var(--cream); color: var(--ground-1);
  padding: 11px 16px; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.2;
}
button:hover, .button:hover { background: var(--cream-bright); }
button:disabled { opacity: .45; cursor: default; }
.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--veil-3); font-weight: 400; }
.quiet:hover { background: var(--veil-2); }
.linkbtn { background: transparent; box-shadow: none; color: var(--muted); font-size: 16px; font-weight: 300; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--veil-3); }
.linkbtn:hover { background: transparent; color: var(--ink); }
.linkbtn:disabled { opacity: .4; text-decoration: none; }
.close { background: transparent !important; box-shadow: none !important; color: var(--muted); font-size: 28px; line-height: 1; padding: 0 4px; font-weight: 300; }
button.block { margin-top: 18px; width: 100%; min-height: 56px; padding: 14px 16px; font-size: 20px; }

/* ---------- text ---------- */
.muted { color: var(--muted); font-size: 18px; line-height: 1.4; }
.fine { color: var(--ink-3); font-size: 14px; font-style: italic; margin: 0; }
.error { color: var(--danger); font-size: 16px; margin: 10px 0 0; }
.error:empty { display: none; }
.eyebrow { font-size: 16px; font-style: italic; color: var(--accent); margin: 0 0 6px; }
.keep { margin: 14px 0 0; font-size: 17px; font-style: italic; color: var(--ink-2); text-align: center; }
.drop-hint { margin-top: 18px; }
@media (hover: none), (pointer: coarse) { .drop-hint { display: none; } }

/* ---------- fields ---------- */
input, textarea {
  width: 100%; padding: 14px 15px; font-size: 19px; /* ≥16px stops iOS zooming on focus */
  background: var(--veil-2); border: 1px solid var(--veil-3); border-radius: var(--r-sm); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:focus, textarea:focus { outline: none; border-color: var(--veil-4); }
.profile { display: grid; gap: 6px; margin-top: 14px; }
.profile .error { text-align: center; }
dialog .profile { margin-top: 6px; }
dialog .profile .linkbtn { justify-self: center; margin-top: 4px; }

/* ---------- the link: QR code and address ---------- */
.share-head { margin-bottom: 2px; }
.share-head .muted { margin: 0; }
.qr-box { text-align: center; margin: 16px 0 4px; }
.qr { display: flex; justify-content: center; align-items: center; padding: 6px 0 2px; min-height: 200px; }
.qr svg { width: min(280px, 72vw); height: auto; background: #fff; border-radius: 12px; padding: 10px; box-shadow: 0 2px 12px #0006; }
.making { font-style: italic; }
.scan-note { margin: 12px 0 2px; font-size: 19px; font-style: italic; color: var(--ink); }
.link-line { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin: 0; font-size: 16px; color: var(--ink-2); }
.link-text { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.notice { margin: 16px 0 6px; padding: var(--suite-panel-padding); border-radius: var(--suite-radius); background: var(--accent-soft); display: grid; gap: var(--suite-item-gap); }
.notice p { margin: 0; color: var(--cream); font-size: 18px; }
.notice .quiet { min-height: 50px; font-size: 17px; box-shadow: inset 0 0 0 1px var(--veil-4); }
.host-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 10px 0 6px; }

/* ---------- lists ---------- */
.list-label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--suite-item-gap); padding: var(--suite-section-gap) 0 var(--suite-section-heading-gap); margin: 0; font-size: 15px; line-height: 1.4; font-weight: 400; font-style: italic; color: var(--ink-2); }
.list-label b { font: inherit; color: inherit; }
.list { border-top: 1px solid var(--veil-2); }
.empty { color: var(--ink-3); font-style: italic; font-size: 16px; padding: 14px 2px; margin: 0; border-bottom: 1px solid var(--veil-2); }
.card {
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 14px; row-gap: 6px;
  padding: var(--suite-panel-padding) 0; border-bottom: 1px solid var(--veil-2); color: inherit; text-decoration: none;
}
button.card { width: 100%; text-align: left; background: transparent; border-radius: 0; font-weight: 400; justify-content: stretch; color: var(--ink); }
button.card:hover { background: var(--veil-1); }
button.card:active { background: var(--veil-2); }
.x { background: transparent; color: var(--ink-3); font-size: 24px; font-weight: 300; padding: 0 6px; min-height: 36px; }
.x:hover { background: transparent; color: var(--ink); }

/* A file: its name and size (a button that saves it, once it's here), then its SHA-256. */
.card.file { display: block; padding: var(--suite-panel-padding) 0; }
.file-main { display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: 14px; width: 100%; font-size: 17px; }
.file.with-thumb .file-main { grid-template-columns: auto 1fr auto; }
button.file-main { background: transparent; color: var(--ink); padding: 0; border-radius: 0; text-align: left; font-weight: 400; justify-content: stretch; }
button.file-main:hover { background: transparent; }
button.file-main:active { opacity: .7; }
.file .fname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fsize { color: var(--ink-3); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.file.done .fsize { color: var(--positive); }
.file.now .fname { color: var(--accent); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--veil-2); }
.thumb.tile { display: grid; place-items: center; color: var(--ink-3); }
.thumb.tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hash { margin: 6px 0 0; font-size: 14px; font-style: italic; color: var(--ink-3); line-height: 1.4; }
.hash code { font-family: var(--font-mono); font-style: normal; font-size: 12px; color: var(--ink-2); word-break: break-all; -webkit-user-select: all; user-select: all; }
.hash .ok { color: var(--positive); white-space: nowrap; }
.hash .bad { color: var(--danger); }
.checked { color: var(--positive); font-style: italic; font-size: 17px; margin: 0 0 12px; }

.person { grid-template-columns: auto 1fr; font-size: 18px; }
.person .who { color: var(--ink); }
.person .status { justify-self: end; color: var(--ink-2); font-style: italic; font-size: 16px; text-align: right; }
.person.done .status { color: var(--positive); }
.person.sending .status { color: var(--accent); }
.person.failed .status, .person.error .status, .person.wrong .status { color: var(--danger); }
.person.left .who, .person.left .status { color: var(--ink-4); }
.person .meter { grid-column: 1 / -1; }

/* Progress: a filled bar, scaled from JavaScript (the CSP allows no inline styles). */
.meter { height: 4px; border-radius: 2px; background: var(--veil-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .2s linear; }
.meter.big { height: 10px; border-radius: 5px; margin: 18px 0 10px; }
.got { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; margin: 0; text-align: center; }
.eta { font-size: 17px; font-style: italic; color: var(--accent); font-variant-numeric: tabular-nums; margin: 4px 0 0; min-height: 1.4em; text-align: center; }
.btn-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- pinned action bar ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--grain), linear-gradient(180deg, var(--ground-2), var(--ground-1));
  border-top: 1px solid var(--veil-3); box-shadow: 0 -10px 30px #0006;
  animation: barIn .25s ease-out;
}
.bar-inner { width: min(var(--suite-content-width), 100%); margin: 0 auto; display: flex; gap: 8px; }
.actionbar .primary { flex: 1; background: var(--accent); color: var(--ground-0); border-radius: var(--r-pill); font-size: 19px; min-height: 56px; padding: 14px 16px; }
.actionbar .primary:hover { background: var(--accent); filter: brightness(1.07); }
.actionbar .primary:disabled { filter: none; }
.actionbar .quiet { border-radius: var(--r-pill); min-height: 56px; padding: 14px 18px; font-size: 17px; white-space: nowrap; color: var(--ink); }
.actionbar .quiet.wide { flex: 1; font-size: 18px; }
.bar-note { width: min(var(--suite-content-width), 100%); margin: 0 auto 10px; text-align: center; font-size: 16px; font-style: italic; color: var(--cream); }
.bar-note:empty, .actionbar .fine:empty { display: none; }
.actionbar .fine { width: min(var(--suite-content-width), 100%); margin: 8px auto 0; text-align: center; }
.actionbar .fine a { color: var(--ink-2); }
body.with-bar main { padding-bottom: 170px; }
@keyframes barIn { from { transform: translateY(100%); } }

/* ---------- dialogs (raised grain surfaces) ---------- */
dialog {
  color: var(--ink); width: min(440px, calc(100% - 24px)); max-height: 90dvh; overflow: auto; padding: 22px;
  background: var(--ground-2); background-image: var(--grain), linear-gradient(180deg, var(--ground-3), var(--ground-2));
  border: 1px solid var(--veil-3); border-radius: var(--r-lg); box-shadow: 0 24px 80px #0007;
}
dialog::backdrop { background: #000a; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; }

/* ---------- dropping files on a computer ---------- */
.dropzone {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; pointer-events: none;
  background: #000b; border: 3px dashed var(--accent); border-radius: var(--r-lg); margin: 12px;
}
.dropzone p { font-size: 30px; font-style: italic; color: var(--cream); margin: 0; }

/* ---------- header: the document's name while it's open ---------- */
header { gap: 14px; }
.doc-name { flex: 1; min-width: 0; text-align: right; color: var(--ink-3); font-style: italic; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.editing header { width: auto; padding: 0 16px; }

/* ---------- the first screen: the common forms, and your signature if it's kept here ---------- */
.forms-link { text-align: center; margin: 6px 0 0; }
.forms-link .linkbtn { font-size: 17px; }
.form-row b { font-variant-numeric: tabular-nums; }
.sheet-fine { margin-top: 12px; text-align: center; }
.mine { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; margin: 18px 0 0; border-top: 1px solid var(--veil-2); }
.mine-sig { display: block; width: 110px; height: 40px; background: #fff; border-radius: 8px; padding: 4px 8px; }
.mine-sig .ink { width: 100%; height: 100%; fill: #1a2b6d; }
.mine-name { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- the signature pad ---------- */
.pad { position: relative; margin-top: 12px; background: #fff; border-radius: var(--r-md); aspect-ratio: 3 / 1; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 2px 14px #0006; }
.pad.small { aspect-ratio: 3 / 2; max-width: 300px; margin-left: auto; margin-right: auto; }
.pad::after { content: ''; position: absolute; left: 7%; right: 7%; bottom: 24%; border-bottom: 1.5px solid #cfc8bd; pointer-events: none; }
.pad::before { content: '×'; position: absolute; left: 3.5%; bottom: calc(24% - 4px); color: #b5aca0; font: 300 24px/1 Helvetica, Arial, sans-serif; pointer-events: none; }
.pad-svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #1a2b6d; touch-action: none; cursor: crosshair; }
.pad-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 8px 0 0; }
.pad-tools .fine { flex: 1; }

/* ---------- the document ---------- */
body.editing main { display: none; }
.doc-view {
  position: fixed; left: 0; right: 0; top: calc(60px + env(safe-area-inset-top)); bottom: var(--bar-h, 0px);
  overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; background: #0004;
}
.pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 10px 28px; width: max-content; min-width: 100%; transform-origin: 0 0; }
.page { position: relative; flex: none; background: #fff; box-shadow: 0 2px 14px #0008; }
.page canvas, .page .marks { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .marks { overflow: visible; pointer-events: none; }
.marks text { font-family: Helvetica, Arial, sans-serif; white-space: pre; }
/* Form fields: a light blue box where a tap fills something in, as in Adobe's and Apple's PDF apps. */
.marks .fld { fill: rgb(56 108 255 / .12); stroke: rgb(56 108 255 / .6); stroke-width: .8px; vector-effect: non-scaling-stroke; }
.marks .fld.filled { fill: rgb(56 108 255 / .05); stroke: rgb(56 108 255 / .3); }
.marks .val { fill: #111; }
.marks .val-mark { stroke: #111; }
.marks .val-dot { fill: #111; }
/* Places marked for someone else. */
.marks .spot rect { fill: hsl(28 100% 60% / .2); stroke: hsl(24 100% 48%); stroke-width: 1.5px; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.marks .spot text { fill: hsl(20 100% 32%); font-weight: 700; }
.marks .spot.flash rect { animation: flash .45s ease-in-out 3 alternate; }
@keyframes flash { to { fill: hsl(28 100% 55% / .6); } }
.marks .locked { opacity: .92; }

/* The thing that's selected: drag it to move it, the round corner to resize it. */
.sel { position: absolute; z-index: 2; border: 1.5px dashed var(--accent); border-radius: 3px; touch-action: none; cursor: move; margin: -1.5px 0 0 -1.5px; box-sizing: content-box; }
.sel-grip { position: absolute; right: -16px; bottom: -16px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 5px #0007; cursor: nwse-resize; touch-action: none; }
.sel-tools { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--ground-1); box-shadow: 0 4px 18px #0009; white-space: nowrap; }
.sel.tools-below .sel-tools { bottom: auto; top: calc(100% + 22px); }
.sel-tools button { padding: 8px 14px; font-size: 16px; border-radius: var(--r-pill); background: transparent; color: var(--ink); font-weight: 400; }
.sel-tools button:hover { background: var(--veil-2); }

/* ---------- sheets: rise from the bottom on phones ---------- */
dialog.sheet { margin: auto auto 0; width: min(var(--suite-content-width), 100%); max-width: 100%; max-height: 88dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
dialog.sheet[open] { animation: sheetIn .22s ease-out; }
dialog.sheet:focus { outline: none; }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: var(--r-lg); border-bottom: 1px solid var(--veil-3); } }
.sheet .muted { font-size: 17px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions .primary { flex: 1; background: var(--accent); color: var(--ground-0); border-radius: var(--r-pill); font-size: 19px; min-height: 54px; }
.sheet-actions .primary:hover { background: var(--accent); filter: brightness(1.07); }
.sheet-actions .quiet { border-radius: var(--r-pill); min-height: 54px; padding: 12px 18px; }
.pad-sheet .pad { margin-top: 4px; }
.pad-sheet input { margin-bottom: 4px; }

.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.opt { flex-direction: column; gap: 4px; min-height: 84px; padding: 10px 8px; border-radius: var(--r-md); background: var(--veil-2); color: var(--ink); font-weight: 400; font-size: 18px; }
.opt:hover { background: var(--veil-3); }
.opt .ink { width: 100%; max-width: 120px; height: 34px; fill: var(--cream); }
.opt small { max-width: 100%; color: var(--ink-3); font-size: 14px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .tick { font: 700 24px/1 Helvetica, Arial, sans-serif; color: var(--cream); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 7px 12px; border-radius: var(--r-pill); background: var(--veil-2); color: var(--ink); font-weight: 400; font-size: 16px; }
.chip:hover { background: var(--veil-3); }

.menu { display: grid; margin-top: 8px; border-top: 1px solid var(--veil-2); }
.menu .card { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 14px 4px; font-size: 18px; }
.menu .card b { font-weight: 500; }
.menu .card span { color: var(--ink-3); font-size: 15px; font-style: italic; }
.menu .card.chosen { color: var(--accent); }

/* ---------- zoom buttons, for computers ---------- */
.zoom { position: fixed; right: 16px; bottom: calc(var(--bar-h, 0px) + 14px); z-index: 5; display: flex; gap: 6px; }
.zoom button { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--ground-1); color: var(--ink); font-size: 24px; font-weight: 300; box-shadow: 0 2px 10px #0008; }
@media (pointer: coarse) { .zoom { display: none; } }

/* ---------- live signing ---------- */
.knock { grid-template-columns: 1fr auto; }
.knock .who { font-size: 18px; }
.knock .who small { display: block; color: var(--ink-3); font-size: 15px; font-style: italic; }
.knock .acts { display: flex; gap: 6px; }
.knock .acts button { padding: 9px 14px; border-radius: var(--r-pill); font-size: 16px; }
.knock .acts .let { background: var(--accent); color: var(--ground-0); }

/* ---------- privacy ---------- */
.policy h2 { margin-top: 28px; }
.policy p { font-size: 17px; color: var(--ink-2); }
.policy .back { margin-top: 28px; }

@media (max-width: 400px) {
  h1 { font-size: 28px; }
  .actionbar .quiet { padding: 13px 14px; }
}
@media (prefers-reduced-motion: reduce) { .actionbar, dialog.sheet[open] { animation: none; } .meter i { transition: none; } .marks .spot.flash rect { animation: none; } }

/* Comfortable targets and readable supporting copy throughout the work tools. */
.close { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.policy p { line-height: 1.6; }
.actionbar .fine { font-size: 14px; }
.actionbar .fine a { display: inline-block; padding-block: 4px; }
