:root {
  color: #262221;
  background: #f4f2f1;
  font-family: Inter, Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --zf-red: #e52b25;
  --zf-red-strong: #bd211c;
  --zf-red-soft: rgba(229, 43, 37, 0.12);
  --zf-gold: #b2873d;
  --zf-ink: #262221;
  --zf-muted: #68707d;
  --zf-border: #dce1e7;
  --zf-paper: #fff;
  --zf-paper-soft: #faf9f8;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: #f4f2f1; }
body { min-height: 100%; margin: 0; color: var(--zf-ink); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 200; top: 8px; left: 8px; padding: 10px 14px; border-radius: 8px; background: #fff; color: var(--zf-red); transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--zf-paper);
  box-shadow: 0 0 46px rgba(42, 31, 30, 0.1);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid rgba(168, 15, 24, 0.09);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand img { width: 35px; height: 35px; object-fit: contain; }
.brand div { display: grid; }
.brand strong { font-size: 20px; line-height: 1; letter-spacing: -0.04em; }
.brand strong span { color: var(--zf-red); }
.brand small { margin-top: 4px; color: var(--zf-muted); font-size: 9px; letter-spacing: 0.02em; }
.security-label { padding: 6px 8px; border-radius: 999px; background: var(--zf-red-soft); color: var(--zf-red); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

.alert { margin: 12px 18px 0; padding: 12px 14px; border: 1px solid #eab9bc; border-radius: 10px; background: #fff1f2; color: #72171d; font-size: 13px; line-height: 1.4; }
.screen { min-height: calc(100svh - 72px); padding: 28px 22px calc(34px + env(safe-area-inset-bottom)); }
.loading-screen, .error-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.loading-screen p, .error-screen p { max-width: 320px; }
.loading-mark { width: 44px; height: 44px; margin-bottom: 22px; border: 3px solid var(--zf-red-soft); border-top-color: var(--zf-red); border-radius: 50%; animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-screen > img { width: 68px; height: 68px; margin-bottom: 20px; object-fit: contain; filter: grayscale(1); opacity: 0.66; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 11px; font-size: clamp(26px, 7vw, 32px); line-height: 1.08; letter-spacing: -0.035em; }
h2 { font-size: 16px; }
h3 { margin: 20px 0 10px; font-size: 12px; color: #49515d; }
p { color: var(--zf-muted); font-size: 14px; line-height: 1.5; }
.eyebrow { margin: 0 0 8px; color: var(--zf-red); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; }
.intro-block { margin: 30px 0 22px; }
.intro-block.compact { margin-bottom: 15px; }

.stepper { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; list-style: none; }
.stepper li { position: relative; display: grid; justify-items: center; gap: 6px; color: #9aa2ae; font-size: 10px; }
.stepper li::after { position: absolute; z-index: 0; top: 14px; left: calc(50% + 18px); width: calc(100% - 36px); height: 1px; background: #dce1e6; content: ""; }
.stepper li:last-child::after { display: none; }
.stepper li > span { z-index: 1; display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid #cfd5dd; border-radius: 50%; background: #fff; font-weight: 700; }
.stepper li.is-current { color: var(--zf-red); font-weight: 700; }
.stepper li.is-current > span { border-color: var(--zf-red); background: var(--zf-red); color: #fff; box-shadow: 0 0 0 5px var(--zf-red-soft); }
.stepper li.is-complete { color: #5c6570; }
.stepper li.is-complete > span { border-color: var(--zf-red); color: var(--zf-red); }
.stepper li.is-complete::after { background: rgba(168, 15, 24, 0.45); }

.otp-card { display: grid; gap: 11px; padding: 20px; border: 1px solid var(--zf-border); border-radius: 16px; background: var(--zf-paper-soft); }
.otp-card label { font-size: 13px; font-weight: 800; }
.otp-card input { width: 100%; min-height: 58px; padding: 0 14px; border: 1px solid #cbd2db; border-radius: 11px; background: #fff; color: var(--zf-ink); font-size: 25px; font-weight: 700; letter-spacing: 0.35em; text-align: center; }
.otp-card input:focus { border-color: var(--zf-red); outline: 3px solid var(--zf-red-soft); }
.otp-card > p { margin-bottom: 0; font-size: 11px; }
.local-test { padding: 10px 12px; border-left: 3px solid var(--zf-gold); background: #fff8e9; color: #6c5328; font-size: 12px; line-height: 1.4; }

.primary-button, .secondary-button, .text-button, .back-button { min-height: 48px; border-radius: 10px; font-weight: 800; }
.primary-button { width: 100%; padding: 0 18px; border: 1px solid var(--zf-red); background: var(--zf-red); color: #fff; box-shadow: 0 8px 20px rgba(229, 43, 37, 0.18); }
.primary-button:hover { background: var(--zf-red-strong); }
.primary-button:disabled { border-color: #d8dadd; background: #d8dadd; color: #818791; box-shadow: none; }
.secondary-button { width: 100%; padding: 0 16px; border: 1px solid var(--zf-red); background: #fff; color: var(--zf-red); }
.text-button, .back-button { padding: 0 8px; border: 0; background: transparent; color: var(--zf-red); }
.text-button:disabled { color: #9ca3ad; }
.helper-copy { margin: 12px 8px 0; font-size: 11px; text-align: center; }

.summary-card { margin-bottom: 18px; overflow: hidden; border: 1px solid var(--zf-border); border-radius: 17px; background: #fff; box-shadow: 0 12px 30px rgba(41, 31, 30, 0.06); }
.card-heading { display: flex; gap: 11px; align-items: center; padding: 16px 17px; border-bottom: 1px solid var(--zf-border); background: var(--zf-paper-soft); }
.card-heading img { width: 34px; height: 34px; object-fit: contain; }
.card-heading div { display: grid; gap: 3px; }
.card-heading span { color: var(--zf-red); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.card-heading strong { font-size: 16px; }
.summary-card dl { margin: 0; }
.summary-row { display: grid; gap: 4px; padding: 14px 17px; border-bottom: 1px solid #edf0f3; }
.summary-row dt { color: var(--zf-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.summary-row dd { display: grid; gap: 3px; margin: 0; font-size: 13px; line-height: 1.45; }
.summary-row dd span { color: var(--zf-muted); font-size: 11px; }
.summary-row .money { color: var(--zf-red); font-size: 19px; }
.service-list { display: grid; gap: 4px; margin: 0; padding-left: 18px; }
.source-note { padding: 12px 17px; border-left: 3px solid var(--zf-gold); background: #fffaf0; color: #655432; font-size: 10px; line-height: 1.4; }

.screen-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; margin: -8px 0 18px; }
.screen-heading h1 { grid-column: 2; margin: 0; font-size: 17px; text-align: center; }
.document-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--zf-muted); font-size: 10px; }
.document-meta strong { color: var(--zf-ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.contract-paper { margin-bottom: 16px; padding: 26px 20px; border: 1px solid var(--zf-border); border-radius: 5px; background: #fff; box-shadow: 0 13px 34px rgba(41, 31, 30, 0.07); }
.contract-paper header { padding-bottom: 18px; border-bottom: 2px solid var(--zf-red); text-align: center; }
.contract-paper header img { width: 46px; height: 46px; object-fit: contain; }
.contract-paper header h2 { margin: 10px 0 4px; font-family: Georgia, serif; font-size: 20px; }
.proposer-verification { width: fit-content; margin: 12px auto 0; padding: 7px 10px; border-radius: 999px; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 11px; font-weight: 800; }
.proposer-verification.is-blue { color: #175b9f; background: #e8f2ff; }
.proposer-verification.is-purple { color: #653092; background: #f0e6fa; }
.contract-paper section { margin-top: 22px; }
.contract-paper h3 { margin: 0 0 8px; color: var(--zf-ink); font-family: Georgia, serif; font-size: 14px; }
.contract-paper p, .contract-paper li { color: #3f444b; font-family: Georgia, serif; font-size: 12px; line-height: 1.65; text-align: justify; }
.contract-paper section > p { white-space: pre-line; }
.contract-paper ul { padding-left: 19px; }
.contract-total { margin-top: 22px; padding: 12px; background: var(--zf-paper-soft); text-align: right; }
.end-marker { margin: 0 0 16px; padding: 11px; border: 1px solid #dfc0c2; border-radius: 9px; background: var(--zf-red-soft); color: var(--zf-red); font-size: 11px; font-weight: 700; text-align: center; }

.verification-line { margin-bottom: 12px; padding: 10px 12px; border-radius: 9px; background: var(--zf-red-soft); color: var(--zf-red-strong); font-size: 11px; font-weight: 700; }
.session-expiry-note { margin: -4px 2px 12px; font-size: 11px; }
.contract-link { display: flex; width: 100%; min-height: 62px; align-items: center; justify-content: space-between; margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--zf-border); border-radius: 11px; background: #fff; color: var(--zf-ink); text-align: left; }
.contract-link span { color: var(--zf-red); font-size: 12px; }
.consent-section { margin-bottom: 18px; padding: 17px; border: 1px solid rgba(178, 135, 61, 0.5); border-radius: 15px; background: #fffaf0; }
.consent-section h2 { margin-bottom: 5px; }
.consent-section > p { margin-bottom: 12px; font-size: 11px; }
.presentation-section { margin-bottom: 18px; padding: 17px; border: 1px solid var(--zf-border); border-radius: 15px; background: var(--zf-paper-soft); }
.presentation-section h2 { margin-bottom: 13px; }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.method-grid button { position: relative; min-height: 58px; padding: 9px; border: 1px solid #d3d9e1; border-radius: 10px; background: #fff; color: #59616d; font-size: 11px; font-weight: 800; }
.method-grid button.is-selected { border-color: var(--zf-red); background: var(--zf-red-soft); color: var(--zf-red); box-shadow: inset 0 0 0 1px var(--zf-red); }
.typed-preview, .draw-preview { position: relative; display: grid; min-height: 130px; place-items: center; overflow: hidden; border: 1px solid #d6dde5; border-radius: 11px; background: #fff; }
.typed-preview { gap: 7px; padding: 14px; }
.typed-preview strong { font-size: 28px; font-weight: 400; text-align: center; }
.typed-preview strong[data-font="zfirma.signature.sans.v1"] { font-family: Arial, sans-serif; font-style: italic; }
.typed-preview strong[data-font="zfirma.signature.serif.v1"] { font-family: Georgia, serif; font-style: italic; }
.typed-preview strong[data-font="zfirma.signature.hand.v1"] { font-family: "Segoe Script", "Bradley Hand", cursive; }
.typed-preview small { color: var(--zf-muted); font-size: 9px; }
.font-options { display: flex; gap: 6px; margin-top: 8px; }
.font-options button { min-height: 34px; padding: 0 11px; border: 1px solid #d3d9e1; border-radius: 999px; background: #fff; color: var(--zf-muted); font-size: 10px; }
.font-options button.is-selected { border-color: var(--zf-red); color: var(--zf-red); }
.draw-preview { height: 132px; margin-bottom: 10px; }
.draw-preview > span, .full-canvas-wrap > span { position: absolute; color: #959da9; font-size: 11px; pointer-events: none; }
.draw-preview canvas, .full-canvas-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

.consent-box { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 11px; align-items: start; margin: 0; padding: 0; font-size: 12px; line-height: 1.5; cursor: pointer; }
.consent-box input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-control { display: grid; width: 28px; height: 28px; place-items: center; border: 1.5px solid #b8c2cf; border-radius: 7px; background: #fff; color: transparent; }
.consent-box input:focus-visible + .check-control { outline: 3px solid var(--zf-red-soft); }
.consent-box input:checked + .check-control { border-color: var(--zf-red); background: var(--zf-red); color: #fff; }

.draw-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); border: 0; background: var(--zf-paper); color: var(--zf-ink); }
.draw-dialog[open] { display: grid; grid-template-rows: auto auto minmax(260px, 1fr) auto; gap: 13px; }
.draw-dialog::backdrop { background: rgba(25, 18, 18, 0.6); }
.draw-header { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; }
.draw-header h2 { margin: 0; font-size: 15px; text-align: center; }
.draw-header .text-button { justify-self: end; }
.draw-dialog > p { margin: 0; font-size: 11px; text-align: center; }
.full-canvas-wrap { position: relative; display: grid; min-height: 260px; place-items: center; overflow: hidden; border: 1.5px dashed #aeb8c5; border-radius: 14px; background: #fff; }
.draw-toolbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.draw-toolbar button { min-height: 48px; border: 1px solid #d7dde5; border-radius: 10px; background: #fff; color: var(--zf-ink); font-size: 11px; font-weight: 700; }
.draw-toolbar button:disabled { color: #abb2bc; }
.discard-confirmation { position: fixed; z-index: 3; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); left: 16px; padding: 17px; border: 1px solid var(--zf-border); border-radius: 14px; background: #fff; box-shadow: 0 18px 46px rgba(35, 27, 26, 0.24); }
.discard-confirmation > strong { font-size: 15px; }
.discard-confirmation > p { margin: 5px 0 12px; font-size: 11px; }
.discard-confirmation > div { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.discard-confirmation button { min-height: 42px; padding: 0 11px; border: 1px solid var(--zf-border); border-radius: 9px; background: #fff; color: var(--zf-red); font-size: 10px; font-weight: 800; }
.discard-confirmation .danger-link { color: #7e1118; }

.success-screen { text-align: center; }
.success-mark { display: grid; width: 72px; height: 72px; place-items: center; margin: 34px auto 18px; border-radius: 50%; background: var(--zf-red); color: #fff; font-size: 35px; box-shadow: 0 0 0 10px var(--zf-red-soft); }
.evidence-card { margin: 26px 0 16px; padding: 17px; border: 1px solid var(--zf-border); border-radius: 14px; background: #fff; text-align: left; }
.evidence-card h2 { margin-bottom: 12px; }
.evidence-card ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.evidence-card li { position: relative; padding-left: 20px; color: #505965; font-size: 12px; }
.evidence-card li::before { position: absolute; left: 0; color: var(--zf-red); content: "✓"; font-weight: 900; }
.legal-note { padding: 12px; border-left: 3px solid var(--zf-gold); background: #fff8e9; font-size: 10px; text-align: left; }

:focus-visible { outline: 3px solid rgba(168, 15, 24, 0.28); outline-offset: 2px; }
@media (max-width: 520px) { .app-shell { width: 100%; box-shadow: none; } }
@media (min-width: 760px) { .app-shell { margin-block: 20px; min-height: calc(100svh - 40px); border-radius: 24px; overflow: clip; } .screen { min-height: calc(100svh - 112px); } }
@media (orientation: landscape) and (max-height: 620px) { .draw-dialog { grid-template-rows: auto auto minmax(170px, 1fr) auto; } .full-canvas-wrap { min-height: 170px; } }
@media (prefers-reduced-motion: reduce) { .loading-mark { animation: none; } }
