:root {
  color-scheme: light;
  font: 16px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #233445;
  background: #f3f4f5;
  --ink: #233445;
  --muted: #596878;
  --border: #dce2e8;
  --accent: #244e76;
  --paper: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p, dd { margin: 0; }
button, input { font: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 3px solid #3375aa; outline-offset: 3px; }

.masthead { background: var(--paper); border-bottom: 1px solid var(--border); }
.masthead-inner, .layout { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead-inner { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; }
.document-mark { display: inline-block; position: relative; width: 18px; height: 22px; border: 1.5px solid var(--accent); border-radius: 3px; }
.document-mark::after { content: ""; position: absolute; inset: 7px 3px auto; height: 4px; border-block: 1px solid var(--accent); }
.reference, time { font-variant-numeric: tabular-nums; }
.reference { font-size: 13px; color: var(--muted); }
.layout { padding-block: 44px 64px; }

.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.provider { color: var(--accent); font-size: 14px; font-weight: 600; }
h1 { margin-top: 4px; font-size: clamp(26px, 4vw, 38px); font-weight: 600; line-height: 1.28; overflow-wrap: anywhere; }
.site-name { margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
.deadline { flex: none; text-align: right; color: var(--muted); font-size: 13px; }
.deadline span, .deadline time { display: block; }
.deadline time { color: var(--ink); margin-top: 2px; }

.columns { display: grid; grid-template-columns: minmax(228px, 300px) minmax(0, 1fr); align-items: start; gap: 24px; }
.preview h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.preview-card { border: 1px solid var(--border); background: var(--paper); border-radius: 12px; }
.preview-card + .preview-card { margin-top: 12px; }
.preview-content { padding: 20px; }
.preview-type { font-weight: 600; }
.preview-host, .preview-help { margin: 4px 0 16px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.mini-preview img { display: block; max-width: 100%; height: auto; object-fit: contain; }

.paper { background: var(--paper); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 12px; padding: 28px 32px 32px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0 0 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin-top: 3px; font-size: 15px; overflow-wrap: anywhere; }
.agreement h2, legend { font-size: 19px; font-weight: 600; }
.agreement-text { margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.85; }

form { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 16px; }
.name-label, .ink-heading { font-size: 14px; font-weight: 600; }
#signer { display: block; width: min(320px, 100%); margin-top: 6px; min-height: 44px; padding: 8px 12px; border: 1px solid #aebdcb; border-radius: 8px; color: var(--ink); }
.ink-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 12px; }
.text-button { padding: 8px 0 8px 8px; color: var(--accent); background: none; border: 0; font-size: 14px; }
.text-button:disabled { color: #687788; cursor: default; opacity: .75; }
.ink-pad { position: relative; background: #fafbfc; border: 1px solid #b9c7d4; border-radius: 8px; overflow: hidden; }
.ink-pad::before { content: ""; position: absolute; left: 16px; right: 16px; bottom: 26%; border-bottom: 1px dashed #b9c7d4; pointer-events: none; }
.ink-pad canvas { display: block; width: 100%; height: auto; touch-action: none; position: relative; z-index: 1; cursor: crosshair; }
.ink-pad span { position: absolute; inset: 44% 8px auto; text-align: center; pointer-events: none; color: var(--muted); font-size: 14px; }
.consent { margin-top: 20px; display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.consent input { flex: none; width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--accent); }
.sign-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.sign-actions span { color: var(--muted); font-size: 13px; }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--accent); transition: background-color 140ms ease;
}
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: #1a3c5d; }
.primary:disabled { opacity: .65; }
.secondary { background: white; color: var(--accent); border-color: #bccbd9; }
.secondary:hover { background: #edf2f6; }
.error { color: #a33429; font-size: 14px; }
.error:not(:empty) { margin-top: 12px; }
.notice { max-width: 580px; margin: 32px auto; background: var(--paper); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.notice h1 { font-size: 24px; }
.notice p { margin-top: 12px; color: var(--muted); white-space: pre-wrap; }
.notice button { margin-top: 20px; }

@media (max-width: 820px) {
  .masthead-inner, .layout { width: calc(100% - 40px); }
  .layout { padding-block: 32px 48px; }
  .columns { grid-template-columns: minmax(168px, 220px) minmax(0, 1fr); gap: 16px; }
  .paper { padding: 20px 24px 24px; }
}
@media (max-width: 630px) {
  .masthead-inner, .layout { width: calc(100% - 32px); }
  .masthead-inner { min-height: 56px; }
  .brand { gap: 8px; font-size: 14px; }
  .heading { display: block; margin-bottom: 20px; }
  .deadline { margin-top: 12px; text-align: left; }
  .deadline span, .deadline time { display: inline; }
  .deadline time { margin-left: 6px; }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 16px; }
  .facts { gap: 12px; }
  .ink-pad canvas { min-height: 148px; }
  .notice { margin-top: 16px; padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
