:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1d2c28;
  background: #f3f5f4;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  --accent: #1d5544;
  --accent-hover: #164334;
  --muted: #78837d;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overscroll-behavior: none; }
body.is-signing { overflow: hidden; position: fixed; inset: 0; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid #96bbaa; outline-offset: 3px; }
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.button:disabled { cursor: default; opacity: .55; }
.button svg { width: 19px; height: 19px; flex: none; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:not(:disabled):hover { background: var(--accent-hover); }
.button-secondary { color: #45554c; background: #fff; border-color: #dce3de; }
.button-secondary:not(:disabled):hover { background: #eaf0ec; }
.button-quiet { color: #63736a; padding: 0 6px; background: transparent; font-size: 14px; font-weight: 500; }
.button-quiet:not(:disabled):hover { color: var(--accent); }
.name-screen { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 32px 24px; }
.name-card { width: min(100%, 352px); margin-top: -3vh; }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; color: var(--accent); background: #e3ebe5; margin-bottom: 24px; }
.brand-mark svg { width: 28px; height: 28px; }
h1 { margin: 0 0 40px; font-size: 28px; font-weight: 650; letter-spacing: .03em; }
.name-card label { display: block; margin: 0 0 10px; color: #536259; font-size: 14px; font-weight: 600; }
.name-card input { width: 100%; height: 54px; padding: 0 15px; color: #1d2c28; background: #fff; border: 1px solid #d6dfd8; border-radius: 12px; font-size: 18px; appearance: none; }
.name-card input:focus { border-color: #5f8a73; }
.name-card input[aria-invalid="true"] { border-color: #b44b3b; }
.field-error { min-height: 20px; margin: 9px 0 17px; font-size: 13px; line-height: 20px; color: #ad4437; }
.start-button { width: 100%; min-height: 54px; justify-content: space-between; padding: 0 19px; }
.start-button span { font-size: 23px; font-weight: 400; }
.signature-screen { position: fixed; inset: 0; overflow: hidden; }
.signature-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--stage-width, 100vw);
  height: var(--stage-height, 100vh);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 24px;
  transform: translate(-50%, -50%);
  transform-origin: center;
}
.signature-stage.is-rotated { transform: translate(-50%, -50%) rotate(90deg); }
.signature-header { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 20px; flex: 0 0 auto; }
.signer { display: flex; align-items: baseline; justify-content: flex-end; gap: 12px; min-width: 0; }
#signer-name { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; font-weight: 650; }
.signer-label { flex: none; color: var(--muted); font-size: 13px; }
.paper-host { display: flex; flex: 1 1 auto; min-height: 0; align-items: center; justify-content: center; }
.signature-paper { flex: none; overflow: hidden; border-radius: 15px; background: #fff; box-shadow: 0 0 0 1px #dfe5e0, 0 5px 20px #263e2c04; }
#signature-canvas { display: block; width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; cursor: crosshair; }
#signature-canvas.is-locked { cursor: default; }
.signature-footer { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; min-height: 46px; gap: 14px; }
.save-status { flex: 1; min-width: 0; margin: 0; text-align: right; color: var(--accent); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.save-status.is-error { color: #ad4437; }
.save-button { min-width: 145px; justify-content: space-between; }
.save-button.is-saved:disabled { opacity: 1; background: #e1ece4; color: var(--accent); }
.save-button[aria-busy="true"] #save-icon { width: 14px; height: 14px; border: 2px solid #ffffff60; border-top-color: #fff; border-radius: 50%; font-size: 0; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-height: 370px) and (orientation: landscape), (max-width: 370px) and (orientation: portrait) {
  .signature-stage { padding: 8px 18px; gap: 8px; }
  .signature-header { min-height: 36px; }
  .signature-header .button { min-height: 36px; }
  .signature-footer .button { min-height: 42px; }
  #signer-name { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .save-button[aria-busy="true"] #save-icon { animation: none; }
}
