/* GRAIN — free document signing.
   The document is the hero: a white sheet on cool paper-grey, ink-navy type, one signing blue for the action.
   Status colours mean one thing each: green signed, amber waiting, red declined.
   Ad slots sit in a fixed frame so the bottom square always lands right under the content. */
:root {
  --paper: #eef1f6;
  --sheet: #ffffff;
  --ink: #14213d;
  --ink-2: #4a5674;
  --ink-3: #7b86a1;
  --line: #d9dfe9;
  --blue: #2357d9;
  --blue-2: #1c47b5;
  --blue-soft: #e7eefc;
  --green: #1f8a5b;
  --green-soft: #e3f4ec;
  --amber: #a8690d;
  --amber-soft: #fbf0dc;
  --red: #c2412d;
  --red-soft: #fbe7e3;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
h2 { font-family: var(--serif); font-size: 21px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- top bar ---------- */
.top { background: var(--sheet); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; font-size: 15px; }
.logo svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a { padding: 7px 11px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: 14px; }
.nav a:hover { background: var(--paper); color: var(--ink); }
.nav a.on { color: var(--ink); background: var(--blue-soft); }

/* ---------- page frame: content + right Google slot; ads above and below content ---------- */
.frame { max-width: 1180px; margin: 0 auto; padding: 18px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.frame.wide { grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; }
.side-ad { position: sticky; top: 74px; }
@media (max-width: 980px) { .frame { grid-template-columns: minmax(0, 1fr); } .side-ad { display: none; } }
.ad-label { font-size: 11px; color: var(--ink-3); text-align: center; margin-bottom: 5px; }
.ad-under { font-size: 12px; text-align: center; margin-top: 5px; }
.ad-under a { color: var(--ink-3); text-decoration: none; }
.ad-under a:hover { color: var(--blue); text-decoration: underline; }
.ad-top { margin: 0 auto 22px; max-width: 728px; }
.ad-bottom { margin: 26px auto 0; max-width: 300px; }      /* fixed gap: always right under the content */
.ad-top img, .ad-bottom img, .ad-card img, .gate-ad img { display: block; width: 100%; height: auto; border-radius: 8px; }
.ad-top .slot-empty { aspect-ratio: 728 / 90; }
.ad-bottom .slot-empty { aspect-ratio: 300 / 250; }
.slot-empty { border: 1.5px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; background: var(--sheet); }
.google-slot { width: 300px; height: 600px; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--sheet);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink-3); font-size: 13px; text-align: center; }
.google-slot .plus { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 18px; font-weight: 700; }

/* ---------- the ad gate (pop-up between pages) ---------- */
.gate-bg { position: fixed; inset: 0; background: rgba(20, 33, 61, 0.55); z-index: 100; display: grid; place-items: center; padding: 16px; }
.gate { background: var(--sheet); border-radius: 16px; padding: 18px 22px 16px; width: min(460px, 100%); box-shadow: 0 24px 60px rgba(20, 33, 61, 0.35); }
.gate .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; min-height: 36px; }
.gate .head .tag { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.gate .count { color: var(--ink-2); font-size: 14px; }
.gate-ad { max-width: 300px; margin: 0 auto; }
.gate .foot { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: 12px; }

/* ---------- buttons, fields ---------- */
.btn { appearance: none; border: 1px solid var(--line); background: var(--sheet); color: var(--ink); border-radius: 9px; padding: 9px 16px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { color: var(--red); border-color: #efc4bc; }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[readonly] { background: var(--paper); color: var(--ink-2); }
textarea { min-height: 76px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 17px; height: 17px; flex: none; accent-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.code-input { font-size: 26px !important; letter-spacing: 0.4em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace !important; }

/* ---------- surfaces ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.sheet + .sheet { margin-top: 16px; }
.sheet.tight { padding: 16px; }
.narrow { max-width: 520px; margin: 0 auto; }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.notice { border-radius: 10px; padding: 12px 14px; font-size: 14px; background: var(--blue-soft); color: var(--ink); }
.notice.warn { background: var(--amber-soft); }
.notice.bad { background: var(--red-soft); }
.notice.good { background: var(--green-soft); }
.error-box { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.empty { text-align: center; color: var(--ink-2); padding: 34px 10px; }
.loading { color: var(--ink-3); padding: 30px; text-align: center; }

/* status pills */
.pill { display: inline-block; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--paper); color: var(--ink-2); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n { opacity: 0.7; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* document list */
.docs { display: flex; flex-direction: column; gap: 8px; }
.doc { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--sheet); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.doc:hover { border-color: var(--ink-3); }
.doc .ico { width: 34px; height: 42px; border-radius: 4px; border: 1px solid var(--line); background: linear-gradient(var(--sheet), var(--sheet)) padding-box;
  position: relative; }
.doc .ico::after { content: ""; position: absolute; left: 6px; right: 6px; top: 9px; height: 14px;
  background: repeating-linear-gradient(var(--line) 0 2px, transparent 2px 5px); }
.doc .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .s { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }

/* people + audit */
.people { display: flex; flex-direction: column; }
.person { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--paper); color: var(--ink-2); }
.audit { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.audit li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.audit li:first-child { border-top: 0; }
@media (max-width: 560px) { .audit li { grid-template-columns: 1fr; gap: 0; } }

/* ---------- pages of the PDF with fields on top ---------- */
.pages { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.pg { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(20, 33, 61, 0.12), 0 8px 24px rgba(20, 33, 61, 0.08); width: 100%; }
.pg canvas { display: block; width: 100%; height: auto; }
.pg .layer { position: absolute; inset: 0; }
.pg .pno { position: absolute; right: 8px; bottom: -20px; font-size: 11px; color: var(--ink-3); }
.fld { position: absolute; border: 2px solid var(--c, var(--blue)); background: color-mix(in srgb, var(--c, var(--blue)) 12%, transparent);
  border-radius: 4px; font-size: 12px; color: var(--ink); display: flex; align-items: center; justify-content: center; text-align: center;
  user-select: none; touch-action: none; overflow: hidden; line-height: 1.1; }
.fld.edit { cursor: move; }
.fld .x { position: absolute; top: -1px; right: -1px; width: 18px; height: 18px; border: 0; border-radius: 0 3px 0 4px; background: var(--c, var(--blue));
  color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }
.fld .grip { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--c, var(--blue)) 50%); }
.fld.todo { cursor: pointer; animation: pulse 1.6s ease-in-out infinite; }
.fld.done { background: transparent; border-style: dashed; border-color: color-mix(in srgb, var(--c, var(--blue)) 50%, transparent); animation: none; }
.fld img { max-width: 100%; max-height: 100%; }
.fld input[type=text] { border: 0; background: transparent; width: 100%; height: 100%; padding: 2px 4px; font-size: 12px; border-radius: 0; }
.fld input[type=checkbox] { width: 70%; height: 70%; margin: 0; accent-color: var(--blue); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--blue)) 25%, transparent); } }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.editor .panel { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow-y: auto; }
@media (max-width: 980px) { .editor { grid-template-columns: 1fr; } .editor .panel { position: static; max-height: none; } }
.signer-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 28px; gap: 8px; align-items: start; margin-bottom: 8px; }
.signer-row .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 12px; background: var(--c); }
.signer-row .inputs { display: grid; gap: 6px; }
.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tool { border: 1px solid var(--line); background: var(--sheet); border-radius: 8px; padding: 8px 4px; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tool.on { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.who { display: flex; gap: 6px; flex-wrap: wrap; }
.who button { border: 2px solid var(--c); background: var(--sheet); color: var(--ink); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.who button.on { background: var(--c); color: #fff; }
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 44px 20px; text-align: center; background: var(--sheet); cursor: pointer; }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); }

/* ---------- signing ---------- */
.signbar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; }
.signbar .in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.signbar .t { font-weight: 650; flex: 1; min-width: 160px; }
.signbar .btn { border-color: transparent; }
.pad-wrap { border: 1px solid var(--line); border-radius: 10px; background: #fff; position: relative; }
.pad-wrap canvas { display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair; border-radius: 10px; }
.pad-wrap .base { position: absolute; left: 22px; right: 22px; bottom: 44px; border-bottom: 1px solid var(--line); pointer-events: none; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: var(--blue-soft); color: var(--blue); }
.place-chip { display: inline-flex; align-items: center; gap: 8px; border: 2px dashed var(--blue); background: var(--blue-soft); color: var(--blue);
  border-radius: 10px; padding: 8px 12px; font-weight: 650; cursor: grab; touch-action: none; user-select: none; }
.place-chip img { height: 26px; }
.done-card { text-align: center; max-width: 520px; margin: 0 auto; }
.done-card .tick { width: 64px; height: 64px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 0 auto 14px; }
.ad-card { margin: 18px auto 6px; max-width: 420px; }

/* ---------- modal + toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 33, 61, 0.45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: var(--sheet); border-radius: 14px; padding: 22px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 24px 60px rgba(20, 33, 61, 0.3); }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, 92vw); }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(20, 33, 61, 0.3); }
.toast.bad { background: var(--red); }

/* ---------- home ---------- */
.home-top { max-width: 1180px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 12px; }
.home-top .nav { margin-left: auto; }
.hero { max-width: 1180px; margin: 0 auto; padding: 46px 20px 56px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 46px; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: 26px; } }
.hero h1 { font-size: clamp(38px, 6vw, 62px); line-height: 1.02; letter-spacing: -0.02em; }
.hero .lede { font-size: 18px; color: var(--ink-2); margin: 18px 0 24px; max-width: 34em; }
.paper { background: #fff; border-radius: 6px; box-shadow: 0 2px 4px rgba(20, 33, 61, 0.08), 0 30px 60px rgba(20, 33, 61, 0.14); padding: 34px 34px 28px;
  transform: rotate(-1.2deg); max-width: 440px; justify-self: center; width: 100%; }
