:root {
  --bg: #f5f6f8; --surface: #fff; --ink: #1c2330; --muted: #5d6675; --line: #dde1e8;
  --brand: #1f3a5f; --brand-ink: #fff; --accent: #c8102e; --ok: #1d7a46; --warn: #a15c00; --bad: #b42318;
  --hot: #fff4d6; --hot-line: #e0a100;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161d; --surface: #1b212b; --ink: #e8ecf2; --muted: #9aa5b5; --line: #2c3442; --brand: #6f9bd6; --brand-ink: #0c121b; --hot: #3a3015; --hot-line: #c99a14; --shadow: none; }
}
* { 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; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.2em 0 .5em; }
a { color: var(--brand); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

button, .btn { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-height: 40px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field small { display: block; color: var(--muted); font-weight: 400; margin-top: 3px; }
.grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 9px 12px; border-radius: 8px; margin: 10px 0; }
.notice { background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); padding: 12px; border-radius: 8px; }

/* admin */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.topbar h1 { margin: 0; font-size: 1.05rem; flex: 1; }
.login { max-width: 360px; margin: 14vh auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); }
.chip.created { color: var(--muted); } .chip.viewed { color: var(--warn); border-color: var(--warn); }
.chip.signed { color: var(--ok); border-color: var(--ok); } .chip.expired, .chip.revoked { color: var(--bad); border-color: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 25, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow: auto; z-index: 50; }
.modal { width: 100%; max-width: 720px; }
.linkbox { display: flex; gap: 8px; } .linkbox input { font-family: ui-monospace, monospace; font-size: .85rem; }
@media (max-width: 720px) { .hide-sm { display: none; } th, td { padding: 8px 4px; } }

/* signing page */
.sbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.sbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
.sbar .prog { flex: 1; font-size: .9rem; }
.bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .25s; }
.intro { max-width: 860px; margin: 16px auto; padding: 0 12px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 0 24px; }
.page { position: relative; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); }
.page canvas { display: block; width: 100%; height: 100%; }
.hot { position: absolute; padding: 0; min-height: 0; border: 2px dashed var(--hot-line); background: var(--hot); border-radius: 4px; color: #6b4a00; font-size: 11px; line-height: 1.15; text-align: center; display: flex; align-items: center; justify-content: center; }
.hot.done { border: 2px solid var(--ok); background: #fff; }
.hot img { max-width: 92%; max-height: 92%; }
.hot.pulse { animation: pulse 1s 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--hot-line) 45%, transparent); } }
.datetxt { position: absolute; color: #000; font-family: Arial, sans-serif; white-space: nowrap; }
.submit { max-width: 860px; margin: 0 auto 60px; padding: 0 12px; }
.pad { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; touch-action: none; display: block; cursor: crosshair; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.typed { font-family: "Dancing Script", cursive; font-size: 2rem; }
.center { text-align: center; }
@font-face { font-family: "Dancing Script"; src: url("/static/fonts/DancingScript-Bold.otf"); font-weight: 700; font-display: swap; }
