:root {
  --paper: #f4efe6; --ink: #1c1a17; --muted: #6f675b; --rule: #cfc6b6; --sheet: #fbf8f2;
  --accent: #c8401f; --accent-ink: #fff8f2; --ok: #2f6b4f;
  --serif: "Fraunces", Georgia, serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--mono); }
main { max-width: 1120px; margin: 0 auto; padding: clamp(24px, 5vw, 64px) 16px; display: grid; gap: 40px; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
header { grid-column: 1 / -1; border-bottom: 2px solid var(--ink); padding-bottom: 16px; }
h1 { font: 600 clamp(38px, 7vw, 76px)/.98 var(--serif); margin: 0; letter-spacing: -.02em; }
header p { margin: 12px 0 0; color: var(--muted); max-width: 62ch; }
h2 { font: 600 22px/1.2 var(--serif); margin: 0 0 12px; }
label { display: block; font-weight: 500; margin-bottom: 6px; }
textarea, input { width: 100%; font: inherit; color: inherit; background: var(--sheet); border: 1px solid var(--rule); padding: 12px; border-radius: 2px; }
textarea { height: 320px; resize: vertical; font-size: 13px; }
textarea:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { margin-bottom: 18px; }
.field input[type="number"] { max-width: 120px; }
button { font: 500 15px var(--mono); background: var(--accent); color: var(--accent-ink); border: 0; padding: 14px 22px; cursor: pointer; border-radius: 2px; box-shadow: 4px 4px 0 var(--ink); transition: transform var(--t, 120ms), box-shadow var(--t, 120ms); }
button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
button:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
button:disabled { opacity: .5; cursor: progress; }
button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--ink); box-shadow: none; padding: 8px 12px; font-size: 13px; }
section + section { margin-top: 32px; }
.stage { font-size: 13px; color: var(--muted); min-height: 20px; margin: 0 0 12px; }
.progress { border: 2px solid var(--ink); background: var(--sheet); padding: 16px; margin-bottom: 32px; box-shadow: 6px 6px 0 var(--ink); }
.score { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.score strong { font: 600 clamp(40px, 6vw, 64px)/1 var(--serif); letter-spacing: -.02em; }
.score strong small { font-size: .5em; color: var(--muted); font-weight: 400; }
.clock { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 14px; margin: 12px 0; border: 1px solid var(--ink); overflow: hidden; position: relative; background: var(--paper); }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform var(--duration, 400ms) ease-out; }
.bar.live::after { content: ""; position: absolute; inset: 0; width: 30%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .55), transparent); animation: sweep 1.6s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.now { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.now b { font-weight: 500; color: var(--accent); }
.error { color: var(--accent); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.chips li { border: 1px solid var(--rule); background: var(--sheet); padding: 2px 8px; font-size: 13px; }
.chips small { color: var(--muted); }
.chips li.done { opacity: .55; text-decoration: line-through; }
.chips li.current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); opacity: 1; text-decoration: none; }
.chips li.current small { color: inherit; }
.refs { list-style: none; counter-reset: ref; padding: 0; margin: 0; }
.refs li { counter-increment: ref; display: grid; grid-template-columns: 44px minmax(0, 1fr); padding: 14px 0; border-top: 1px solid var(--rule); }
.refs li::before { content: counter(ref, decimal-leading-zero); font: 600 22px var(--serif); color: var(--accent); }
.refs a { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.meta { font-size: 12px; color: var(--muted); }
.quote { font: 400 15px/1.4 var(--serif); margin: 6px 0 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
td { padding: 3px 0; border-bottom: 1px dotted var(--rule); }
td:last-child { text-align: right; }
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
@media (max-width: 760px) { main { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { button { --t: 0ms; } .bar i { --duration: 0ms; } .bar.live::after { animation: none; } }

[hidden] { display: none !important; }
select { width: 100%; font: inherit; color: inherit; background: var(--sheet); border: 1px solid var(--rule); padding: 12px; border-radius: 2px; }
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: 20px; margin-bottom: 24px; font-size: 14px; }
.tabs a { color: var(--muted); text-decoration: none; padding-bottom: 4px; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--accent); }

main.signing { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
.sticky { position: sticky; top: 16px; }
.drop { display: block; border: 2px dashed var(--ink); background: var(--sheet); padding: 40px 16px; text-align: center; cursor: pointer; font-weight: 500; }
.drop:hover, .drop.over { background: var(--paper); border-color: var(--accent); color: var(--accent); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.drop small { display: block; color: var(--muted); font-weight: 400; margin-top: 6px; }

.pdf-pages { display: grid; gap: 20px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 0 var(--rule), 6px 6px 0 var(--rule); }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page-number { position: absolute; left: 8px; top: 8px; font-size: 11px; background: var(--ink); color: var(--paper); padding: 1px 6px; }

.palette-chip, .marker, .spot { font: 500 11px/1.2 var(--mono); letter-spacing: .04em; color: var(--accent); text-align: center; }
.palette-chip { display: block; width: 100%; border: 2px dashed var(--accent); background: rgb(200 64 31 / .1); padding: 18px 8px; cursor: grab; touch-action: none; user-select: none; }
.palette-chip:hover { background: rgb(200 64 31 / .18); }
.drag-ghost { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -50%); width: 180px; border: 2px dashed var(--accent); background: rgb(251 248 242 / .9); padding: 12px 6px; }
.marker { position: absolute; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--accent); background: rgb(200 64 31 / .14); cursor: grab; touch-action: none; user-select: none; overflow: visible; }
.marker:active { cursor: grabbing; }
.marker:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.marker-remove { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; padding: 0; font-size: 13px; line-height: 1; border-radius: 50%; box-shadow: none; }
.marker-remove:hover, .marker-remove:active { transform: none; box-shadow: none; background: var(--ink); }
.marker-grip { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; background: var(--accent); cursor: nwse-resize; touch-action: none; }
.spot { position: absolute; display: flex; align-items: center; justify-content: center; border: 2px solid var(--accent); background: rgb(200 64 31 / .12); }

.contracts { list-style: none; padding: 0; margin: 0; }
.contracts li { padding: 14px 0; border-top: 1px solid var(--rule); }
.contracts h3 { font: 600 18px/1.25 var(--serif); margin: 0 0 2px; overflow-wrap: anywhere; }
.contract-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.status { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 6px; border: 1px solid currentColor; color: var(--muted); }
.status.signed { color: var(--ok); }
.notice { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--sheet); font-size: 13px; margin: 12px 0; }

.mode-switch { display: flex; gap: 8px; margin-bottom: 8px; }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.signature-pad { display: block; width: 100%; height: 170px; background: var(--sheet); border: 1px solid var(--ink); touch-action: none; cursor: crosshair; }
.signature-preview { display: block; max-width: 100%; max-height: 120px; margin-top: 8px; background: var(--sheet); border: 1px solid var(--rule); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; }
.check input { width: 18px; height: 18px; flex: none; margin: 2px 0 0; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.download { display: inline-block; font: 500 15px var(--mono); background: var(--accent); color: var(--accent-ink); text-decoration: none; padding: 14px 22px; border-radius: 2px; box-shadow: 4px 4px 0 var(--ink); }

@media (max-width: 760px) {
  main.signing { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
.copy-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.alert { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border: 2px solid var(--accent); background: var(--sheet); padding: 14px 16px; box-shadow: 6px 6px 0 var(--accent); }
.alert p { margin: 0; font-size: 14px; }
.alert strong { color: var(--accent); }

.history { margin-top: 36px; }
.history-list { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; border-top: 1px solid var(--rule); }
.history-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; width: 100%; text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--rule); box-shadow: none; padding: 10px 4px; font-size: 13px; }
.history-entry:hover { transform: none; box-shadow: none; background: var(--sheet); }
.history-entry:active { transform: none; box-shadow: none; }
.history-niche { font: 600 16px/1.25 var(--serif); overflow-wrap: anywhere; }
.history-status { justify-self: end; font-size: 12px; color: var(--muted); }
.history-status.running, .history-status.queued { color: var(--accent); font-weight: 500; }
.history-status.done { color: var(--ok); }
.history-status.error { color: var(--accent); }

.log { margin-top: 32px; }
.log-lines { max-height: 320px; overflow: auto; background: var(--ink); color: var(--paper); font-size: 11px; line-height: 1.5; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
