/* Prap Sign. Calm, light and dark, no hover colour changes. */
:root {
  --bg: #f5f5f7; --panel: #ffffff; --ink: #1d1d1f; --muted: #6e6e73; --line: #d2d2d7;
  --accent: #0a66d8; --accent-ink: #ffffff; --soft: #e8f1fd; --danger: #c4262e; --good: #1a7f37;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.06);
  --p0: #0a66d8; --p1: #b3541e; --p2: #1a7f37; --p3: #8a3ffc; --p4: #a2191f; --p5: #005d5d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --panel: #2c2c2e; --ink: #f5f5f7; --muted: #a1a1a6; --line: #48484a;
    --accent: #4c9bff; --accent-ink: #0b0b0c; --soft: #3e3e42; --danger: #ff6961; --good: #4cc26a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.35);
    --p0: #4c9bff; --p1: #ff9f5a; --p2: #4cc26a; --p3: #be95ff; --p4: #ff8389; --p5: #3ddbd9;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.2; margin: 8px 0 12px; letter-spacing: -.01em; }
h1.small { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 18px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.wrap { overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 13px; }
.problem { color: var(--danger); }
div.problem { border: 1px solid var(--danger); border-radius: 10px; padding: 8px 14px; margin: 12px 0; }
.good { color: var(--good); } .bad { color: var(--danger); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink); text-decoration: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 6px #e5484d; }
.top nav { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.top nav a { color: var(--ink); text-decoration: none; }
form.inline { display: inline; margin: 0; }
.top nav button.link { color: var(--ink); text-decoration: none; }

main.narrow { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
main.wide { padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; margin: 16px 0; box-shadow: var(--shadow); }
.card.small { max-width: 460px; margin: 40px auto; }
.card.center { max-width: 520px; margin: 60px auto; text-align: center; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }

label { display: block; font-weight: 550; margin: 12px 0 4px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; width: 18px; height: 18px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
textarea { resize: vertical; }
button, a.button { font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 14px; min-height: 36px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.danger { color: #0b0b0c; } }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; }
button:disabled { opacity: .45; cursor: default; }
form > button { margin-top: 14px; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card table.list { border: 0; border-radius: 0; }
.card:has(table) { overflow-x: auto; }
table.list th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 550; padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list td form { margin: 0; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; }
.pill.completed { border-color: var(--good); color: var(--good); }
.pill.declined, .pill.voided, .pill.expired { border-color: var(--danger); color: var(--danger); }
.pill.sent, .pill.completing { border-color: var(--accent); color: var(--accent); }
ol.history { margin: 8px 0 0; padding-left: 20px; }
ol.history li { margin: 4px 0; overflow-wrap: anywhere; }
.mail pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 8px 0 0; }

/* Prepare and signing screens */
.workspace { display: grid; grid-template-columns: 340px 1fr; min-height: calc(100vh - 54px); }
.panel { background: var(--panel); border-right: 1px solid var(--line); padding: 16px; overflow: auto; }
.pages { padding: 20px 16px 80px; display: flex; flex-direction: column; align-items: center; gap: 20px; overflow: auto; }
.page { position: relative; width: min(100%, 860px); background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); touch-action: pan-y; }
.page img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.page.arming { cursor: crosshair; }
.pagenum { color: var(--muted); font-size: 12.5px; margin: -12px 0 0; }
.person { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; border-left-width: 6px; }
.person.active { background: var(--soft); }
.person .line { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.person .line label { margin: 0; font-weight: 400; font-size: 13px; }
.person input[type=number] { width: 64px; }
.person select { width: auto; flex: 1; min-width: 120px; }
.person .line button { margin-left: auto; }
.person .pick { display: flex; gap: 8px; align-items: center; font-weight: 550; }
.person .pick input { width: 18px; height: 18px; }
.c0 { border-left-color: var(--p0); } .c1 { border-left-color: var(--p1); } .c2 { border-left-color: var(--p2); }
.c3 { border-left-color: var(--p3); } .c4 { border-left-color: var(--p4); } .c5 { border-left-color: var(--p5); }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette button[aria-pressed=true] { background: var(--soft); border-color: var(--accent); font-weight: 600; }
.status { min-height: 22px; color: var(--muted); font-size: 13px; }

.field { position: absolute; border: 2px solid var(--p0); background: rgba(10,102,216,.12); color: #1d1d1f; border-radius: 4px; font-size: 11px; line-height: 1.1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0; min-height: 0; cursor: grab; touch-action: none; }
.field.f1 { border-color: var(--p1); background: rgba(179,84,30,.14); } .field.f2 { border-color: var(--p2); background: rgba(26,127,55,.14); }
.field.f3 { border-color: var(--p3); background: rgba(138,63,252,.14); } .field.f4 { border-color: var(--p4); background: rgba(162,25,31,.14); }
.field.f5 { border-color: var(--p5); background: rgba(0,93,93,.14); }
.field:focus-visible { outline-offset: 1px; }
.field .grip { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; background: currentColor; opacity: .55; cursor: nwse-resize; border-top-left-radius: 4px; }

.signbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.signbar p { margin: 0; }
.progress { font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.more { position: relative; }
details.more summary { cursor: pointer; padding: 7px 4px; }
details.more .menu { position: absolute; right: 0; top: 100%; width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); z-index: 6; }
.signing .field { cursor: pointer; border-color: #b7791f; background: rgba(255,214,10,.3); }
.signing .field.done { border-color: var(--good); background: rgba(26,127,55,.08); }
.signing .field.auto { cursor: default; border-style: dashed; }
.signing .field img { max-width: 100%; max-height: 100%; }
.signing input.field { font: inherit; font-size: 12px; text-align: left; padding: 0 4px; color: #1d1d1f; cursor: text; }
.signing input.field[type=checkbox] { appearance: auto; padding: 0; cursor: pointer; }
.signing > .problem { margin: 10px 20px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); padding: 18px 20px; width: min(680px, calc(100vw - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
.tabs { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; min-height: 30px; padding: 4px 16px; }
.tabs button[aria-selected=true] { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.2); font-weight: 600; }
#pad { display: block; width: 100%; height: auto; margin: 12px 0 4px; background: #fff; border: 1px dashed var(--line); border-radius: 10px; touch-action: none; }
@font-face { font-family: "Prap Script"; src: url("/static/DancingScript.ttf") format("truetype"); font-display: block; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .signbar { padding: 8px 12px; }
  .pages { padding: 12px 8px 80px; }
  table.list th:nth-child(4), table.list td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Round 2: field settings, filters, small forms inside tables, the QR picture */
.fieldbox { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 12px 0 0; }
.fieldbox legend { font-weight: 600; padding: 0 6px; }
.fieldbox button.link { margin-top: 10px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.chosen { outline: 2px dashed var(--ink); outline-offset: 2px; }
form.filter { display: flex; gap: 8px; align-items: center; margin: 16px 0 8px; flex-wrap: wrap; }
form.filter input[type=text] { flex: 2; min-width: 200px; }
form.filter select { flex: 1; min-width: 160px; width: auto; }
form.filter > button { margin-top: 0; }
td.acts form { display: inline-block; margin-right: 10px; }
td.acts form > button { margin-top: 0; }
details.fix summary { cursor: pointer; color: var(--accent); text-decoration: underline; margin-top: 4px; }
details.fix form { margin-top: 6px; min-width: 220px; }
img.qr { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
a.button + a.button { margin-left: 6px; }
.signing select.field { font: inherit; font-size: 12px; padding: 0 2px; color: #1d1d1f; background: rgba(255,214,10,.3); cursor: pointer; appearance: auto; }
.signing select.field.done { background: rgba(26,127,55,.08); }

/* Round 3: more handwriting, the one-at-a-time panel, small extras */
@font-face { font-family: "Prap Vibes"; src: url("/static/GreatVibes.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Prap Sacramento"; src: url("/static/Sacramento.ttf") format("truetype"); font-display: block; }
.sigpad { display: block; width: min(100%, 600px); height: auto; aspect-ratio: 600 / 160; border: 1px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; }
.private > .card { max-width: 860px; margin: 14px auto; }
.private #p-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; }
@font-face { font-family: "Prap Caveat"; src: url("/static/Caveat.ttf") format("truetype"); font-display: block; }
.guide { position: sticky; bottom: 0; z-index: 5; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 20px 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.guide p { margin: 0; font-size: 12.5px; }
.guide label { margin: 2px 0 6px; }
.guide .row { margin-top: 0; justify-content: space-between; align-items: center; }
.guide #guide-slot { flex: 1; display: flex; justify-content: center; }
.guide #guide-slot > * { max-width: 420px; }
.guide #guide-slot > input[type=text], .guide #guide-slot > select { width: 100%; }
.guide #guide-slot > input[type=checkbox], .guide #guide-slot > input[type=radio] { width: 22px; height: 22px; }
.guide #guide-slot > .auto { padding: 6px 10px; }
.signing .field.current { box-shadow: 0 0 0 3px var(--accent); }
.signing input.field[type=radio] { appearance: auto; padding: 0; cursor: pointer; }
.signing button.field { color: #1d1d1f; }
.anchor { margin-top: 10px; }
.anchor .line { display: flex; gap: 6px; }
.anchor .line input { flex: 1; }
details.extra { margin-top: 6px; }
.fieldbox label.check { margin: 6px 0; }
/* Fields on the page keep the size the sender gave them: no minimum height from ordinary inputs. */
.signing input.field, .signing select.field, .signing button.field { min-height: 0; border-radius: 4px; border-width: 2px; }
.signing input.field[type=text] { padding: 0 4px; }
img.logo { height: 22px; width: auto; }
dl.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 12px; }
dl.figures dt { color: var(--muted); font-size: 12.5px; }
dl.figures dd { margin: 0; font-size: 20px; font-weight: 600; }

/* Round 4 */
.signing input.field[type=date] { font: inherit; font-size: 12px; padding: 0 2px; color: #1d1d1f; }
.fieldbox #f-repeat { display: block; }

.ghost { position: absolute; border: 2px dashed var(--accent); background: rgba(10,102,216,.1); pointer-events: none; }
.palette button { cursor: grab; }
/* Round 5: fields that can't be changed while correcting, boxes, and notices */
.field.locked { cursor: not-allowed; opacity: .55; border-style: dotted; }
.signing input.field.cells { font-family: ui-monospace, Consolas, "Courier New", monospace; padding-right: 0; background-image: none; }
p.notice { border-left: 3px solid var(--accent); padding: 6px 10px; background: rgba(10,102,216,.08); border-radius: 4px; }

/* A part hidden from one person (prepare screen), and the plain-words card (signing page). */
.field.hide { background: repeating-linear-gradient(45deg, rgba(0,0,0,.72), rgba(0,0,0,.72) 6px, rgba(0,0,0,.58) 6px, rgba(0,0,0,.58) 12px); color: #fff; border-style: dashed; }
.palette button.hide { border-style: dashed; }
.plain { max-width: 860px; margin: 14px auto 0; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent, #0a66d8); border-radius: 10px; }
.plain h2 { margin: 0 0 6px; font-size: 16px; }
.plain h3 { margin: 10px 0 4px; font-size: 14px; }
.plain ul { margin: 6px 0; padding-left: 20px; }
.plain p { margin: 6px 0; }
.signing > .notice { max-width: 860px; margin: 14px auto 0; }

/* The signing page's helper column, and the home board. */
.reading.with-helper { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 4px; align-items: start; max-width: 1260px; margin: 0 auto; }
.reading.with-helper .pages { grid-column: 1; grid-row: 1; }
.reading.with-helper .helper { grid-column: 2; grid-row: 1; position: sticky; top: 78px; max-height: calc(100vh - 170px); overflow: auto; padding: 0 16px 16px 0; }
.helper .plain { margin: 20px 0 0; max-width: none; }
@media (max-width: 980px) { .reading.with-helper { display: block; } .reading.with-helper .helper { position: static; max-height: none; padding: 0 16px; } }
#ask-log p { margin: 6px 0; padding: 6px 10px; border-radius: 10px; overflow-wrap: anywhere; }
#ask-log .q { background: rgba(10,102,216,.12); margin-left: 28px; }
#ask-log .a { background: var(--bg, rgba(0,0,0,.05)); margin-right: 18px; }
#ask-log .bad { color: var(--danger); }
#ask-form .line { display: flex; gap: 6px; margin-top: 8px; } #ask-form .line input { flex: 1; min-width: 0; }
#read-aloud[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.drop.over { outline: 3px dashed var(--accent); outline-offset: -6px; }
.drop .row { align-items: center; gap: 16px; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 16px 0 24px; }
@media (max-width: 820px) { .board { grid-template-columns: minmax(0, 1fr); } }
.board h2 { font-size: 15px; margin: 0 0 8px; }
.board .doc { display: block; color: inherit; text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.board .doc strong { display: block; overflow-wrap: anywhere; margin-bottom: 6px; }
.board .doc:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pill.warn { border-color: #a15c00; color: #a15c00; }
.board .who { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.board .who span { font-size: 12px; border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; color: var(--muted); }
.board .who span.ok { border-color: var(--good); color: var(--good); }

#ask-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#ask-chips .chip { border: 1px solid var(--line); background: transparent; color: inherit; border-radius: 99px; padding: 2px 10px; font: inherit; font-size: 12.5px; min-height: 0; cursor: pointer; }
