:root {
  color-scheme: light;
  font-family: "Work Sans", "Segoe UI", sans-serif;
  color: #16131a;
  background: #f7f5f8;
  --blue: #5170ff;
  --pink: #ff66c4;
  --ink: #16131a;
  --muted: #6f6875;
  --border: #ded9e1;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 5%, rgba(81, 112, 255, .10), transparent 28rem),
    radial-gradient(circle at 92% 90%, rgba(255, 102, 196, .09), transparent 30rem),
    #f8f7f9;
  overscroll-behavior: none;
}

button, input { font: inherit; }

.shell {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 24px;
}

.brand { text-align: center; margin: 0 auto 24px; }
.brand__name { font-family: Georgia, serif; font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: .08em; line-height: 1; color: #000; }
.brand__descriptor { display: inline-block; margin-top: 8px; font-size: .72rem; font-weight: 700; letter-spacing: .42em; color: var(--blue); background: linear-gradient(90deg, var(--blue), var(--pink)); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(222, 217, 225, .9);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(37, 25, 43, .10);
  padding: clamp(28px, 5vw, 54px);
}

.state { text-align: center; padding-block: clamp(54px, 10vw, 96px); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(1.8rem, 4.8vw, 3rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: clamp(1.25rem, 3vw, 1.65rem); }
p { color: var(--muted); line-height: 1.55; }
.eyebrow { margin-bottom: 12px; color: #765070; font-size: .76rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.muted { font-size: .9rem; }

.pairing-code { display: block; margin: 30px auto 16px; font-size: clamp(2.7rem, 11vw, 5.5rem); font-weight: 750; letter-spacing: .15em; color: var(--ink); }
.status-dot { width: 18px; height: 18px; margin: 0 auto 22px; border-radius: 50%; background: #32b778; box-shadow: 0 0 0 8px rgba(50, 183, 120, .13); }
.complete-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 24px; border-radius: 50%; background: #e5f8ef; color: #168653; font-size: 2.25rem; font-weight: 800; }
.spinner { width: 42px; height: 42px; margin: 0 auto 24px; border: 4px solid #eeeaf0; border-top-color: var(--blue); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.membership-type { font-weight: 650; color: #765070; }
.declaration { margin: 26px 0; padding: 22px; background: #f8f6f9; border-left: 4px solid var(--blue); border-radius: 4px 14px 14px 4px; color: #39333d; line-height: 1.62; white-space: pre-line; }
.acceptance { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 1px solid var(--border); border-radius: 14px; font-weight: 650; line-height: 1.4; cursor: pointer; }
.acceptance input { width: 25px; height: 25px; flex: 0 0 auto; accent-color: var(--blue); }
.policies { margin: 26px 0; }
.policy-agreement { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 1px solid var(--border); border-radius: 14px; font-weight: 650; line-height: 1.5; }
.policy-agreement input { width: 25px; height: 25px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--blue); }
.policy-link { display: inline; padding: 0; border: 0; background: transparent; color: #405fd4; font: inherit; font-weight: 750; text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .14em; cursor: pointer; }
.policy-link:hover, .policy-link:focus-visible { color: #a43d82; }
.policy-help { margin: 9px 4px 0; }
.policy-dialog { width: min(960px, calc(100% - 20px)); height: min(90vh, 900px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 28px 90px rgba(0,0,0,.3); }
.policy-dialog::backdrop { background: rgba(20, 15, 23, .68); }
.policy-dialog__header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.policy-dialog__header h2 { margin: 0; }
.policy-dialog iframe { display: block; width: 100%; height: calc(100% - 62px); border: 0; background: #eee; }

.signature-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-top: 32px; }
.signature-heading p { margin-bottom: 0; }
.canvas-frame { position: relative; height: clamp(210px, 35vh, 330px); margin: 16px 0 22px; overflow: hidden; background: #fff; border: 2px solid #bdb5c1; border-radius: 16px; touch-action: none; }
canvas { position: relative; z-index: 2; display: block; width: 100%; height: 100%; touch-action: none; }
.signature-line { position: absolute; z-index: 1; left: 9%; right: 9%; bottom: 22%; border-bottom: 1px solid #d4ced7; }
.canvas-frame.is-active { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(81, 112, 255, .12); }

.button { min-height: 52px; padding: 13px 24px; border-radius: 999px; border: 0; font-weight: 750; cursor: pointer; }
.button:disabled { opacity: .55; cursor: wait; }
.button--primary { width: 100%; color: #fff; background: linear-gradient(90deg, #405fe9, #c24e9a); box-shadow: 0 12px 28px rgba(81, 112, 255, .22); }
.button--secondary { color: var(--ink); background: #f0edf2; }
.text-button { padding: 8px 0; border: 0; background: transparent; color: #4a5fd0; font-weight: 700; cursor: pointer; }
.error { margin: -8px 0 16px; color: #ad2543; font-weight: 650; }
footer { padding: 8px 16px max(24px, env(safe-area-inset-bottom)); text-align: center; color: #827a87; font-size: .75rem; }

@media (max-width: 620px) {
  .shell { width: min(100% - 18px, 900px); padding-top: 18px; }
  .card { border-radius: 18px; padding: 24px 20px; }
  .signature-heading { display: block; }
  .text-button { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
