/* Wippli look: IBM Plex Sans, brand purple #502E91, action magenta #CB007B, white cards with 20px corners, pills. */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');
:root { --purple: #502E91; --magenta: #CB007B; --magenta-dark: #A80066; --ink: #222; --mid: #666; --rule: #e6e1ef; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #f5f5f5; color: var(--ink); font-family: 'IBM Plex Sans', -apple-system, Segoe UI, sans-serif; }
body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.card { background: #fff; border-radius: 20px; padding: 36px 32px 24px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 8px 24px rgba(20, 8, 50, .10); }
.card.wide { max-width: 720px; text-align: left; }
.logo { display: block; margin: 0 auto 18px; height: 28px; width: auto; }
.card.wide .logo { margin-left: 0; }
h1 { color: var(--purple); font-size: 22px; margin: 0 0 6px; font-weight: 600; }
h2 { color: var(--purple); font-size: 18px; margin: 0 0 6px; font-weight: 600; }
.muted { color: var(--mid); margin: 0 0 20px; font-size: 14px; }
.small { font-size: 12px; }
.pin { display: flex; gap: 8px; justify-content: center; margin: 0 0 20px; }
.pin input { width: 44px; height: 54px; text-align: center; font-size: 22px; font-weight: 600; color: var(--purple); border: 2px solid var(--rule); border-radius: 12px; outline: none; }
.pin input:focus { border-color: var(--magenta); }
button { background: var(--magenta); color: #fff; border: 0; border-radius: 40px; padding: 13px 28px; font: inherit; font-weight: 700; cursor: pointer; width: 100%; }
button:hover { background: var(--magenta-dark); }
button:disabled { background: #cfcfcf; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--purple); border: 2px solid var(--purple); }
.error { color: #c62828; font-size: 14px; margin: 12px 0 0; }
.attribution { color: var(--mid); font-size: 12px; margin: 22px 0 0; }
.attribution a { color: var(--magenta); text-decoration: none; font-weight: 600; }
.attribution a:hover { text-decoration: underline; }
/* signing page */
body.signing { justify-content: flex-start; padding: 0 0 260px; }
/* the bar: everything on one centred line; room on the right for the board's own Flip pill */
.bar { position: sticky; top: 0; z-index: 2; width: 100%; min-height: 44px; background: #fff; border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 16px; padding: 6px 96px 6px 16px; }
.bar .logo { height: 22px; width: auto; margin: 0; flex: 0 0 auto; }
.bar .title { font-weight: 600; color: var(--purple); flex: 1; text-align: center; overflow-wrap: anywhere; line-height: 1.2; }
/* who it is for wraps and never takes more than 40% of the bar, so a long list of parties cannot squeeze the title */
.bar .who { color: var(--mid); font-size: 13px; flex: 0 1 auto; max-width: 40%; text-align: right; }
/* narrow screens: logo, then the whole title, then who it is for, each on its own line and wrapping; the right room for the Flip pill stays */
@media (max-width: 760px) { .bar { flex-wrap: wrap; row-gap: 4px; padding-top: 10px; padding-bottom: 10px; } .bar .title, .bar .who { flex: 1 1 100%; text-align: left; } .bar .who { max-width: none; } }
.doc { width: 100%; max-width: 900px; padding: 16px; }
.page { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); margin: 0 0 16px; border-radius: 6px; }
.panel { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: calc(100% - 32px); max-width: 680px; background: #fff; border-radius: 20px; padding: 18px 20px; box-shadow: 0 8px 24px rgba(20, 8, 50, .18); text-align: left; }
.panel.notice { text-align: center; } .panel.notice .muted { margin-bottom: 0; } .panel.notice .links { margin-top: 10px; }
#pad { width: 100%; height: 160px; border: 2px dashed var(--rule); border-radius: 12px; touch-action: none; background: #fff; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.links { font-size: 14px; margin: 8px 0 0; } .links a { color: var(--magenta); font-weight: 600; text-decoration: none; } .links a:hover { text-decoration: underline; }
.row button { flex: 1; }
pre { background: #faf8fd; border-radius: 12px; padding: 14px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* verify form: the drop zone edge to edge, the Verify button under it, at every width */
form#f { display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; }
form#f .drop { width: 100%; margin: 0; }
form#f button { width: 100%; }
@media (min-width: 720px) { .card { padding: 44px 40px 28px; } }
/* pages with fields on them (prepare and sign) */
.pagewrap { position: relative; margin: 0 0 16px; }
.pagewrap .page { margin: 0; }
.field { position: absolute; box-sizing: border-box; border: 2px solid var(--c, var(--purple)); background: color-mix(in srgb, var(--c, var(--purple)) 12%, transparent); border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 11px; color: var(--c, var(--purple)); user-select: none; touch-action: none; }
.field .tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; padding: 0 4px; }
.field .tag .material-symbols-outlined { font-size: 16px; }
.field.filled { background: transparent; border-style: solid; }
.field.filled img { max-width: 96%; max-height: 92%; object-fit: contain; }
.field.filled .val { color: #1a1a1a; font-size: 12px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.field.filled .tick { color: #1a1a1a; font-size: 20px; }
.field.other { border-color: transparent; background: transparent; cursor: default; }
.field.optional { border-style: dashed; }
.field.auto { border-style: dotted; cursor: default; opacity: .85; }
.field.locked { pointer-events: none; }
.field.pulse { animation: pulse 0.8s ease-in-out 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c, var(--purple)) 35%, transparent); } }
.field.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--purple)) 40%, transparent); }
.field .grip { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; background: var(--c, var(--purple)); border-radius: 3px 0 3px 0; cursor: nwse-resize; }
.field.sel { overflow: visible; }
.field .tag { max-width: 100%; overflow: hidden; }
.field .del { position: absolute; top: -14px; right: -14px; z-index: 2; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: var(--c, var(--purple)); color: #fff; box-shadow: 0 0 0 2px #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.field .del .material-symbols-outlined { font-size: 14px; }
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20; vertical-align: middle; }
/* the sender's studio */
body.studio { justify-content: flex-start; align-items: stretch; padding: 0; }
.work { display: flex; width: 100%; min-height: calc(100vh - 44px); }
.palette { flex: 0 0 272px; background: #fff; border-right: 1px solid var(--rule); padding: 18px 18px 24px; position: sticky; top: 44px; align-self: flex-start; max-height: calc(100vh - 44px); overflow: auto; }
.palette h2 { font-size: 15px; margin: 14px 0 6px; }
.palette p.muted { margin-bottom: 12px; }
.chip { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: #fff; color: var(--ink); border: 2px solid var(--rule); border-radius: 40px; padding: 8px 12px; font-weight: 600; margin: 0 0 6px; }
.chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, #fff); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); display: inline-block; flex: 0 0 12px; }
.tools { display: grid; gap: 6px; margin: 12px 0; }
.tool { display: flex; align-items: center; gap: 10px; background: #fff; color: var(--purple); border: 2px solid var(--rule); border-radius: 12px; padding: 10px 12px; font-weight: 600; text-align: left; }
.tool.on { border-color: var(--magenta); background: #fdf2f8; color: var(--magenta); }
body.placing .pagewrap { cursor: crosshair; }
/* after Send: the document stays, read-only; the fields panel goes; the confirmation card sits in the centre over it */
body.sent .palette { display: none; }
body.sent .pagewrap, body.sent .field { pointer-events: none; cursor: default; }
body.sent .field .grip { display: none; }
body.sent #done .muted { text-wrap: balance; }
#done .done-logo { display: block; margin: 0 auto 14px; width: 132px; height: auto; }
body.sent::before { content: ''; position: fixed; inset: 0; z-index: 40; background: rgba(28, 24, 38, .55); }   /* a grey screen over the page, the card on top */
body.sent #done { z-index: 50; top: 50%; bottom: auto; transform: translate(-50%, -50%); max-width: 520px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 26px 28px; box-shadow: 0 18px 48px rgba(20, 8, 50, .28); outline: none; }
.selected label { display: block; font-size: 13px; margin: 6px 0; }
.selected select { font: inherit; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 8px; width: 100%; margin-top: 4px; }
.small-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; width: auto; font-size: 13px; margin-top: 6px; }
.sumrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mid); margin: 4px 0; }
.summary { margin: 12px 0 6px; }
.studio .doc { flex: 1; padding: 20px 24px 60px; max-width: none; }
.studio .pagewrap { max-width: 900px; margin: 0 auto 16px; }
.studio .error { margin: 10px 0 0; }
.studio .attribution { margin-top: 16px; }
/* signer panel, modal */
.progress { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; color: var(--purple); margin: 0 0 4px; flex-wrap: wrap; }
.progress .muted { margin: 0; }
.modal { position: fixed; inset: 0; background: rgba(20, 8, 50, .45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal[hidden], .panel[hidden], .work[hidden], .working[hidden] { display: none; }
.sheet { background: #fff; border-radius: 20px; padding: 20px; width: 100%; max-width: 680px; box-shadow: 0 12px 32px rgba(20, 8, 50, .25); }
.tabs { display: flex; gap: 8px; margin: 10px 0 12px; }
.tab { display: inline-flex; align-items: center; gap: 6px; width: auto; background: #fff; color: var(--purple); border: 2px solid var(--rule); border-radius: 40px; padding: 8px 16px; font-size: 14px; }
.tab.on { border-color: var(--magenta); color: var(--magenta); background: #fdf2f8; }
.tabpane input[type=text] { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 2px solid var(--rule); border-radius: 12px; }
.typed-preview { height: 120px; border: 2px dashed var(--rule); border-radius: 12px; margin-top: 10px; display: flex; align-items: center; justify-content: center; }
.typed-preview img { max-height: 110px; max-width: 100%; }
#uploadPreview { width: 100%; height: 160px; border: 2px dashed var(--rule); border-radius: 12px; margin-top: 10px; }
@media (max-width: 760px) { .work { flex-direction: column; } .palette { position: static; flex: none; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); } }

/* verify page */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 2px dashed var(--rule); border-radius: 16px; padding: 26px 16px; background: #faf8fd; cursor: pointer; text-align: center; color: var(--mid); margin: 0 0 14px; }
.drop.over, .drop:hover { border-color: var(--magenta); background: #fdf2f8; }
.drop.has-file { border-style: solid; border-color: var(--purple); color: var(--ink); }
.drop .material-symbols-outlined { font-size: 34px; color: var(--purple); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pill { display: inline-block; background: var(--magenta); color: #fff; font-weight: 700; border-radius: 40px; padding: 10px 22px; }
.result { margin: 18px 0 8px; text-align: left; }
.result h2.ok { color: #2f855a; } .result h2.bad { color: #c62828; }
.vrow { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.vrow .k { flex: 0 0 84px; color: var(--mid); font-weight: 600; } .vrow .v { flex: 1; overflow-wrap: anywhere; }

/* while the service is working: a spinner in the button and a line that says what is happening */
button.busy, button.busy:disabled { position: relative; color: transparent !important; pointer-events: none; background: var(--magenta); }
button.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 3px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { button.busy::after, .working::before { animation-duration: 2.4s; } }
.working { display: flex; align-items: center; gap: 10px; color: var(--purple); font-size: 13px; margin: 10px 0 0; }
.working::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--rule); border-top-color: var(--magenta); border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 14px; }
