@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-latin-normal.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: hsl(207 50% 14%);
  --stone: hsl(207 25% 36%);
  --surface: hsl(210 58% 97%);
  --desk: hsl(206 30% 90%);
  --paper: #fff;
  --line: hsl(203 34% 83%);
  --teal: hsl(194 94% 40%);
  --teal-soft: hsl(194 90% 95%);
  --red: hsl(4 70% 45%);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; color: var(--ink); }
.brand svg { height: 26px; width: auto; }
.doc { min-width: 0; flex: 1; }
.doc h1 { margin: 0; font: 400 22px/1.15 var(--serif); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc p { margin: 2px 0 0; color: var(--stone); font-size: 13px; }
.copy { color: var(--stone); font-size: 13px; white-space: nowrap; }
.progress { margin: 0; color: var(--stone); font-size: 13px; white-space: nowrap; }

button.primary { border: 0; border-radius: 6px; padding: 9px 18px; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; }
button.primary:hover { background: hsl(207 50% 20%); }
button.primary:disabled { opacity: .45; cursor: default; }
button.plain { border: 1px solid var(--line); border-radius: 6px; padding: 9px 16px; background: var(--paper); cursor: pointer; }
button.link { border: 0; padding: 0; background: none; color: var(--stone); text-decoration: underline; cursor: pointer; font-size: 13px; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.notice { max-width: 880px; margin: 20px auto 0; padding: 14px 18px; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: 4px; }
.notice strong { display: block; font: 400 20px/1.2 var(--serif); margin-bottom: 2px; }
.notice a { color: var(--ink); font-weight: 600; }
.notice p { margin: 0; color: var(--stone); }

/* pages */
#pages { max-width: 880px; margin: 0 auto; padding: 20px 12px 80px; }
.page { position: relative; margin: 0 auto 16px; background: var(--paper); box-shadow: 0 1px 2px hsl(207 30% 30% / .18), 0 0 0 1px hsl(207 30% 30% / .06); }
.page canvas { display: block; width: 100%; height: auto; }

.spot { position: absolute; display: flex; align-items: center; padding: 0; border: 0; background: none; font-size: 11px; line-height: 1; text-align: left; }
.spot img { max-width: 100%; max-height: 100%; object-fit: contain; object-position: left bottom; align-self: flex-end; }
.spot.mine.open { border: 1.5px solid var(--teal); border-radius: 3px; background: hsl(194 90% 95% / .85); color: hsl(194 94% 24%); cursor: pointer; justify-content: center; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.spot.mine.open:hover { background: hsl(194 90% 90%); }
.spot.mine.open.next { box-shadow: 0 0 0 4px hsl(194 94% 46% / .25); }
.spot.other.open { border: 1px dashed hsl(207 20% 70%); border-radius: 3px; color: hsl(207 15% 55%); padding-left: 6px; white-space: nowrap; overflow: hidden; }
.spot.date, .spot.text, .spot.check { font: calc(var(--pt, 1px) * 11) / 1 "Times New Roman", Times, serif; color: var(--ink); }
input.spot.text.mine.open { padding: 0 calc(var(--pt, 1px) * 2); border: 0; border-bottom: 1.5px solid var(--teal); border-radius: 0; background: hsl(194 90% 95% / .85); text-transform: none; letter-spacing: 0; font-weight: 400; cursor: text; }
input.spot.text.mine.open.optional { border-bottom-color: hsl(207 20% 70%); background: hsl(207 30% 96% / .7); }
input.spot.text.needed.next { box-shadow: 0 0 0 4px hsl(194 94% 46% / .25); }
input.spot.text::placeholder { color: hsl(194 60% 35% / .7); }
div.spot.text.filled { padding-left: calc(var(--pt, 1px) * 2); white-space: nowrap; }
.spot.check { justify-content: center; font-family: var(--sans); font-weight: 700; }
button.spot.check.open { border: 1.5px solid var(--teal); border-radius: 2px; background: hsl(194 90% 95% / .85); cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--ink); }
.spot.date.mine.open { border: 0; background: none; cursor: default; box-shadow: none; }
.spot.date.filled { padding-left: calc(var(--pt, 1px) * 2); white-space: nowrap; }

.state { max-width: 520px; margin: 18vh auto; padding: 0 20px; text-align: center; color: var(--stone); }
.state p { margin: 0; }
.state strong { display: block; color: var(--ink); font: 400 28px/1.15 var(--serif); margin-bottom: 8px; }

/* signature dialog */
dialog { width: min(560px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); box-shadow: 0 20px 50px hsl(207 50% 14% / .25); }
dialog::backdrop { background: hsl(207 50% 14% / .45); }
dialog form { padding: 22px 24px 20px; }
dialog h2 { margin: 0 0 14px; font: 400 26px/1.1 var(--serif); }
.field-label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; }
input[type=text] { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.tabs { display: flex; gap: 22px; margin: 18px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 0 0 8px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--stone); cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.styles { display: grid; gap: 8px; }
.styles label { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; overflow: hidden; }
.styles label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.styles span { font-size: 34px; line-height: 1; white-space: nowrap; color: hsl(215 60% 18%); }
#pad { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); touch-action: none; cursor: crosshair; }
.upload { display: flex; align-items: center; justify-content: center; height: 130px; margin-bottom: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 6px; color: var(--stone); font-size: 13px; text-align: center; }
.upload img { max-width: 100%; max-height: 100%; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 13.5px; }
.consent input { margin-top: 3px; }
.error { min-height: 18px; margin: 8px 0 0; color: var(--red); font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 600px) {
  .bar { gap: 10px; padding: 10px 12px; }
  .doc h1 { font-size: 18px; }
  .doc p, .progress, .copy { display: none; }
  #pages { padding: 10px 0 80px; }
  .styles span { font-size: 28px; }
}
