/* SigneMoi — paper, ink, and almost nothing else. */

@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(/vendor/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url(/vendor/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(/vendor/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-display: swap; src: url(/vendor/fonts/cormorant-garamond-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(/vendor/fonts/cormorant-garamond-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: italic; font-display: swap; src: url(/vendor/fonts/cormorant-garamond-latin-500-italic.woff2) format('woff2'); }
/* Typed-signature faces, loaded on demand by the canvas. */
@font-face { font-family: 'Great Vibes'; font-display: swap; src: url(/vendor/fonts/great-vibes-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Caveat'; font-weight: 500; font-display: swap; src: url(/vendor/fonts/caveat-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Homemade Apple'; font-display: swap; src: url(/vendor/fonts/homemade-apple-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'La Belle Aurore'; font-display: swap; src: url(/vendor/fonts/la-belle-aurore-latin-400-normal.woff2) format('woff2'); }

:root {
  --paper: #f6f4ee;
  --surface: #fffefb;
  --ink: #14161a;
  --muted: #6c6f76;
  --faint: #a7a498;
  --line: #e4e0d4;
  --line-strong: #cdc7b6;
  --seal: #a8322a;
  --ink-blue: #1d2b5e;
  --ok: #2c6a4d;
  --warn: #99680f;
  --danger: #a8322a;
  --tint: rgba(20, 22, 26, 0.045);
  --shadow: 0 1px 2px rgba(20, 22, 26, 0.05), 0 10px 30px -12px rgba(20, 22, 26, 0.18);
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 14px;
  --gutter: max(20px, env(safe-area-inset-left));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #0e1013; --surface: #16191e; --ink: #ece8df; --muted: #9b9b96; --faint: #5f605f;
    --line: #262a31; --line-strong: #353a43; --seal: #e0675c; --ink-blue: #9fb0f0;
    --ok: #6cc29a; --warn: #e0b04f; --danger: #e0675c;
    --tint: rgba(236, 232, 223, 0.06);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--ink); color: var(--paper); }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

/* ── Layout ───────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 var(--gutter) calc(48px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 880px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) var(--gutter) 14px; max-width: 880px; margin: 0 auto;
}
.wordmark { font: 600 25px/1 var(--serif); letter-spacing: -0.01em; text-decoration: none; display: inline-flex; align-items: baseline; gap: 1px; }
.wordmark em { font-style: italic; font-weight: 500; }
.wordmark::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--seal); margin-left: 3px; transform: translateY(-1px); }
.topnote { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.topnote svg { flex: none; }
.stack > * + * { margin-top: 16px; }

/* ── Type ─────────────────────────────────────────────────────── */
.display { font: 500 clamp(40px, 9vw, 64px)/1.02 var(--serif); letter-spacing: -0.02em; margin: 28px 0 14px; }
.display em { font-style: italic; }
h2.title { font: 500 clamp(28px, 6vw, 36px)/1.1 var(--serif); letter-spacing: -0.015em; margin: 24px 0 8px; }
.lede { font-size: 17px; color: var(--muted); max-width: 46ch; margin: 0 0 28px; }
.eyebrow { font: 600 11px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 11.5px; word-break: break-all; letter-spacing: 0; }

/* ── Controls ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 24px;
  border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font-weight: 500; font-size: 15.5px; letter-spacing: 0.005em; cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.32; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover:not([disabled]) { border-color: var(--ink); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); min-height: 44px; padding: 0 12px; }
.btn.quiet:hover { color: var(--ink); }
.btn.danger { background: transparent; border-color: var(--line-strong); color: var(--danger); }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 8px 0; min-height: 44px; color: var(--muted); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; font-size: 14.5px; }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }

.input, .textarea {
  width: 100%; min-height: 50px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--tint); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px 2px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap-r { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 96px; gap: 12px; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 999px; background: var(--tint); gap: 2px; width: 100%; }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 14.5px; font-weight: 500; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.seg button[aria-pressed='true'], .seg button[aria-selected='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14.5px; color: var(--muted); }
.check input { appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border: 1.5px solid var(--line-strong); border-radius: 7px; background: var(--surface); display: grid; place-content: center; cursor: pointer; transition: all 0.12s ease; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ''; width: 11px; height: 6px; border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: translateY(-1px) rotate(-45deg); }
.check span { padding-top: 1px; }

/* ── Cards, lists ─────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink)); flex: none; }
.dot.hollow { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c, var(--faint)); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--tint); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.divider { height: 1px; background: var(--line); border: 0; margin: 24px 0; }

/* ── Stepper ──────────────────────────────────────────────────── */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 8px; }
.stepper i { height: 2px; border-radius: 2px; background: var(--line-strong); transition: background 0.3s ease; }
.stepper i.on { background: var(--ink); }
.stepname { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }

/* ── Drop zone ────────────────────────────────────────────────── */
.drop {
  display: grid; place-items: center; text-align: center; gap: 6px; padding: 44px 24px; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 20px; background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.drop:hover, .drop.over { border-color: var(--ink); }
.drop.over { background: var(--tint); transform: scale(1.005); }
.drop .glyph { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); margin-bottom: 6px; }
.drop strong { font: 500 24px/1.1 var(--serif); letter-spacing: -0.01em; }
.drop span { color: var(--muted); font-size: 14px; }

/* ── Document pages & fields ──────────────────────────────────── */
.doc { display: grid; gap: 14px; padding: 4px 0 8px; }
.pg { position: relative; background: #fff; border-radius: 4px; box-shadow: var(--shadow); width: 100%; overflow: hidden; touch-action: pan-y; }
.pg canvas { display: block; width: 100%; height: 100%; }
.pg .num { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: #8a8a8a; pointer-events: none; font-family: var(--mono); }
.pg.placing { cursor: crosshair; outline: 2px dashed color-mix(in srgb, var(--ink) 35%, transparent); outline-offset: -2px; }

.fld {
  position: absolute; border: 1.5px solid var(--c, var(--ink)); border-radius: 6px; background: color-mix(in srgb, var(--c, var(--ink)) 11%, transparent);
  display: grid; place-items: center; color: var(--c, var(--ink)); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; container-type: size;
}
.fld.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--ink)) 25%, transparent); z-index: 3; }
.fld .tag { pointer-events: none; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; max-width: 100%; padding: 0 4px; }
.fld .x, .fld .rs { position: absolute; width: 28px; height: 28px; display: none; place-items: center; }
.fld.sel .x, .fld.sel .rs { display: grid; }
.fld .x { top: -15px; right: -15px; border-radius: 50%; background: var(--ink); color: var(--paper); border: 2px solid var(--paper); cursor: pointer; padding: 0; }
.fld .rs { bottom: -14px; right: -14px; cursor: nwse-resize; touch-action: none; }
.fld .rs::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--ink)); border: 2px solid #fff; }
.fld.idle { border-style: dashed; opacity: 0.55; cursor: default; background: transparent; }