.paper .ln { height: 7px; border-radius: 4px; background: var(--paper); margin-bottom: 11px; }
.paper .sig-line { margin-top: 30px; border-bottom: 1.5px solid var(--ink); height: 58px; position: relative; }
.paper .sig-line svg { position: absolute; left: 6px; bottom: 4px; width: 210px; height: 54px; }
.paper .sig-line path { stroke-dasharray: 600; stroke-dashoffset: 600; animation: ink 2.2s 0.4s ease-out forwards; }
@keyframes ink { to { stroke-dashoffset: 0; } }
.paper .meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.steps { background: var(--ink); color: #fff; }
.steps .in { max-width: 1180px; margin: 0 auto; padding: 46px 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
@media (max-width: 760px) { .steps .in { grid-template-columns: 1fr; } }
.steps h3 { color: #fff; font-size: 17px; margin: 8px 0 6px; }
.steps p { color: #c5cde0; font-size: 15px; }
.steps .k { font-family: var(--serif); font-size: 34px; color: #8fb0ff; line-height: 1; }
.compare { max-width: 820px; margin: 0 auto; padding: 50px 20px; }
.compare table { width: 100%; border-collapse: collapse; background: var(--sheet); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.compare th, .compare td { padding: 12px 16px; text-align: left; border-top: 1px solid var(--line); font-size: 15px; }
.compare thead th { border-top: 0; background: var(--paper); font-size: 14px; }
.compare td.g { color: var(--green); font-weight: 650; }
.foot { text-align: center; color: var(--ink-3); font-size: 13px; padding: 26px 20px 40px; }
.foot a { color: var(--ink-2); }

/* key / value rows (document details) */
.kv { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px 16px; font-size: 14px; }
.kv .k { color: var(--ink-2); }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv .v { margin-bottom: 8px; } }