/* signer-side fields */
.fld.mine { cursor: pointer; border-style: solid; background: color-mix(in srgb, var(--seal) 8%, transparent); border-color: var(--seal); color: var(--seal); animation: breathe 2.4s ease-in-out infinite; }
.fld.mine.done { animation: none; border-color: transparent; background: transparent; }
.fld.mine.done:hover { background: var(--tint); border-color: var(--line-strong); }
.fld.mine img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.fld.mine.auto { cursor: default; animation: none; border-style: dashed; background: transparent; color: #222; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: clamp(8px, 55cqh, 14px); }
.fld.mine.focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--seal) 28%, transparent); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--seal) 30%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--seal) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── Dock (fixed bottom bar) ──────────────────────────────────── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.dock .in { max-width: 680px; margin: 0 auto; display: grid; gap: 10px; }
.has-dock { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip[aria-pressed='true'] { border-color: var(--c, var(--ink)); box-shadow: inset 0 0 0 1px var(--c, var(--ink)); }
.chip .tick { display: none; }
.chip.ok .tick { display: inline; color: var(--ok); }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool { display: grid; justify-items: center; gap: 4px; padding: 10px 4px 9px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 500; min-height: 58px; transition: all 0.12s ease; }
.tool svg { opacity: 0.85; }
.tool[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.hint { font-size: 13px; color: var(--muted); text-align: center; min-height: 18px; }

/* progress hairline */
.hairline { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30; background: transparent; }
.hairline i { display: block; height: 100%; width: 0; background: var(--seal); transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ── Sheet ────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(10, 11, 13, 0.46); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; overflow: auto; overscroll-behavior: contain; background: var(--paper);
  border-radius: 24px 24px 0 0; padding: 10px var(--gutter) calc(22px + env(safe-area-inset-bottom)); animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 14px; }
.sheet h3 { font: 500 28px/1.1 var(--serif); letter-spacing: -0.01em; margin: 0 0 4px; }
.sheet .sub { color: var(--muted); font-size: 14.5px; margin: 0 0 18px; }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 24px; padding-bottom: 24px; box-shadow: var(--shadow); } .sheet .grab { display: none; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Signature pad ────────────────────────────────────────────── */
.pad { position: relative; background: #fff; color: #555; border: 1px solid var(--line-strong); border-radius: 16px; overflow: hidden; touch-action: none; }
.pad canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
@media (orientation: landscape) and (max-height: 520px) { .pad canvas { height: 130px; } }
.pad .base { position: absolute; left: 22px; right: 22px; bottom: 54px; border-bottom: 1px dashed #cfcab9; pointer-events: none; }
.pad .x { position: absolute; left: 22px; bottom: 60px; font: 500 18px var(--serif); color: #a7a498; pointer-events: none; }
.pad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #a7a498; font-size: 14.5px; pointer-events: none; padding-bottom: 36px; transition: opacity 0.15s; }
.pad.has .ph { opacity: 0; }
.pad .tools-in { position: absolute; left: 10px; right: 10px; bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.swatches { display: flex; gap: 10px; align-items: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.sw[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ink); }
.typed { display: grid; gap: 8px; margin-top: 12px; }
.typed button { text-align: left; min-height: 66px; padding: 4px 18px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; cursor: pointer; font-size: 38px; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--c); }
.typed button[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.saved { display: grid; place-items: center; min-height: 150px; background: #fff; color: #555; border: 1px solid var(--line-strong); border-radius: 16px; padding: 18px; }
.saved img { max-width: 100%; max-height: 110px; }
.seal-prev { display: grid; place-items: center; padding: 20px; border: 1px solid var(--line-strong); border-radius: 16px; background: #fff; color: #555; margin-bottom: 14px; }
.seal-prev canvas { width: 190px; height: auto; max-width: 100%; }
.seal-prev canvas.rect { width: 260px; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 80; background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; font-size: 14.5px; opacity: 0; transition: all 0.25s ease; pointer-events: none; max-width: calc(100vw - 40px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── Success mark ─────────────────────────────────────────────── */
.seal-mark { width: 84px; height: 84px; margin: 36px 0 8px; }
.seal-mark circle { fill: none; stroke: var(--seal); stroke-width: 2; stroke-dasharray: 246; stroke-dashoffset: 246; animation: draw 0.9s 0.1s ease forwards; }
.seal-mark path { fill: none; stroke: var(--seal); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.5s 0.8s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.recent { margin-top: 44px; }
.recent a { text-decoration: none; }
.countdown { font-variant-numeric: tabular-nums; }
.errbox { padding: 14px 16px; border-radius: 12px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); font-size: 14.5px; }
.fine { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.fine a { color: inherit; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--ink); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
.fp { font-family: var(--mono); font-size: 12px; line-height: 1.7; letter-spacing: 0.02em; word-break: break-all; padding: 12px 14px; border-radius: 12px; background: var(--tint); }

@media (min-width: 700px) {
  .display { margin-top: 56px; }
  .pg { border-radius: 3px; }
}
@media print { .dock, .topbar, .hairline { display: none; } }

.pad .btn.quiet { color: #6c6f76; }
.pad .btn.quiet:hover { color: #14161a; }
.pad .btn.quiet[disabled] { opacity: 0.35; }
